pnkx_nav_core 1.0 — every package with a remote is a submodule, and the root CMake builds them
A single commit on an orphan branch: the whole tree as it should land on a
robot, with no history from the branch it grew out of.
The rule applied: a package that has its own remote becomes a submodule; a
package that only ever lived inside this repository stays as ordinary files.
That comes to 29 submodules, 18 registered here for the first time. They were
sitting in the tree as plain clones, which looks right locally and is empty on
the robot - a clone of this repository would have carried the directory names
and none of the contents.
.gitignore is fixed at the source rather than patched per path. The rule
**/[Pp]ackages/* comes from the Visual Studio template and targets NuGet's
generated packages/ folder; here Packages/ is a SOURCE directory, so it hid
whole packages from git status - and a missing package then becomes invisible
to exactly the command you would use to look for one. It cost move_base2,
dock_pattern_action and sbpl_recovery, and sbpl_recovery surfaced only by
walking the tree for .git directories and diffing against .gitmodules. The
exception now re-includes src/*/Packages/** wholesale, placed immediately after
the NuGet rule so the build-artifact rules further down still win. Listing
paths one by one is what let one slip in the first place.
The root CMakeLists.txt described a tree that no longer exists. Its second half
was a migration shim that looked for a sibling Test/ directory from AMR_T800 and
added packages out of it; PNKX_NAV_CORE_BUILD_TEST_PACKAGES defaults to ON, so
with the migration finished it would have hit FATAL_ERROR at configure time.
That is gone, and the 18 packages are added in dependency order at their real
in-tree paths.
Two guard names are traps worth naming, because a guard that never matches adds
the subdirectory twice on a re-entrant configure:
- src/Libraries/angles is project robot_angles_prv, and a DIFFERENT package
called angles lives at src/Algorithms/Libraries/angles. Both are in the
tree; guarding on `angles` would silently skip the first.
- dock_pattern_action's library target is dock_pattern_action_handler, and
move_base2's is move_base2_core.
sbpl_recovery and dock_pattern_action call find_package(catkin REQUIRED) at top
level with no standalone branch, so they sit behind
PNKX_NAV_CORE_BUILD_CATKIN_ONLY_PACKAGES, OFF, with a message naming why. They
still build under catkin_make, which does not go through this file. Pulling
them into the standalone graph fails with "Could not find recovery_core", which
misleads: recovery_core IS in the tree and was added above, but the catkin
branch wants a recovery_coreConfig.cmake that a standalone build never
produces.
grid_map_core and image_geometry were added because hybrid_local_planner and
depth_image_proc link robot_grid_map_core and robot_image_geometry, and neither
was in the tree - found by scanning every CMakeLists for internal library names
and diffing against the targets the tree defines, then confirmed by the build.
Every submodule points at the tip of the branch it was already pinned to, not
blindly at main. costmap_2d stays on dev_cam_intel; that branch exists for a
reason, and this tree carries field calibration that does not belong on main.
config/ is flattened into config/runtime/, matching the layout the nav core
reads. The .zip snapshots of old package states are gone - manual backups, not
build inputs.
Verified: cmake configure returns 0 and a full build returns 0, producing 46
shared libraries.
This commit is contained in:
402
CMAKE_BUILD_README.md
Normal file
402
CMAKE_BUILD_README.md
Normal file
@@ -0,0 +1,402 @@
|
||||
# Hướng dẫn Build bằng CMake
|
||||
|
||||
Hướng dẫn chi tiết để build project `pnkx_nav_core` sử dụng CMake standalone (không cần Catkin workspace).
|
||||
|
||||
## Mục lục
|
||||
|
||||
1. [Yêu cầu hệ thống](#yêu-cầu-hệ-thống)
|
||||
2. [Cài đặt Dependencies](#cài-đặt-dependencies)
|
||||
3. [Build Project](#build-project)
|
||||
4. [Các tùy chọn Build](#các-tùy-chọn-build)
|
||||
5. [Install](#install)
|
||||
6. [Sử dụng trong project khác](#sử-dụng-trong-project-khác)
|
||||
7. [Troubleshooting](#troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## Yêu cầu hệ thống
|
||||
|
||||
### Hệ điều hành
|
||||
- Linux (Ubuntu 18.04+ hoặc tương đương)
|
||||
### Compiler
|
||||
- **GCC**: phiên bản 7.0 trở lên (hỗ trợ C++17)
|
||||
- **Clang**: phiên bản 5.0 trở lên
|
||||
|
||||
### CMake
|
||||
- **CMake**: phiên bản 3.10 trở lên
|
||||
|
||||
Kiểm tra phiên bản:
|
||||
```bash
|
||||
cmake --version
|
||||
g++ --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cài đặt Dependencies
|
||||
|
||||
### Linux (Ubuntu/Debian)
|
||||
|
||||
```bash
|
||||
# Cập nhật package list
|
||||
sudo apt-get update
|
||||
|
||||
# Cài đặt CMake và build tools
|
||||
sudo apt-get install -y cmake build-essential
|
||||
|
||||
# Cài đặt các thư viện cần thiết
|
||||
sudo apt-get install -y \
|
||||
libboost-all-dev \
|
||||
libeigen3-dev \
|
||||
libyaml-cpp-dev \
|
||||
libpcl-dev \
|
||||
libgoogle-glog-dev
|
||||
sudo apt install liborocos-kdl-dev
|
||||
|
||||
# Optional: Cài đặt Google Test (nếu muốn build tests)
|
||||
sudo apt-get install -y libgtest-dev
|
||||
```
|
||||
|
||||
**Lưu ý:** Hướng dẫn này dành cho hệ thống Linux. Nếu sử dụng các distro khác (CentOS, Fedora, Arch, etc.), vui lòng cài đặt các packages tương ứng bằng package manager của distro đó.
|
||||
|
||||
---
|
||||
|
||||
## Build Project
|
||||
|
||||
### Bước 1: Clone repository
|
||||
|
||||
```bash
|
||||
git clone https://git.pnkr.asia/HiepLM/pnkx_nav_core.git
|
||||
cd pnkx_nav_core
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
### Bước 2: Tạo thư mục build
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
```
|
||||
|
||||
### Bước 3: Cấu hình với CMake
|
||||
|
||||
```bash
|
||||
# Cấu hình cơ bản (Release mode)
|
||||
cmake ..
|
||||
|
||||
# Hoặc chỉ định build type rõ ràng
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
|
||||
# Hoặc Debug mode (để debug)
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
```
|
||||
|
||||
### Bước 4: Build
|
||||
|
||||
```bash
|
||||
# Build tất cả targets
|
||||
make
|
||||
|
||||
# Hoặc build với nhiều cores (nhanh hơn)
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
### Bước 5: Kiểm tra build thành công
|
||||
|
||||
```bash
|
||||
# Kiểm tra các thư viện đã được build
|
||||
ls -la lib/
|
||||
|
||||
# Kiểm tra các executable (nếu có)
|
||||
ls -la bin/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Các tùy chọn Build
|
||||
|
||||
### Build Type
|
||||
|
||||
```bash
|
||||
# Release mode (mặc định) - tối ưu hóa
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
|
||||
# Debug mode - với debug symbols
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
|
||||
# RelWithDebInfo - Release với debug info
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
||||
|
||||
# MinSizeRel - Tối ưu kích thước
|
||||
cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
|
||||
```
|
||||
|
||||
### Build chỉ một target cụ thể
|
||||
|
||||
```bash
|
||||
# Build chỉ một library
|
||||
make robot_cpp_node_handle
|
||||
|
||||
# Build chỉ move_base
|
||||
make move_base
|
||||
|
||||
# Build chỉ C API
|
||||
make navigation_c_api
|
||||
```
|
||||
|
||||
### Các tùy chọn CMake khác
|
||||
|
||||
```bash
|
||||
# Tắt warnings (đã được cấu hình sẵn trong CMakeLists.txt)
|
||||
cmake -DCMAKE_CXX_FLAGS="-w" ..
|
||||
|
||||
# Chỉ định compiler
|
||||
cmake -DCMAKE_CXX_COMPILER=g++-9 ..
|
||||
|
||||
# Chỉ định install prefix
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
|
||||
|
||||
# Build tests (nếu có)
|
||||
cmake -DBUILD_TESTS=ON ..
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
Sau khi build thành công, bạn có thể install các thư viện và headers vào hệ thống:
|
||||
|
||||
```bash
|
||||
# Install vào thư mục mặc định (/usr/local)
|
||||
sudo make install
|
||||
|
||||
# Hoặc install vào thư mục tùy chỉnh
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/opt/pnkx_nav_core ..
|
||||
make install
|
||||
```
|
||||
|
||||
Cấu trúc sau khi install:
|
||||
```
|
||||
/usr/local/
|
||||
├── include/
|
||||
│ ├── robot/
|
||||
│ ├── nav_core2/
|
||||
│ ├── mkt_algorithm/
|
||||
│ └── ...
|
||||
├── lib/
|
||||
│ ├── librobot_cpp_node_handle.so
|
||||
│ ├── libmove_base.so
|
||||
│ └── ...
|
||||
└── lib/cmake/
|
||||
├── robot_cpp/
|
||||
├── move_base/
|
||||
└── ...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Sử dụng trong project khác
|
||||
|
||||
### Sử dụng với CMake
|
||||
|
||||
Sau khi install, bạn có thể sử dụng trong CMakeLists.txt của project khác:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(my_project)
|
||||
|
||||
# Tìm các packages
|
||||
find_package(robot_cpp REQUIRED)
|
||||
find_package(move_base REQUIRED)
|
||||
find_package(navigation_c_api REQUIRED)
|
||||
|
||||
# Link libraries
|
||||
add_executable(my_app main.cpp)
|
||||
target_link_libraries(my_app
|
||||
PRIVATE
|
||||
robot_cpp
|
||||
move_base
|
||||
navigation_c_api
|
||||
)
|
||||
```
|
||||
|
||||
### Sử dụng C API (cho .NET/C#)
|
||||
|
||||
Xem hướng dẫn chi tiết trong `examples/README.md` và `examples/QUICK_START.md`.
|
||||
|
||||
Tóm tắt:
|
||||
```bash
|
||||
# Copy shared library
|
||||
cp build/src/APIs/c_api/libnavigation_c_api.so /path/to/your/project/
|
||||
|
||||
# Sử dụng trong C#
|
||||
[DllImport("libnavigation_c_api.so")]
|
||||
public static extern IntPtr create_navigation();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Lỗi: "Could not find Boost"
|
||||
|
||||
```bash
|
||||
# Kiểm tra Boost đã được cài đặt
|
||||
dpkg -l | grep libboost
|
||||
|
||||
# Cài đặt lại nếu thiếu
|
||||
sudo apt-get install libboost-all-dev
|
||||
```
|
||||
|
||||
### Lỗi: "Could not find Eigen3"
|
||||
|
||||
```bash
|
||||
# Cài đặt Eigen3
|
||||
sudo apt-get install libeigen3-dev
|
||||
|
||||
# Hoặc chỉ định đường dẫn
|
||||
cmake -DEigen3_DIR=/usr/include/eigen3 ..
|
||||
```
|
||||
|
||||
### Lỗi: "Could not find yaml-cpp"
|
||||
|
||||
```bash
|
||||
# Cài đặt yaml-cpp
|
||||
sudo apt-get install libyaml-cpp-dev
|
||||
```
|
||||
|
||||
### Lỗi: "undefined reference"
|
||||
|
||||
Đảm bảo tất cả dependencies đã được build theo đúng thứ tự:
|
||||
1. Core libraries (tf3, robot_time, xmlrpcpp, robot_cpp)
|
||||
2. Geometry và messages (geometry2, common_msgs)
|
||||
3. Navigation cores (nav_core, nav_core2)
|
||||
4. Algorithms (score_algorithm, mkt_algorithm)
|
||||
5. Main packages (move_base)
|
||||
|
||||
Build lại từ đầu:
|
||||
```bash
|
||||
cd build
|
||||
rm -rf *
|
||||
cmake ..
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
### Lỗi: "Permission denied" khi install
|
||||
|
||||
```bash
|
||||
# Sử dụng sudo cho system-wide install
|
||||
sudo make install
|
||||
|
||||
# Hoặc install vào user directory
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..
|
||||
make install
|
||||
```
|
||||
|
||||
### Build chậm
|
||||
|
||||
```bash
|
||||
# Sử dụng nhiều cores
|
||||
make -j$(nproc)
|
||||
|
||||
# Chỉ build target cần thiết
|
||||
make robot_cpp_node_handle # Thay vì make all
|
||||
```
|
||||
|
||||
### Clean build
|
||||
|
||||
```bash
|
||||
# Xóa toàn bộ build directory
|
||||
cd build
|
||||
rm -rf *
|
||||
|
||||
# Hoặc xóa chỉ các file object
|
||||
make clean
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cấu trúc Build Output
|
||||
|
||||
Sau khi build, cấu trúc thư mục `build/` sẽ như sau:
|
||||
|
||||
```
|
||||
build/
|
||||
├── CMakeCache.txt
|
||||
├── CMakeFiles/
|
||||
├── cmake_install.cmake
|
||||
├── Makefile
|
||||
├── lib/
|
||||
│ ├── librobot_cpp_console.so
|
||||
│ ├── librobot_cpp_node_handle.so
|
||||
│ ├── libmove_base.so
|
||||
│ ├── libnavigation_c_api.so
|
||||
│ └── ...
|
||||
├── src/
|
||||
│ ├── Libraries/
|
||||
│ │ ├── robot_cpp/
|
||||
│ │ └── ...
|
||||
│ ├── Navigations/
|
||||
│ │ └── ...
|
||||
│ └── Algorithms/
|
||||
│ └── ...
|
||||
└── bin/ # (nếu có executables)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Một số biến môi trường hữu ích:
|
||||
|
||||
```bash
|
||||
# Chỉ định config directory cho NodeHandle
|
||||
export PNKX_NAV_CORE_CONFIG_DIR=/path/to/config
|
||||
|
||||
# Chỉ định workspace directory
|
||||
export PNKX_NAV_CORE_DIR=/path/to/pnkx_nav_core
|
||||
|
||||
# LD_LIBRARY_PATH (nếu không install)
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/pnkx_nav_core/build/lib
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Build nhanh (một lệnh)
|
||||
|
||||
```bash
|
||||
mkdir -p build && cd build && cmake .. && make -j$(nproc)
|
||||
```
|
||||
|
||||
### Build và Install
|
||||
|
||||
```bash
|
||||
mkdir -p build && cd build && cmake .. && make -j$(nproc) && sudo make install
|
||||
```
|
||||
|
||||
### Rebuild từ đầu
|
||||
|
||||
```bash
|
||||
rm -rf build && mkdir build && cd build && cmake .. && make -j$(nproc)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Liên kết hữu ích
|
||||
|
||||
- [CMake Documentation](https://cmake.org/documentation/)
|
||||
- [C++17 Reference](https://en.cppreference.com/w/cpp/17)
|
||||
- [Examples](./examples/README.md)
|
||||
- [Catkin Build Guide](./CATKIN_BUILD_README.md)
|
||||
|
||||
---
|
||||
|
||||
## Ghi chú
|
||||
|
||||
- Project này sử dụng **C++17** standard
|
||||
- Warnings đã được tắt trong build configuration (`-w` flag)
|
||||
- Tất cả libraries được build dưới dạng **shared libraries** (.so)
|
||||
- Build type mặc định là **Release** với optimization `-O3`
|
||||
Reference in New Issue
Block a user