在场地放置在体育馆内,用Xmake构建导航的纯算法库
This commit is contained in:
1 parent
f7412ec369
commit
f25ce828ce
50 files changed
+3689
-180
No files matched your search
@@ -23,6 +23,69 @@ source install/setup.bash
|
||||
> 所以 `CMakeLists.txt` 用 `ament_cmake_auto`(按 `package.xml` 的 `<depend>` 自动处理)。
|
||||
> 网上老教程里的 `ament_target_dependencies(...)` 在这里会直接报"Unknown CMake command"。
|
||||
|
||||
### C++ 标准:23
|
||||
|
||||
`CMakeLists.txt` 里是 **C++23**(2026-11-16 从 C++17 升级,实测 GCC 15.2 + 全部依赖通过)。
|
||||
|
||||
**下限是 C++17,不能再低** —— 这是被依赖强制的,不是风格选择:
|
||||
|
||||
| 依赖 | 最低标准 | 证据(实测编译报错) |
|
||||
|---|---|---|
|
||||
| ROS 2 Lyrical 的 rclcpp | C++17 | C++11 → `'make_unique' is not a member of 'std'`(要 14)<br>C++14 → `'is_same_v' is not a member of 'std'`(要 17) |
|
||||
| PCL 1.15 | C++17 | `pcl_config.h:7: #error C++ standard too low (PCL requires 201703L or above)` |
|
||||
|
||||
### 为什么不用 Xmake 替代 CMake
|
||||
|
||||
**不能**,ROS 2 的 C++ 包必须走 CMake。三层理由:
|
||||
|
||||
1. **colcon 只认 `package.xml` 的 `<build_type>`** —— 本包是 `ament_cmake`,
|
||||
colcon 的后端列表里没有 xmake。
|
||||
2. **`ament_cmake_auto` 本身就是一堆 CMake 宏**
|
||||
(`macro(ament_auto_add_executable target)`),不是独立构建系统。
|
||||
3. **实测 xmake v3.1.1 编 `patrol.cpp`**:目标文件能生成,但**链接失败**:
|
||||
|
||||
```
|
||||
undefined reference to symbol 'rcl_timer_call_with_info'
|
||||
/opt/ros/lyrical/lib/librcl.so: error adding symbols: DSO missing from command line
|
||||
```
|
||||
|
||||
因为 ament 会自动展开整条传递依赖链;手工写 xmake 得自己枚举
|
||||
(全 ROS 光 `*__rosidl_typesupport_cpp.so` 就有 **47 个**)。
|
||||
|
||||
> **想要 xmake 的体验,正确姿势是分层** —— 这个方案 **2026-11-16 已落地**,见下一节。
|
||||
|
||||
### 分层:纯算法库 + ROS 胶水
|
||||
|
||||
```
|
||||
src/sentry_nav_core/ ← 纯 C++,零 ROS / 零 PCL 依赖,用 xmake 构建
|
||||
├── SelfFilterCore 一个点保留还是丢弃(+ 丢弃原因)
|
||||
├── WaypointSequencer 当前航点 / 走完没有 / 结果计数
|
||||
├── tests/ 85 项检查,1 秒跑完
|
||||
└── xmake.lua
|
||||
|
||||
src/sentry_nav/ ← 本包只做 ROS 胶水
|
||||
├── src/self_filter.cpp 订阅 → TF → 调 SelfFilterCore → 发布
|
||||
├── src/patrol.cpp 定时器 → 调 WaypointSequencer → 发动作目标
|
||||
└── CMakeLists.txt 把 sentry_nav_core 的源码编成静态库再链接
|
||||
```
|
||||
|
||||
| | 核心库(xmake) | ROS 包(colcon) |
|
||||
|---|---|---|
|
||||
| 编译时间 | **1.4 秒** | 约 8 秒 |
|
||||
| 跑测试 | **1 秒 / 85 项** | 要起 Gazebo + Nav2 |
|
||||
| 依赖 | 只要 C++23 编译器 | rclcpp / PCL / tf2 … |
|
||||
|
||||
**两套构建系统共享同一份源码**,没有复制粘贴;`colcon build` 依然自包含
|
||||
(队友不需要装 xmake),而你可以用 xmake 秒级迭代核心逻辑。
|
||||
|
||||
```bash
|
||||
cd ../sentry_nav_core
|
||||
xmake run_tests # 85 项检查,1 秒
|
||||
```
|
||||
|
||||
> 以后加决策状态机(PATROL / ENGAGE / RETREAT)时,先在这个库里写纯逻辑 + 单测,
|
||||
> 跑通了再接到 ROS 节点上 —— 不用每次都起 Gazebo 试。
|
||||
|
||||
## 跑起来
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user