pnkx_nav_core 1.0 — every package with a remote is a submodule at its pinned commit
A single commit on an orphan branch, so this is 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 27 submodules, 16 of them 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. That failure reports itself as "works
on my machine, not on the robot", and it is why this conversion happened.
Newly registered:
src/Navigations/Packages/move_base2
src/Algorithms/Packages/actions/dock_pattern_action
src/Algorithms/Packages/recoveries/sbpl_recovery
src/Algorithms/Packages/global_planners/sbpl_lattice_planner
src/Algorithms/Packages/local_planners/{hybrid,mppi,priest}_local_planner
src/Libraries/{action_core,angles,depth_image_proc,dock_pattern_detector}
src/Libraries/{mission_adapters,recovery_core,robot_line_extraction}
src/Libraries/{robot_sensor_ports,sbpl}
.gitignore had a rule - **/[Pp]ackages/* - that hid move_base2,
dock_pattern_action and sbpl_recovery from git status entirely, so they would
have been left out with nothing said about it. sbpl_recovery was found only by
walking the tree for .git directories and comparing against .gitmodules, not by
reading git status, which is the lesson worth keeping: an ignore rule makes a
missing package invisible to exactly the command you would use to look for one.
The exception is written for those three paths only rather than by loosening
the rule.
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.
The other 26 are at the tip of main.
config/ is flattened into config/runtime/, matching the layout the nav core
reads. The .zip snapshots of old package states are gone - they were manual
backups, not build inputs.
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