将 note 笔记库同步到 note_sync,AI_compiler 作为 submodule
This commit is contained in:
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"promptDelete": false
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"file-explorer": true,
|
||||
"global-search": true,
|
||||
"switcher": true,
|
||||
"graph": true,
|
||||
"backlink": true,
|
||||
"canvas": true,
|
||||
"outgoing-link": true,
|
||||
"tag-pane": true,
|
||||
"footnotes": false,
|
||||
"properties": true,
|
||||
"page-preview": true,
|
||||
"daily-notes": true,
|
||||
"templates": true,
|
||||
"note-composer": true,
|
||||
"command-palette": true,
|
||||
"slash-command": false,
|
||||
"editor-status": true,
|
||||
"bookmarks": true,
|
||||
"markdown-importer": false,
|
||||
"zk-prefixer": false,
|
||||
"random-note": false,
|
||||
"outline": true,
|
||||
"word-count": true,
|
||||
"slides": false,
|
||||
"audio-recorder": false,
|
||||
"workspaces": false,
|
||||
"file-recovery": true,
|
||||
"publish": false,
|
||||
"sync": true,
|
||||
"bases": true,
|
||||
"webviewer": false
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"collapse-filter": false,
|
||||
"search": "",
|
||||
"showTags": false,
|
||||
"showAttachments": false,
|
||||
"hideUnresolved": false,
|
||||
"showOrphans": true,
|
||||
"collapse-color-groups": false,
|
||||
"colorGroups": [
|
||||
{
|
||||
"query": "tag:",
|
||||
"color": {
|
||||
"a": 1,
|
||||
"rgb": 14048348
|
||||
}
|
||||
}
|
||||
],
|
||||
"collapse-display": true,
|
||||
"showArrow": false,
|
||||
"textFadeMultiplier": 0,
|
||||
"nodeSizeMultiplier": 1,
|
||||
"lineSizeMultiplier": 1,
|
||||
"collapse-forces": true,
|
||||
"centerStrength": 0.518713248970312,
|
||||
"repelStrength": 10,
|
||||
"linkStrength": 1,
|
||||
"linkDistance": 250,
|
||||
"scale": 1,
|
||||
"close": true
|
||||
}
|
||||
Vendored
+201
@@ -0,0 +1,201 @@
|
||||
{
|
||||
"main": {
|
||||
"id": "914c9e8d9774b62f",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "22be749e4ad854f0",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "0f14a7f3e342ee77",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "ros2/概念/基础概念.md",
|
||||
"mode": "preview",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "基础概念"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
},
|
||||
"left": {
|
||||
"id": "3d550c51e4dc52dd",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "64ee6b66868da0e5",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "4a3332297ce1ac65",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "file-explorer",
|
||||
"state": {
|
||||
"sortOrder": "alphabetical",
|
||||
"autoReveal": false
|
||||
},
|
||||
"icon": "lucide-folder-closed",
|
||||
"title": "文件列表"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "94dc470ccbf6e453",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "search",
|
||||
"state": {
|
||||
"query": "",
|
||||
"matchingCase": false,
|
||||
"explainSearch": false,
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical"
|
||||
},
|
||||
"icon": "lucide-search",
|
||||
"title": "搜索"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "a49ddb63b7b71d3d",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "bookmarks",
|
||||
"state": {},
|
||||
"icon": "lucide-bookmark",
|
||||
"title": "书签"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300
|
||||
},
|
||||
"right": {
|
||||
"id": "94ee3ffae97277f1",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "30c22dd0ea555284",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "e08ac0b7a754e82a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
"showSearch": false,
|
||||
"searchQuery": "",
|
||||
"backlinkCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
},
|
||||
"icon": "links-coming-in",
|
||||
"title": "反向链接"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "c28b4721bbc7549d",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
},
|
||||
"icon": "links-going-out",
|
||||
"title": "出链"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "951c9abc2fe22169",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "tag",
|
||||
"state": {
|
||||
"sortOrder": "frequency",
|
||||
"useHierarchy": true,
|
||||
"showSearch": false,
|
||||
"searchQuery": ""
|
||||
},
|
||||
"icon": "lucide-tags",
|
||||
"title": "标签"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "ced613ec67772cc8",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "all-properties",
|
||||
"state": {
|
||||
"sortOrder": "frequency",
|
||||
"showSearch": false,
|
||||
"searchQuery": ""
|
||||
},
|
||||
"icon": "lucide-archive",
|
||||
"title": "添加笔记属性"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "31cad42ee1968b90",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"followCursor": false,
|
||||
"showSearch": false,
|
||||
"searchQuery": ""
|
||||
},
|
||||
"icon": "lucide-list",
|
||||
"title": "大纲"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300,
|
||||
"collapsed": true
|
||||
},
|
||||
"left-ribbon": {
|
||||
"hiddenItems": {
|
||||
"switcher:打开快速切换": false,
|
||||
"graph:查看关系图谱": false,
|
||||
"canvas:新建白板": false,
|
||||
"daily-notes:打开/创建今天的日记": false,
|
||||
"templates:插入模板": false,
|
||||
"command-palette:打开命令面板": false,
|
||||
"bases:新建数据库": false
|
||||
}
|
||||
},
|
||||
"active": "0f14a7f3e342ee77",
|
||||
"lastOpenFiles": [
|
||||
"ros2/概念/基础概念.md",
|
||||
"ros2/安装配置/环境配置.md",
|
||||
"ros2/概念",
|
||||
"ros2/新建文件夹",
|
||||
"未命名",
|
||||
"ros2/安装配置",
|
||||
"ros2/安装配置/代码更新_zh.md",
|
||||
"未命名.md",
|
||||
"ros2/安装配置/ros2_structure.md",
|
||||
"ros2/安装配置/安装_zh.md",
|
||||
"ros2/安装配置/安装.md",
|
||||
"欢迎.md",
|
||||
"创建链接.md",
|
||||
"ros2",
|
||||
"desktop.ini"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
``` bash
|
||||
root@nvidia:~/ros2_ws# ros2 topic echo /goal_pose
|
||||
header:
|
||||
stamp:
|
||||
sec: 1776912839
|
||||
nanosec: 772353086
|
||||
frame_id: map
|
||||
pose:
|
||||
position:
|
||||
x: -0.2929971516132355
|
||||
y: -28.93631362915039
|
||||
z: 0.0
|
||||
orientation:
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: -0.7140266359687852
|
||||
w: 0.7001185350546718
|
||||
---
|
||||
header:
|
||||
stamp:
|
||||
sec: 1776912894
|
||||
nanosec: 349057427
|
||||
frame_id: map
|
||||
pose:
|
||||
position:
|
||||
x: 1.0191293954849243
|
||||
y: -23.940237045288086
|
||||
z: 0.0
|
||||
orientation:
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: -0.758253550259611
|
||||
w: 0.6519597790651626
|
||||
---
|
||||
header:
|
||||
stamp:
|
||||
sec: 1776912930
|
||||
nanosec: 59193832
|
||||
frame_id: map
|
||||
pose:
|
||||
position:
|
||||
x: -0.25821736454963684
|
||||
y: -26.604511260986328
|
||||
z: 0.0
|
||||
orientation:
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: -0.7286561115363753
|
||||
w: 0.6848797493872113
|
||||
---
|
||||
header:
|
||||
stamp:
|
||||
sec: 1776913007
|
||||
nanosec: 811936088
|
||||
frame_id: map
|
||||
pose:
|
||||
position:
|
||||
x: -0.5403046607971191
|
||||
y: -23.95861053466797
|
||||
z: 0.0
|
||||
orientation:
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: -0.7323575592769619
|
||||
w: 0.6809202635917743
|
||||
---
|
||||
header:
|
||||
stamp:
|
||||
sec: 1776913105
|
||||
nanosec: 601216801
|
||||
frame_id: map
|
||||
pose:
|
||||
position:
|
||||
x: -0.13717754185199738
|
||||
y: -31.840221405029297
|
||||
z: 0.0
|
||||
orientation:
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: -0.6531641242066932
|
||||
w: 0.7572163672618966
|
||||
---
|
||||
|
||||
```
|
||||
|
||||
雷达同步问题
|
||||
```
|
||||
ros2_ws\src\rslidar_sdk\config\config.yaml
|
||||
use_lidar_clock: false
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
---
|
||||
⚠️ 警告1:No goal checker was specified in parameter 'current_goal_checker'. Server will use only plugin loaded
|
||||
general_goal_checker
|
||||
|
||||
含义
|
||||
|
||||
这是配置缺失类警告,不影响功能,只是提示你没有显式指定当前使用的目标检查器,系统自动用了第一个加载的general_goal_check
|
||||
er。
|
||||
根因
|
||||
|
||||
ROS2 Humble及以上版本的Nav2新增了current_goal_checker强制配置项,你的配置里只定义了goal_checker插件,但没有指定当前使
|
||||
用哪一个。
|
||||
✅ 解决方案
|
||||
|
||||
在controller_server的ros__parameters下添加一行即可:
|
||||
controller_server:
|
||||
ros__parameters:
|
||||
current_goal_checker: "general_goal_checker" # 新增这行
|
||||
controller_frequency: 20.0
|
||||
# ... 其他原有配置
|
||||
|
||||
---
|
||||
⚠️ 警告2:Behavior Tree tick rate 100.00 was exceeded!
|
||||
|
||||
含义
|
||||
|
||||
这是性能类警告,行为树默认tick频率是100Hz(每10ms执行一次),现在单次tick执行时间超过了10ms,导致频率不达标。
|
||||
根因
|
||||
|
||||
行为树中的计算密集型节点执行太慢,90%的情况是MPPI控制器计算耗时过长,小概率是系统CPU负载过高、规划器卡顿等。
|
||||
✅ 排查&解决方案
|
||||
|
||||
1. 先看CPU占用:top 看controller_server进程的CPU占比,如果超过100%就是计算量太大
|
||||
2. 优先优化MPPI参数(你的当前配置计算量过高),后面警告3会详细说
|
||||
3. 实在优化不了可以调大BT的tick间隔,在bt_navigator下加:
|
||||
bt_navigator:
|
||||
ros__parameters:
|
||||
bt_loop_duration: 20 # 从10ms改成20ms,频率降到50Hz,不推荐,优先优化控制器
|
||||
|
||||
---
|
||||
⚠️ 警告3:Control loop missed its desired rate of 20.0000Hz
|
||||
|
||||
含义
|
||||
|
||||
这是核心性能警告,控制器要求20Hz的控制频率(每50ms输出一次速度指令),现在单次循环执行超过了50ms,频率不达标。
|
||||
⚠️ 这个问题必须优先解决:控制频率低于15Hz会导致MPPI控制不稳定,甚至出现急刹、撞障碍物的情况。
|
||||
根因
|
||||
|
||||
你的MPPI配置计算量过大,两个核心参数超标:
|
||||
FollowPath:
|
||||
batch_size: 2000 # 单次迭代采样2000条轨迹,计算量极大
|
||||
time_steps: 56 # 每条轨迹预测56步(0.05*56=2.8秒预测时长)
|
||||
- 2000的batch_size在Jetson NX级别的嵌入式平台单次计算就要60-80ms,肯定达不到50ms的要求
|
||||
- 额外加重负载的配置:local costmap的obstacle_max_range: 20.0,local
|
||||
costmap本身只有6m×6m,处理20米内的点云完全是浪费CPU
|
||||
✅ 解决方案(按优先级)
|
||||
|
||||
1. 调小MPPI计算量(优先保证控制频率达标):
|
||||
FollowPath:
|
||||
batch_size: 1000 # 降到800-1200,轨迹采样数减半,性能提升一倍,效果下降不明显
|
||||
time_steps: 40 # 降到32-40,预测时长2秒足够,履带车速度慢不需要太长预测
|
||||
2. 缩小local costmap障碍物检测范围:
|
||||
# local_costmap的voxel_layer下的scan配置
|
||||
obstacle_max_range: 10.0 # 从20米改成10米,足够覆盖6m的local costmap范围
|
||||
3. 验证效果:改完后用ros2 topic hz /cmd_vel_nav看频率,稳定在18Hz以上就算合格
|
||||
|
||||
---
|
||||
❌ 错误1:Failed to create a plan from potential when a legal potential was found. This shouldn't happen.
|
||||
|
||||
含义
|
||||
|
||||
这是Navfn规划器内部错误:规划器已经算出了从起点到终点的势场(理论上存在可行路径),但实际提取路径的时候失败了。
|
||||
根因
|
||||
|
||||
结合你的配置,最可能的几个原因:
|
||||
4. 可行通道太窄:你的膨胀半径是1.8m,车身本身宽1.8m,通道宽度必须大于3.6m才能通过,如果路径上有窄于这个宽度的通道,膨
|
||||
胀后就没有可行空间了
|
||||
5. 起点/终点落在膨胀区内:虽然势场是通的,但膨胀后的代价太高,路径提取的时候找不到合法的起点/终点
|
||||
6. 膨胀半径过大:1.8m的膨胀半径刚好是车身宽度,没有冗余,稍微有点障碍物就会把通道堵死
|
||||
7. 全局costmap噪点过多:点云误检的障碍物挡住了路径
|
||||
✅ 排查&解决方案
|
||||
|
||||
8. 排查路径情况:规划失败时,在rviz上看起点到终点的通道宽度,是不是小于3.6m
|
||||
9. 优化膨胀半径(如果通道普遍较窄):
|
||||
# 全局和局部costmap的inflation_radius都可以降到1.5m(只要大于车身最大半长1.2m就满足SMAC优化要求)
|
||||
inflation_radius: 1.5
|
||||
10. 优化Navfn参数:
|
||||
GridBased:
|
||||
tolerance: 1.0 # 从0.5米改成1.0米,允许终点有更大的容忍范围
|
||||
11. 终极方案:换规划器:如果经常走窄通道,把Navfn换成nav2_smac_planner/SmacPlanner,对窄通道的支持好很多
|
||||
12. 检查全局costmap噪点:如果有很多误检的小障碍物,调大mark_threshold过滤噪点
|
||||
|
||||
---
|
||||
❌ 错误2:Failed to get result for follow_path in node halt!
|
||||
|
||||
含义
|
||||
|
||||
这是次生错误,不影响功能,只是日志提示:行为树在终止(halt)的时候,尝试获取follow_path节点的执行结果,但结果不存在。
|
||||
根因
|
||||
|
||||
完全是前面的规划失败导致的连锁反应:规划失败后整个导航任务提前终止,follow_path节点还没来得及产生结果就被强制停止了。
|
||||
✅ 解决方案
|
||||
|
||||
解决前面的规划失败问题后,这个错误会自动消失,不需要单独处理。
|
||||
|
||||
---
|
||||
🎯 解决优先级建议
|
||||
|
||||
13. 【最高优先级】先解决控制循环频率不够的问题,直接影响导航安全性
|
||||
14. 【次高优先级】解决规划失败的问题,影响导航可用性
|
||||
15. 【低优先级】解决剩下的配置类警告,不影响功能只是优化日志
|
||||
|
||||
额外优化建议
|
||||
|
||||
你现在的voxel层mark_threshold: 10有点太高了,需要10个点才能标记障碍物,容易漏检小障碍物,建议调到3-5更合适:
|
||||
voxel_layer:
|
||||
mark_threshold: 3 # 从10改成3,平衡噪点过滤和小障碍物检测
|
||||
```
|
||||
@@ -0,0 +1,356 @@
|
||||
# Navigation2 详解:nav2_bringup 与 nav2_gps_waypoint_follower_demo
|
||||
|
||||
## 1. Navigation2 整体介绍
|
||||
Navigation2(简称Nav2)是ROS2生态中最成熟的开源导航框架,是ROS1 Navigation Stack的官方继任者,专为移动机器人自主导航设计。
|
||||
|
||||
### 1.1 核心功能
|
||||
- **定位**:支持AMCL、SLAM(Cartographer、SLAM Toolbox等)、GPS/RTK等多源定位
|
||||
- **全局路径规划**:支持A*、Dijkstra、NavFn等多种规划算法
|
||||
- **局部路径跟踪**:支持DWA、TEB、MPPI、Pure Pursuit等跟踪算法
|
||||
- **避障与行为树**:通过行为树实现复杂导航逻辑,支持动态障碍物规避
|
||||
- **重规划与恢复行为**:导航失败时自动执行恢复策略(旋转、回退、清图等)
|
||||
- **多机器人支持**:支持命名空间隔离的多机器人导航
|
||||
|
||||
### 1.2 整体架构
|
||||
Nav2采用模块化插件式设计,核心模块包括:
|
||||
```
|
||||
├── 感知层
|
||||
│ ├── 传感器数据处理(LiDAR、Camera、IMU、GPS等)
|
||||
│ └── 障碍物检测/语义分割
|
||||
├── 定位层
|
||||
│ ├── AMCL(蒙特卡洛定位)
|
||||
│ ├── SLAM 建图
|
||||
│ └── 多传感器融合定位
|
||||
├── 地图层
|
||||
│ ├── 代价地图(全局/局部)
|
||||
│ ├── 图层插件(静态层、障碍层、膨胀层、社会层等)
|
||||
├── 规划层
|
||||
│ ├── 全局路径规划器
|
||||
│ └── 平滑器
|
||||
├── 控制层
|
||||
│ ├── 局部路径规划器
|
||||
│ └── 轨迹跟踪控制器
|
||||
├── 行为决策层
|
||||
│ ├── 行为树执行器
|
||||
│ └── 恢复行为管理器
|
||||
└── 接口层
|
||||
├── RViz 可视化
|
||||
├── Action/Topic API
|
||||
└── 配置参数系统
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. nav2_bringup 包详解
|
||||
nav2_bringup是Nav2的官方启动集成包,提供了开箱即用的启动文件、配置模板和参数集合,是快速部署Nav2系统的入口。
|
||||
|
||||
### 2.1 代码结构
|
||||
```
|
||||
nav2_bringup/
|
||||
├── bringup/ # 启动相关核心目录
|
||||
│ ├── launch/ # 启动文件集合
|
||||
│ │ ├── bringup_launch.py # 主启动文件,集成所有导航模块
|
||||
│ │ ├── localization_launch.py # 单独启动定位模块(AMCL/SLAM)
|
||||
│ │ ├── navigation_launch.py # 单独启动导航模块(规划/控制/行为树)
|
||||
│ │ ├── rviz_launch.py # 启动RViz可视化
|
||||
│ │ ├── slam_launch.py # 启动SLAM建图
|
||||
│ │ └── urdf_launch.py # 加载机器人URDF模型
|
||||
│ ├── params/ # 参数配置文件目录
|
||||
│ │ ├── nav2_params.yaml # 导航全模块默认参数
|
||||
│ │ ├── nav2_params_no_odom.yaml # 无里程计场景参数
|
||||
│ │ ├── nav2_slam_params.yaml # SLAM模式参数
|
||||
│ │ └── robot_localization/ # 传感器融合参数模板
|
||||
│ └── rviz/ # RViz配置文件
|
||||
│ └── nav2_default_view.rviz # Nav2默认RViz配置
|
||||
├── docker/ # Docker部署相关文件
|
||||
├── scripts/ # 辅助脚本
|
||||
├── CMakeLists.txt
|
||||
├── package.xml
|
||||
└── README.md
|
||||
```
|
||||
|
||||
### 2.2 核心启动文件说明
|
||||
|
||||
#### 2.2.1 bringup_launch.py
|
||||
这是最常用的一站式启动文件,集成了完整的导航流程,支持参数配置:
|
||||
```python
|
||||
# 关键参数
|
||||
'namespace': '', # 多机器人命名空间
|
||||
'use_sim_time': False, # 是否使用仿真时间
|
||||
'rviz_config_file': '', # RViz配置文件路径
|
||||
'params_file': '', # 导航参数文件路径
|
||||
'autostart': True, # 启动后自动激活导航栈
|
||||
'use_composition': True, # 使用组件化节点(减少进程数,提高性能)
|
||||
'use_respawn': False, # 节点崩溃时自动重启
|
||||
'map': '', # 静态地图文件路径(.yaml/.pgm)
|
||||
'slam': False, # 是否启用SLAM模式
|
||||
'localization_type': 'amcl' # 定位方式:amcl/slam_toolbox等
|
||||
```
|
||||
启动示例:
|
||||
```bash
|
||||
# 仿真环境启动导航
|
||||
ros2 launch nav2_bringup bringup_launch.py use_sim_time:=True map:=/path/to/map.yaml
|
||||
|
||||
# 真机环境启用SLAM建图
|
||||
ros2 launch nav2_bringup bringup_launch.py slam:=True params_file:=/path/to/my_params.yaml
|
||||
```
|
||||
|
||||
#### 2.2.2 localization_launch.py
|
||||
单独启动定位模块,适合只需要定位不需要完整导航的场景:
|
||||
```bash
|
||||
# 仅启动AMCL定位
|
||||
ros2 launch nav2_bringup localization_launch.py map:=/path/to/map.yaml use_sim_time:=True
|
||||
```
|
||||
|
||||
#### 2.2.3 navigation_launch.py
|
||||
单独启动导航模块(规划/控制/行为树),适合定位已由其他系统提供的场景:
|
||||
```bash
|
||||
# 仅启动导航模块,使用已有的定位信息
|
||||
ros2 launch nav2_bringup navigation_launch.py params_file:=/path/to/my_params.yaml
|
||||
```
|
||||
|
||||
### 2.3 配置文件详解
|
||||
nav2_params.yaml是核心参数配置文件,采用分层结构,每个模块单独配置:
|
||||
```yaml
|
||||
amcl:
|
||||
ros__parameters:
|
||||
base_frame_id: "base_footprint" # 机器人基坐标系
|
||||
global_frame_id: "map" # 全局坐标系
|
||||
odom_frame_id: "odom" # 里程计坐标系
|
||||
max_particles: 2000 # 最大粒子数
|
||||
min_particles: 500 # 最小粒子数
|
||||
update_min_a: 0.2 # 角度变化超过0.2rad时更新
|
||||
update_min_d: 0.25 # 位移超过0.25m时更新
|
||||
|
||||
bt_navigator:
|
||||
ros__parameters:
|
||||
use_sim_time: False
|
||||
bt_xml_filename: "navigate_w_replanning_and_recovery.xml" # 行为树文件
|
||||
|
||||
global_costmap:
|
||||
global_costmap:
|
||||
ros__parameters:
|
||||
update_frequency: 1.0
|
||||
publish_frequency: 1.0
|
||||
global_frame: map
|
||||
robot_base_frame: base_footprint
|
||||
resolution: 0.05
|
||||
plugins:
|
||||
- {name: static_layer, type: "costmap_2d::StaticLayer"}
|
||||
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
|
||||
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
|
||||
|
||||
local_costmap:
|
||||
local_costmap:
|
||||
ros__parameters:
|
||||
update_frequency: 5.0
|
||||
publish_frequency: 2.0
|
||||
global_frame: odom
|
||||
robot_base_frame: base_footprint
|
||||
width: 3
|
||||
height: 3
|
||||
resolution: 0.05
|
||||
rolling_window: true # 局部代价地图随机器人移动
|
||||
|
||||
planner_server:
|
||||
ros__parameters:
|
||||
expected_planner_frequency: 1.0
|
||||
planner_plugins: ["GridBased"]
|
||||
GridBased:
|
||||
plugin: "nav2_navfn_planner/NavfnPlanner" # 默认使用NavFn规划器
|
||||
use_astar: true # 启用A*算法
|
||||
|
||||
controller_server:
|
||||
ros__parameters:
|
||||
controller_frequency: 20.0
|
||||
min_x_velocity_threshold: 0.001
|
||||
min_y_velocity_threshold: 0.5
|
||||
controller_plugins: ["FollowPath"]
|
||||
FollowPath:
|
||||
plugin: "nav2_regulated_pure_pursuit_controller/RegulatedPurePursuitController" # 默认使用Pure Pursuit控制器
|
||||
```
|
||||
|
||||
### 2.4 最佳实践
|
||||
1. **不要直接修改默认参数文件**:将nav2_params.yaml复制到自己的工作空间进行修改,通过`params_file`参数传入
|
||||
2. **组件化启动**:默认启用`use_composition:=True`可以显著减少内存占用和通信开销
|
||||
3. **分层配置**:将通用参数和机器人特定参数分开存放,便于维护
|
||||
4. **仿真与真机分离**:使用`use_sim_time`参数区分仿真和真机环境,分别配置不同的参数值
|
||||
|
||||
---
|
||||
|
||||
## 3. nav2_gps_waypoint_follower_demo 详解
|
||||
这是Nav2官方提供的室外导航示例,演示了如何结合GPS/RTK定位实现全局航点跟随功能,适用于无人车、巡检机器人等室外场景。
|
||||
|
||||
### 3.1 代码结构
|
||||
该包位于navigation2_tutorials仓库中,结构如下:
|
||||
```
|
||||
nav2_gps_waypoint_follower_demo/
|
||||
├── bringup/
|
||||
│ ├── launch/
|
||||
│ │ ├── gps_waypoint_follower_launch.py # Demo主启动文件
|
||||
│ │ ├── rviz.launch.py # RViz启动
|
||||
│ │ └── dual_ekf.launch.py # 双EKF传感器融合启动
|
||||
│ ├── params/
|
||||
│ │ ├── dual_ekf.yaml # 传感器融合参数
|
||||
│ │ ├── nav2_params.yaml # 导航参数(适配GPS场景)
|
||||
│ │ └── waypoint_follower_params.yaml # 航点跟随器参数
|
||||
│ ├── rviz/
|
||||
│ │ └── gps_waypoint.rviz # GPS导航专用RViz配置
|
||||
│ └── worlds/
|
||||
│ └── gps_world.world # 仿真世界文件(含GPS插件)
|
||||
├── config/
|
||||
│ └── sample_waypoints.yaml # 示例航点配置文件
|
||||
├── src/
|
||||
│ └── gps_waypoint_logger.cpp # 航点到达日志节点(可选)
|
||||
├── CMakeLists.txt
|
||||
├── package.xml
|
||||
└── README.md
|
||||
```
|
||||
|
||||
### 3.2 核心组件说明
|
||||
GPS航点跟随系统主要由三个核心部分组成:
|
||||
1. **传感器融合模块**(robot_localization):融合GPS、IMU、轮式里程计数据,输出全局定位
|
||||
2. **导航栈模块**:基于全局定位进行路径规划和跟踪
|
||||
3. **航点跟随器**:按照预设的GPS航点序列依次导航
|
||||
|
||||
#### 3.2.1 双EKF传感器融合
|
||||
demo使用两个扩展卡尔曼滤波器(EKF)实现多传感器融合:
|
||||
```yaml
|
||||
# dual_ekf.yaml 核心配置
|
||||
ekf_filter_node_odom:
|
||||
ros__parameters:
|
||||
frequency: 30.0
|
||||
sensor_timeout: 0.1
|
||||
two_d_mode: true
|
||||
publish_tf: true
|
||||
odom_frame: odom
|
||||
base_link_frame: base_link
|
||||
world_frame: odom
|
||||
# 融合IMU和轮式里程计,输出odom->base_link变换
|
||||
imu0: /imu/data
|
||||
odom0: /wheel/odometry
|
||||
|
||||
ekf_filter_node_map:
|
||||
ros__parameters:
|
||||
frequency: 30.0
|
||||
sensor_timeout: 0.1
|
||||
two_d_mode: true
|
||||
publish_tf: true
|
||||
odom_frame: odom
|
||||
base_link_frame: base_link
|
||||
world_frame: map
|
||||
# 融合GPS数据,输出map->odom变换
|
||||
odom1: /gps/fix
|
||||
odom1_differential: false
|
||||
odom1_relative: false
|
||||
```
|
||||
- 第一个EKF(odom系):融合IMU和轮式里程计,提供短时间内高精度的局部定位,无漂移
|
||||
- 第二个EKF(map系):融合GPS数据,提供全局绝对定位,修正长期漂移
|
||||
|
||||
#### 3.2.2 导航参数适配(nav2_params.yaml)
|
||||
GPS导航场景需要对默认导航参数进行调整:
|
||||
```yaml
|
||||
amcl:
|
||||
ros__parameters:
|
||||
# GPS导航场景下禁用AMCL,使用EKF融合提供定位
|
||||
use_sim_time: False
|
||||
# AMCL相关参数全部注释或删除
|
||||
|
||||
global_costmap:
|
||||
global_costmap:
|
||||
ros__parameters:
|
||||
# GPS模式下不使用静态地图,使用动态生成的代价地图
|
||||
plugins:
|
||||
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer"}
|
||||
- {name: inflation_layer, type: "costmap_2d::InflationLayer"}
|
||||
# 代价地图大小足够覆盖所有航点范围
|
||||
width: 1000
|
||||
height: 1000
|
||||
resolution: 0.1
|
||||
rolling_window: false # 全局代价地图固定,不随机器人移动
|
||||
origin_x: -500
|
||||
origin_y: -500
|
||||
|
||||
planner_server:
|
||||
ros__parameters:
|
||||
# 使用适合长距离规划的算法
|
||||
GridBased:
|
||||
plugin: "nav2_navfn_planner/NavfnPlanner"
|
||||
use_astar: true
|
||||
allow_unknown: true # 允许在未知区域规划路径
|
||||
|
||||
controller_server:
|
||||
ros__parameters:
|
||||
# 使用适合高速行驶的控制器
|
||||
FollowPath:
|
||||
plugin: "nav2_mppi_controller/MPPIController" # 或者TEB控制器
|
||||
max_vel_x: 5.0 # 室外场景允许更高速度
|
||||
```
|
||||
|
||||
#### 3.2.3 航点跟随器配置
|
||||
```yaml
|
||||
# waypoint_follower_params.yaml
|
||||
waypoint_follower:
|
||||
ros__parameters:
|
||||
loop: False # 航点是否循环执行
|
||||
waypoint_timeout: 300.0 # 单个航点导航超时时间(秒)
|
||||
stop_on_failure: True # 某个航点导航失败时停止
|
||||
action_server_name: "follow_waypoints"
|
||||
# 航点到达阈值
|
||||
goal_tolerance_x: 0.5
|
||||
goal_tolerance_y: 0.5
|
||||
goal_tolerance_yaw: 0.25
|
||||
```
|
||||
|
||||
### 3.3 航点配置
|
||||
sample_waypoints.yaml是预设的GPS航点文件,格式如下:
|
||||
```yaml
|
||||
waypoints:
|
||||
- latitude: 37.7749
|
||||
longitude: -122.4194
|
||||
yaw: 0.0 # 到达后的朝向(弧度)
|
||||
frame_id: "wgs84" # GPS坐标系
|
||||
- latitude: 37.7750
|
||||
longitude: -122.4195
|
||||
yaw: 1.57
|
||||
frame_id: "wgs84"
|
||||
- latitude: 37.7751
|
||||
longitude: -122.4196
|
||||
yaw: 3.14
|
||||
frame_id: "wgs84"
|
||||
```
|
||||
航点使用WGS84坐标系(标准GPS坐标),也可以配置为UTM坐标系。
|
||||
|
||||
### 3.4 运行流程
|
||||
1. **启动仿真/真机驱动**:加载机器人模型、传感器驱动、GPS插件
|
||||
2. **启动传感器融合**:`ros2 launch nav2_gps_waypoint_follower_demo dual_ekf.launch.py`
|
||||
3. **启动导航栈**:`ros2 launch nav2_gps_waypoint_follower_demo gps_waypoint_follower_launch.py`
|
||||
4. **加载航点**:`ros2 run nav2_waypoint_follower waypoint_follower --ros-args -p waypoint_file:=/path/to/sample_waypoints.yaml`
|
||||
5. **启动航点跟随**:通过RViz发送FollowWaypoints action请求,或者用命令行启动:
|
||||
```bash
|
||||
ros2 action send_goal /follow_waypoints nav2_msgs/action/FollowWaypoints "{waypoints: []}"
|
||||
```
|
||||
|
||||
### 3.5 关键注意事项
|
||||
1. **GPS信号质量**:室外场景下需要确保GPS信号良好,RTK定位能达到厘米级精度,普通GPS只有米级精度,可能影响导航效果
|
||||
2. **坐标系转换**:需要正确配置WGS84到UTM再到机器人本地坐标系的转换参数
|
||||
3. **航点规划**:航点之间需要有可行路径,避免有障碍物阻挡
|
||||
4. **动态障碍物**:室外场景需要配置合适的障碍物检测和避障参数
|
||||
5. **TF树检查**:确保`map->odom->base_link`的TF变换正确发布,这是GPS导航的基础
|
||||
|
||||
---
|
||||
|
||||
## 4. 常用调试技巧
|
||||
1. **查看TF树**:`ros2 run tf2_tools view_frames`,检查坐标系变换是否正确
|
||||
2. **检查定位质量**:`ros2 topic echo /gps/fix` 查看GPS信号质量,`ros2 topic echo /odometry/filtered` 查看融合后的定位输出
|
||||
3. **可视化调试**:在RViz中显示全局/局部代价地图、规划路径、当前目标点等信息
|
||||
4. **参数动态调整**:使用`ros2 param`命令动态修改参数,无需重启导航栈
|
||||
5. **日志分析**:查看`/tf`, `/cmd_vel`, `/plan`等话题的输出,排查导航失败原因
|
||||
|
||||
---
|
||||
|
||||
## 参考资料
|
||||
- [Navigation2 官方文档](https://navigation.ros.org/)
|
||||
- [nav2_bringup 源码](https://github.com/ros-navigation/navigation2/tree/main/nav2_bringup)
|
||||
- [GPS Waypoint Follower 教程](https://navigation.ros.org/tutorials/docs/gps_waypoint_follower.html)
|
||||
- [navigation2_tutorials 仓库](https://github.com/ros-navigation/navigation2_tutorials)
|
||||
@@ -0,0 +1,59 @@
|
||||
#### 拉取镜像
|
||||
```bash
|
||||
docker pull arm64v8/ros:humble
|
||||
```
|
||||
|
||||
#### 启动脚本
|
||||
```code
|
||||
#!/bin/bash
|
||||
|
||||
# 允许 Docker 访问 X 服务器(用于 GUI)
|
||||
xhost +local:docker
|
||||
|
||||
# 容器名称
|
||||
CONTAINER_NAME="ylhan_ros2_humble"
|
||||
|
||||
# 检查容器是否存在
|
||||
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
# 容器存在
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||
# 容器正在运行,直接进入
|
||||
echo "容器 ${CONTAINER_NAME} 正在运行,进入容器..."
|
||||
docker exec -it ${CONTAINER_NAME} bash
|
||||
else
|
||||
# 容器已存在但未运行,启动并进入
|
||||
echo "容器 ${CONTAINER_NAME} 已存在但未运行,启动容器..."
|
||||
docker start -i ${CONTAINER_NAME}
|
||||
fi
|
||||
else
|
||||
# 容器不存在,创建并运行新容器
|
||||
echo "容器 ${CONTAINER_NAME} 不存在,创建新容器..."
|
||||
docker run -it --rm \
|
||||
--name ${CONTAINER_NAME} \
|
||||
--network host \
|
||||
--privileged \
|
||||
-e DISPLAY=$DISPLAY \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
|
||||
-v /home/ylhan/ros2_ws:/root/ros2_ws \
|
||||
-v /dev:/dev \
|
||||
arm64v8/ros:humble \
|
||||
bash
|
||||
fi
|
||||
|
||||
```
|
||||
|
||||
#### 环境设置
|
||||
宿主机
|
||||
```bash
|
||||
echo $DISPLAY
|
||||
```
|
||||
假设输出为nvidia:13.0,在docker内:
|
||||
```bash
|
||||
export DISPLAY=nvidia:13.0
|
||||
```
|
||||
复制宿主机home目录下.Xauthority文件到docker中home目录下,使用xeyes测试
|
||||
|
||||
ros2 docker隔离
|
||||
```bash
|
||||
export ROS_DOMAIN_ID=79 #设置独立的DOMAIN_ID
|
||||
```
|
||||
@@ -0,0 +1,128 @@
|
||||
# ROS2 代码结构图
|
||||
|
||||
## ROS2 工作区目录结构
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Workspace[ROS2 工作区] --> src[src/ 源代码目录]
|
||||
Workspace --> build[build/ 构建目录]
|
||||
Workspace --> install[install/ 安装目录]
|
||||
Workspace --> log[log/ 日志目录]
|
||||
|
||||
src --> Package1[包1]
|
||||
src --> Package2[包2]
|
||||
src --> PackageN[...]
|
||||
|
||||
Package1 --> P1_CMake[CMakeLists.txt]
|
||||
Package1 --> P1_PackageXML[package.xml]
|
||||
Package1 --> P1_src[src/ 源代码]
|
||||
Package1 --> P1_include[include/ 头文件]
|
||||
Package1 --> P1_msgs[msg/ 消息定义]
|
||||
Package1 --> P1_srvs[srv/ 服务定义]
|
||||
Package1 --> P1_actions[action/ 动作定义]
|
||||
```
|
||||
|
||||
## ROS2 软件架构
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
App[应用程序] --> ClientLibs[客户端库]
|
||||
|
||||
subgraph ClientLibs [客户端库]
|
||||
direction LR
|
||||
RCLcpp[C++ 客户端库 rclcpp]
|
||||
RCLpy[Python 客户端库 rclpy]
|
||||
RCL[C 客户端库 rcl]
|
||||
end
|
||||
|
||||
ClientLibs --> RCL_Interface[RCL 接口]
|
||||
RCL_Interface --> RMW[ROS 中间件接口 RMW]
|
||||
|
||||
subgraph DDS_Implementations [DDS 实现]
|
||||
direction LR
|
||||
FastDDS[Fast DDS]
|
||||
CycloneDDS[Cyclone DDS]
|
||||
RTI_Connext[RTI Connext]
|
||||
OpenSplice[OpenSplice]
|
||||
end
|
||||
|
||||
RMW --> DDS_Implementations
|
||||
DDS_Implementations --> Network[网络通信]
|
||||
```
|
||||
|
||||
## ROS2 核心包依赖关系
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
ROS2_Core[ROS2 核心] --> ament_core[ament_core<br/>构建系统]
|
||||
ROS2_Core --> rcl[rcl<br/>C语言客户端库]
|
||||
ROS2_Core --> rclcpp[rclcpp<br/>C++客户端库]
|
||||
ROS2_Core --> rclpy[rclpy<br/>Python客户端库]
|
||||
|
||||
rcl --> rmw[rmw<br/>中间件接口]
|
||||
rclcpp --> rcl
|
||||
rclpy --> rcl
|
||||
|
||||
rmw --> rmw_implementation[rmw_implementation<br/>中间件实现]
|
||||
rmw_implementation --> DDS[DDS 实现]
|
||||
|
||||
ROS2_Tools[ROS2 工具] --> ros2cli[ros2cli<br/>命令行工具]
|
||||
ROS2_Tools --> colcon[colcon<br/>构建工具]
|
||||
ROS2_Tools --> launch_ros[launch_ros<br/>启动系统]
|
||||
```
|
||||
|
||||
## ROS2 节点通信模型
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
NodeA[ROS2 节点 A] -->|发布话题| Topic1[话题 /topic1]
|
||||
NodeB[ROS2 节点 B] -->|订阅话题| Topic1
|
||||
|
||||
NodeC[ROS2 节点 C] -->|请求服务| Service1[服务 /service1]
|
||||
NodeD[ROS2 节点 D] -->|提供服务| Service1
|
||||
|
||||
NodeE[ROS2 节点 E] -->|发送目标| Action1[动作 /action1]
|
||||
NodeF[ROS2 节点 F] -->|执行动作| Action1
|
||||
NodeF -->|反馈| NodeE
|
||||
NodeF -->|结果| NodeE
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
### 1. 工作区目录结构
|
||||
- **src/**: 包含所有ROS2包的源代码
|
||||
- **build/**: 构建过程中生成的中间文件
|
||||
- **install/**: 安装目录,包含可执行文件、库和资源
|
||||
- **log/**: 构建和运行时的日志文件
|
||||
|
||||
### 2. ROS2包的基本结构
|
||||
每个ROS2包通常包含:
|
||||
- `CMakeLists.txt`: CMake构建配置文件
|
||||
- `package.xml`: 包元数据文件
|
||||
- `src/`: C++或Python源代码
|
||||
- `include/`: C++头文件
|
||||
- `msg/`, `srv/`, `action/`: 消息、服务、动作定义文件
|
||||
|
||||
### 3. 软件架构层次
|
||||
1. **应用程序层**: 用户编写的ROS2节点
|
||||
2. **客户端库层**: 语言特定的API(C++、Python、C)
|
||||
3. **RCL层**: 通用的ROS客户端库
|
||||
4. **RMW层**: ROS中间件抽象接口
|
||||
5. **DDS层**: 具体的DDS实现
|
||||
|
||||
### 4. 通信模式
|
||||
- **话题(Topics)**: 发布/订阅模式,单向异步通信
|
||||
- **服务(Services)**: 请求/响应模式,同步通信
|
||||
- **动作(Actions)**: 目标/反馈/结果模式,长时间运行的任务
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 将本文件在支持 Mermaid 图的 Markdown 查看器中打开(如 VS Code with Mermaid 插件、GitHub、GitLab 等)
|
||||
2. 图表将自动渲染为可视化图形
|
||||
3. 如需修改图表,编辑对应的 Mermaid 代码块
|
||||
|
||||
## 相关资源
|
||||
|
||||
- [ROS2 官方文档](https://docs.ros.org/)
|
||||
- [ROS2 架构设计](https://design.ros2.org/)
|
||||
- [Mermaid 语法指南](https://mermaid.js.org/syntax/flowchart.html)
|
||||
@@ -0,0 +1,77 @@
|
||||
# 维护 ROS 2 源代码检出
|
||||
|
||||
## [概述](https://docs.ros.org/en/humble/Installation/Maintaining-a-Source-Checkout.html)
|
||||
|
||||
本文档介绍如何维护从源代码构建的 ROS 2 安装。如果您已经从源代码安装了 ROS 2,并且想要更新到最新的错误修复和功能,请遵循本指南。
|
||||
|
||||
## [更新 ROS 2 源代码](https://docs.ros.org/en/humble/Installation/Maintaining-a-Source-Checkout.html#updating-ros-2-source-code)
|
||||
|
||||
### 1. 更新仓库列表文件
|
||||
|
||||
首先,您需要获取最新的 `ros2.repos` 文件,该文件定义了构建 ROS 2 所需的所有仓库及其分支。
|
||||
|
||||
```bash
|
||||
# 对于 Humble Hawksbill 版本
|
||||
cd ~/ros2_humble
|
||||
wget https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos -O ros2.repos
|
||||
```
|
||||
|
||||
或者,如果您想使用特定分支(例如主分支)而不是发布分支:
|
||||
|
||||
```bash
|
||||
# 使用主分支(开发版本)
|
||||
wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos -O ros2.repos
|
||||
```
|
||||
|
||||
### 2. 更新本地仓库
|
||||
|
||||
使用 `vcs` 工具更新您的本地仓库:
|
||||
|
||||
```bash
|
||||
# 更新所有仓库的远程引用
|
||||
vcs custom --args remote update
|
||||
```
|
||||
|
||||
### 3. 下载新的源代码
|
||||
|
||||
现在,使用新的 `ros2.repos` 文件导入并拉取最新的代码:
|
||||
|
||||
```bash
|
||||
# 导入新仓库定义
|
||||
vcs import src < ros2.repos
|
||||
|
||||
# 拉取所有仓库的最新代码
|
||||
vcs pull src
|
||||
```
|
||||
|
||||
**注意**:`vcs import` 命令将覆盖 `src` 目录中现有的仓库定义。如果您有本地修改或添加了额外的仓库,请确保在运行此命令之前备份您的更改。
|
||||
|
||||
### 4. 重新构建工作空间
|
||||
|
||||
更新源代码后,需要重新构建工作空间:
|
||||
|
||||
```bash
|
||||
# 返回到工作空间根目录
|
||||
cd ~/ros2_humble
|
||||
|
||||
# 使用 colcon 重新构建
|
||||
colcon build --symlink-install
|
||||
```
|
||||
|
||||
构建选项说明:
|
||||
- `--symlink-install`:使用符号链接而不是复制文件,这可以加快构建速度并减少磁盘空间使用
|
||||
|
||||
### 5. 检查源代码状态
|
||||
|
||||
要查看当前工作空间中所有仓库的状态,可以导出当前的仓库配置:
|
||||
|
||||
```bash
|
||||
# 导出当前仓库状态
|
||||
vcs export src > my_ros2.repos
|
||||
```
|
||||
|
||||
这将在当前目录下创建一个 `my_ros2.repos` 文件,其中包含所有仓库的当前提交哈希值。您可以将此文件用于:
|
||||
- 备份当前的源代码状态
|
||||
- 在其他机器上复制相同的配置
|
||||
- 调试构建问题
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
## [System requirements](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id1)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-requirements "Link to this heading")
|
||||
|
||||
The current Debian-based target platforms for Humble Hawksbill are:
|
||||
|
||||
- Tier 1: Ubuntu Linux - Jammy (22.04) 64-bit
|
||||
|
||||
- Tier 3: Ubuntu Linux - Focal (20.04) 64-bit
|
||||
|
||||
- Tier 3: Debian Linux - Bullseye (11) 64-bit
|
||||
|
||||
|
||||
Other Linux platforms with varying support levels include:
|
||||
|
||||
- Arch Linux, see [alternate instructions](https://wiki.archlinux.org/index.php/ROS#ROS_2)
|
||||
|
||||
- Fedora Linux, see [alternate instructions](https://ros2docs.robook.org/humble/Installation/Alternatives/Fedora-Development-Setup.html)
|
||||
|
||||
- OpenEmbedded / webOS OSE, see [alternate instructions](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)
|
||||
|
||||
|
||||
As defined in [REP 2000](https://www.ros.org/reps/rep-2000.html).
|
||||
|
||||
## [System setup](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id2)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-setup "Link to this heading")
|
||||
|
||||
### [Set locale](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id3)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#set-locale "Link to this heading")
|
||||
|
||||
请确保您有一个支持 `UTF-8` 的区域设置。 如果您处于最简环境中(例如 docker 容器),区域设置可能是一些类似 `POSIX` 的选项。 我们使用以下设置通过了测试。但是,如果您使用不同的支持 `UTF-8` 的区域设置,也应该没问题。
|
||||
|
||||
`locale # check for UTF-8`
|
||||
`sudo apt update && sudo apt install locales`
|
||||
`sudo locale-gen en_US en_US.UTF-8`
|
||||
`sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8`
|
||||
`export LANG=en_US.UTF-8`
|
||||
`locale # verify settings`
|
||||
|
||||
### [Add the ROS 2 apt repository](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id4)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#add-the-ros-2-apt-repository "Link to this heading")
|
||||
|
||||
你需要将 ROS 2 apt 仓库添加到你的系统中。
|
||||
|
||||
首先确保 [Ubuntu Universe 仓库](https://help.ubuntu.com/community/Repositories/Ubuntu) 已启用。
|
||||
|
||||
`sudo apt install software-properties-common`
|
||||
`sudo add-apt-repository universe`
|
||||
|
||||
然后使用 apt 添加 ROS 2 GPG 密钥。
|
||||
|
||||
`sudo apt update && sudo apt install curl -y`
|
||||
`sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg`
|
||||
|
||||
然后将仓库添加到你的源列表中。
|
||||
|
||||
`echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null`
|
||||
|
||||
### [Install development tools and ROS tools](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id5)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools "Link to this heading")
|
||||
|
||||
Install common packages.
|
||||
|
||||
`sudo apt update && sudo apt install -y \`
|
||||
`python3-flake8-docstrings \`
|
||||
`python3-pip \`
|
||||
`python3-pytest-cov \`
|
||||
`ros-dev-tools`
|
||||
|
||||
Install packages according to your Ubuntu version.
|
||||
|
||||
Ubuntu 22.04 LTS and laterUbuntu 20.04 LTS
|
||||
|
||||
`sudo apt install -y \`
|
||||
`python3-flake8-blind-except \`
|
||||
`python3-flake8-builtins \`
|
||||
`python3-flake8-class-newline \`
|
||||
`python3-flake8-comprehensions \`
|
||||
`python3-flake8-deprecated \`
|
||||
`python3-flake8-import-order \`
|
||||
`python3-flake8-quotes \`
|
||||
`python3-pytest-repeat \`
|
||||
`python3-pytest-rerunfailures`
|
||||
|
||||
## [Get ROS 2 code](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id6)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#get-ros-2-code "Link to this heading")
|
||||
|
||||
Create a workspace and clone all repos:
|
||||
|
||||
`mkdir -p ~/ros2_humble/src`
|
||||
`cd ~/ros2_humble`
|
||||
`vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src`
|
||||
|
||||
## [Install dependencies using rosdep](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id7)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-dependencies-using-rosdep "Link to this heading")
|
||||
|
||||
ROS 2 包是在经常更新的 Ubuntu 系统上构建的。 在安装新包之前,建议您确保系统是最新的。
|
||||
|
||||
%% `sudo apt upgrade` %%
|
||||
|
||||
`sudo rosdep init`
|
||||
`rosdep update`
|
||||
`rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"`
|
||||
|
||||
**Note**: If you’re using a distribution that is based on Ubuntu (like Linux Mint) but does not identify itself as such, you’ll get an error message like `Unsupported OS [mint]`. In this case append `--os=ubuntu:jammy` to the above command.
|
||||
|
||||
## [Install additional DDS implementations (optional)](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id8)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-additional-dds-implementations-optional "Link to this heading")
|
||||
|
||||
If you would like to use another DDS or RTPS vendor besides the default, you can find instructions [here](https://ros2docs.robook.org/humble/Installation/DDS-Implementations.html).
|
||||
|
||||
## [Build the code in the workspace](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id9)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#build-the-code-in-the-workspace "Link to this heading")
|
||||
|
||||
If you have already installed ROS 2 another way (either via debs or the binary distribution), make sure that you run the below commands in a fresh environment that does not have those other installations sourced. Also ensure that you do not have `source /opt/ros/${ROS_DISTRO}/setup.bash` in your `.bashrc`. You can make sure that ROS 2 is not sourced with the command `printenv | grep -i ROS`. The output should be empty.
|
||||
|
||||
More info on working with a ROS workspace can be found in [this tutorial](https://ros2docs.robook.org/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html).
|
||||
|
||||
`cd ~/ros2_humble/`
|
||||
`colcon build --symlink-install`
|
||||
|
||||
Note: if you are having trouble compiling all examples and this is preventing you from completing a successful build, you can use `COLCON_IGNORE` in the same manner as [CATKIN_IGNORE](https://github.com/ros-infrastructure/rep/blob/master/rep-0128.rst) to ignore the subtree or remove the folder from the workspace. Take for instance: you would like to avoid installing the large OpenCV library. Well then simply run `touch COLCON_IGNORE` in the `cam2image` demo directory to leave it out of the build process.
|
||||
|
||||
## [Environment setup](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id10)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#environment-setup "Link to this heading")
|
||||
|
||||
### [Source the setup script](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id11)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#source-the-setup-script "Link to this heading")
|
||||
|
||||
Set up your environment by sourcing the following file.
|
||||
|
||||
# Replace ".bash" with your shell if you're not using bash
|
||||
# Possible values are: setup.bash, setup.sh, setup.zsh
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
|
||||
## [Try some examples](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id12)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#try-some-examples "Link to this heading")
|
||||
|
||||
In one terminal, source the setup file and then run a C++ `talker`:
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
`ros2 run demo_nodes_cpp talker`
|
||||
|
||||
In another terminal source the setup file and then run a Python `listener`:
|
||||
|
||||
`. ~/ros2_humble/install/local_setup.bash`
|
||||
`ros2 run demo_nodes_py listener`
|
||||
|
||||
You should see the `talker` saying that it’s `Publishing` messages and the `listener` saying `I heard` those messages. This verifies both the C++ and Python APIs are working properly. Hooray!
|
||||
@@ -0,0 +1,161 @@
|
||||
## [系统要求](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id1)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-requirements "Link to this heading")
|
||||
|
||||
当前 Humble Hawksbill 基于 Debian 的目标平台包括:
|
||||
|
||||
- 第一级:Ubuntu Linux - Jammy (22.04) 64位
|
||||
|
||||
- 第三级:Ubuntu Linux - Focal (20.04) 64位
|
||||
|
||||
- 第三级:Debian Linux - Bullseye (11) 64位
|
||||
|
||||
|
||||
其他支持程度不同的 Linux 平台包括:
|
||||
|
||||
- Arch Linux,请参阅[替代安装说明](https://wiki.archlinux.org/index.php/ROS#ROS_2)
|
||||
|
||||
- Fedora Linux,请参阅[替代安装说明](https://ros2docs.robook.org/humble/Installation/Alternatives/Fedora-Development-Setup.html)
|
||||
|
||||
- OpenEmbedded / webOS OSE,请参阅[替代安装说明](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)
|
||||
|
||||
|
||||
如 [REP 2000](https://www.ros.org/reps/rep-2000.html) 中所定义。
|
||||
|
||||
## [系统设置](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id2)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#system-setup "Link to this heading")
|
||||
|
||||
### [设置区域](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id3)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#set-locale "Link to this heading")
|
||||
|
||||
请确保您有一个支持 `UTF-8` 的区域设置。如果您处于最简环境中(例如 docker 容器),区域设置可能是一些类似 `POSIX` 的选项。我们使用以下设置通过了测试。但是,如果您使用不同的支持 `UTF-8` 的区域设置,也应该没问题。
|
||||
|
||||
```bash
|
||||
locale # 检查 UTF-8 支持
|
||||
sudo apt update && sudo apt install locales
|
||||
sudo locale-gen en_US en_US.UTF-8
|
||||
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
locale # 验证设置
|
||||
```
|
||||
|
||||
### [添加 ROS 2 apt 仓库](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id4)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#add-the-ros-2-apt-repository "Link to this heading")
|
||||
|
||||
你需要将 ROS 2 apt 仓库添加到你的系统中。
|
||||
|
||||
首先确保 [Ubuntu Universe 仓库](https://help.ubuntu.com/community/Repositories/Ubuntu) 已启用。
|
||||
|
||||
```bash
|
||||
sudo apt install software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
```
|
||||
|
||||
然后使用 apt 添加 ROS 2 GPG 密钥。
|
||||
|
||||
```bash
|
||||
sudo apt update && sudo apt install curl -y
|
||||
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
|
||||
```
|
||||
|
||||
然后将仓库添加到你的源列表中。
|
||||
|
||||
```bash
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
||||
```
|
||||
|
||||
### [安装开发工具和 ROS 工具](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id5)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools "Link to this heading")
|
||||
|
||||
安装常用软件包。
|
||||
|
||||
```bash
|
||||
sudo apt update && sudo apt install -y \
|
||||
python3-flake8-docstrings \
|
||||
python3-pip \
|
||||
python3-pytest-cov \
|
||||
ros-dev-tools
|
||||
```
|
||||
|
||||
根据您的 Ubuntu 版本安装软件包。
|
||||
|
||||
Ubuntu 22.04 LTS 及更高版本 Ubuntu 20.04 LTS
|
||||
|
||||
```bash
|
||||
sudo apt install -y \
|
||||
python3-flake8-blind-except \
|
||||
python3-flake8-builtins \
|
||||
python3-flake8-class-newline \
|
||||
python3-flake8-comprehensions \
|
||||
python3-flake8-deprecated \
|
||||
python3-flake8-import-order \
|
||||
python3-flake8-quotes \
|
||||
python3-pytest-repeat \
|
||||
python3-pytest-rerunfailures
|
||||
```
|
||||
|
||||
## [获取 ROS 2 代码](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id6)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#get-ros-2-code "Link to this heading")
|
||||
|
||||
创建工作区并克隆所有仓库:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/ros2_humble/src
|
||||
cd ~/ros2_humble
|
||||
vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src
|
||||
```
|
||||
|
||||
## [使用 rosdep 安装依赖](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id7)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-dependencies-using-rosdep "Link to this heading")
|
||||
|
||||
ROS 2 包是在经常更新的 Ubuntu 系统上构建的。在安装新包之前,建议您确保系统是最新的。
|
||||
|
||||
%% `sudo apt upgrade` %%
|
||||
|
||||
```bash
|
||||
sudo rosdep init
|
||||
rosdep update
|
||||
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
|
||||
```
|
||||
|
||||
**注意**:如果您使用的是基于 Ubuntu 的发行版(如 Linux Mint)但系统未标识为 Ubuntu,您可能会收到类似 `Unsupported OS [mint]` 的错误消息。在这种情况下,请在上述命令后追加 `--os=ubuntu:jammy`。
|
||||
|
||||
## [安装额外的 DDS 实现(可选)](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id8)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-additional-dds-implementations-optional "Link to this heading")
|
||||
|
||||
如果您想使用默认之外的 DDS 或 RTPS 供应商,可以在此处找到说明[这里](https://ros2docs.robook.org/humble/Installation/DDS-Implementations.html)。
|
||||
|
||||
## [在工作区中构建代码](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id9)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#build-the-code-in-the-workspace "Link to this heading")
|
||||
|
||||
如果您已经通过其他方式(deb 包或二进制发行版)安装了 ROS 2,请确保在未激活其他安装的新环境中运行以下命令。同时确保您的 `.bashrc` 中没有 `source /opt/ros/${ROS_DISTRO}/setup.bash`。您可以使用命令 `printenv | grep -i ROS` 来确保 ROS 2 未被激活。输出应为空。
|
||||
|
||||
有关使用 ROS 工作区的更多信息,请参阅[本教程](https://ros2docs.robook.org/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html)。
|
||||
|
||||
```bash
|
||||
cd ~/ros2_humble/
|
||||
colcon build --symlink-install
|
||||
```
|
||||
|
||||
**注意**:如果编译所有示例时遇到问题,导致无法成功构建,您可以像使用 [CATKIN_IGNORE](https://github.com/ros-infrastructure/rep/blob/master/rep-0128.rst) 一样使用 `COLCON_IGNORE` 来忽略子树或从工作区中移除文件夹。例如:如果您想避免安装庞大的 OpenCV 库,只需在 `cam2image` 演示目录中运行 `touch COLCON_IGNORE` 即可将其排除在构建过程之外。
|
||||
|
||||
## [环境设置](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id10)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#environment-setup "Link to this heading")
|
||||
|
||||
### [源化安装脚本](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id11)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#source-the-setup-script "Link to this heading")
|
||||
|
||||
通过源化以下文件来设置您的环境。
|
||||
|
||||
# 如果不使用 bash,请将 ".bash" 替换为您的 shell
|
||||
# 可能的取值为:setup.bash, setup.sh, setup.zsh
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
```
|
||||
|
||||
## [尝试一些示例](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#id12)[](https://ros2docs.robook.org/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#try-some-examples "Link to this heading")
|
||||
|
||||
在一个终端中,源化安装脚本然后运行 C++ `talker`:
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
ros2 run demo_nodes_cpp talker
|
||||
```
|
||||
|
||||
在另一个终端中源化安装脚本然后运行 Python `listener`:
|
||||
|
||||
```bash
|
||||
. ~/ros2_humble/install/local_setup.bash
|
||||
ros2 run demo_nodes_py listener
|
||||
```
|
||||
|
||||
您应该能看到 `talker` 显示它正在 `Publishing` 消息,而 `listener` 显示 `I heard` 这些消息。这表明 C++ 和 Python API 都能正常工作。太好了!
|
||||
@@ -0,0 +1,8 @@
|
||||
``` bash
|
||||
source install/local_setup.bash
|
||||
# export ROS_DOMAIN_ID=<your_domain_id>
|
||||
# echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc
|
||||
# export ROS_LOCALHOST_ONLY=1
|
||||
# echo "export ROS_LOCALHOST_ONLY=1" >> ~/.bashrc
|
||||
```
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
# ROS 2 基础概念
|
||||
|
||||
ROS 2 (Robot Operating System 2) 是一个用于构建机器人应用程序的开源框架。它提供了一套工具、库和约定,帮助开发者创建可维护、可扩展且可重用的机器人软件。
|
||||
|
||||
## 1. Node (节点)
|
||||
|
||||
**节点** 是 ROS 2 中最小的可执行单元,代表一个单一功能模块。每个节点执行特定任务(如控制传感器、处理图像、规划路径等),并通过标准接口与其他节点通信。
|
||||
|
||||
- **特点**:
|
||||
- 轻量级,单一职责
|
||||
- 使用命名空间避免命名冲突
|
||||
- 支持多种客户端库(C++、Python、Java等)
|
||||
|
||||
- **核心概念**:
|
||||
- 节点名称:唯一标识符,如 `/camera_driver`
|
||||
- 命名空间:用于组织节点,如 `/robot1/camera_driver`
|
||||
|
||||
## 2. Discovery (发现机制)
|
||||
|
||||
**发现机制** 是 ROS 2 中节点自动发现其他节点和服务的过程。它允许节点在网络中找到彼此并建立通信,无需硬编码地址。
|
||||
|
||||
- **工作原理**:
|
||||
- 使用 DDS (Data Distribution Service) 作为底层通信中间件
|
||||
- 通过参与者(Participant)、主题(Topic)和服务(Service)的发现实现
|
||||
- 自动管理连接的建立和断开
|
||||
|
||||
- **关键组件**:
|
||||
- ROS 2 守护进程 `ros2 daemon`(后台运行,管理发现)
|
||||
- DDS 域(Domain ID):控制节点可见性(同一域的节点才能通信)
|
||||
|
||||
## 3. Interfaces (接口)
|
||||
|
||||
**接口** 定义了节点之间通信的消息格式。ROS 2 提供了三种主要通信接口类型:
|
||||
|
||||
### 3.1 Topics (话题) - 发布/订阅通信
|
||||
|
||||
**话题** 是节点之间传递数据的命名通道。一个节点可以**发布**(发送)数据到某个话题,其他节点可以**订阅**(接收)该话题的数据。
|
||||
|
||||
- **特点**:
|
||||
- 单向、异步通信
|
||||
- 一对多或多对多通信模式
|
||||
- 消息类型严格定义(如 `std_msgs/String`、`sensor_msgs/Image`)
|
||||
|
||||
- **使用场景**:
|
||||
- 持续数据流(如传感器数据、状态信息)
|
||||
|
||||
### 3.2 Services (服务) - 请求/响应通信
|
||||
|
||||
**服务** 实现节点之间的双向同步通信。一个节点提供**服务**,其他节点发送**请求**并等待**响应**。
|
||||
|
||||
- **特点**:
|
||||
- 请求/响应模式
|
||||
- 同步通信(客户端等待服务端处理)
|
||||
- 需要定义请求和响应的消息类型(.srv 文件)
|
||||
|
||||
- **使用场景**:
|
||||
- 一次性任务(如获取配置、执行动作)
|
||||
|
||||
### 3.3 Actions (动作) - 目标导向通信
|
||||
|
||||
**动作** 是服务的扩展,支持长时间运行的任务,并提供反馈和取消功能。
|
||||
|
||||
- **特点**:
|
||||
- 目标-反馈-结果模式
|
||||
- 可取消、可获取进度反馈
|
||||
- 异步执行
|
||||
- 消息类型定义在 .action 文件中
|
||||
|
||||
- **使用场景**:
|
||||
- 长时间运行的任务(如导航、抓取物体)
|
||||
|
||||
## 4. Parameters (参数)
|
||||
|
||||
**参数** 是节点的配置值,可以在运行时动态修改。参数支持多种数据类型(整数、浮点数、字符串、布尔值等)。
|
||||
|
||||
- **管理方式**:
|
||||
- 命令行设置
|
||||
- 配置文件(YAML)
|
||||
- 运行时动态修改(通过 `ros2 param` 命令或 API)
|
||||
|
||||
- **常用操作**:
|
||||
- `ros2 param list`:列出节点参数
|
||||
- `ros2 param set`:设置参数值
|
||||
- `ros2 param get`:获取参数值
|
||||
|
||||
## 5. Introspection (内省)
|
||||
|
||||
**内省** 允许开发者在运行时检查和监控 ROS 2 系统的状态。通过内省工具,您可以查看节点、话题、服务和参数的信息。
|
||||
|
||||
- **常用工具**:
|
||||
- `ros2 node list`:列出所有节点
|
||||
- `ros2 topic list`:列出所有话题
|
||||
- `ros2 service list`:列出所有服务
|
||||
- `ros2 topic echo`:查看话题消息内容
|
||||
- `ros2 node info`:查看节点详细信息
|
||||
|
||||
## 6. Launch (启动系统)
|
||||
|
||||
**Launch** 允许您同时启动多个节点和配置它们的参数。使用 Python 或 XML 编写的启动文件可以简化系统启动过程。
|
||||
|
||||
- **特点**:
|
||||
- 同时启动多个节点
|
||||
- 配置节点参数
|
||||
- 设置命名空间和重映射
|
||||
- 支持条件启动和依赖关系
|
||||
|
||||
- **常用工具**:
|
||||
- `ros2 launch`:执行启动文件
|
||||
- 启动文件格式:Python(推荐)、XML、YAML
|
||||
|
||||
## 7. Client Libraries (客户端库)
|
||||
|
||||
**客户端库** 是 ROS 2 提供的编程接口,允许开发者使用不同语言编写节点。
|
||||
|
||||
- **主要客户端库**:
|
||||
- **rclcpp**:C++ 客户端库(推荐用于高性能应用)
|
||||
- **rclpy**:Python 客户端库(推荐用于快速原型开发)
|
||||
- **rcljava**:Java 客户端库
|
||||
- **其他**:Swift、Go 等语言的社区支持
|
||||
|
||||
- **核心特性**:
|
||||
- 统一的 API 接口
|
||||
- 自动内存管理
|
||||
- 支持所有 ROS 2 通信模式
|
||||
|
||||
## 8. 通信中间件
|
||||
|
||||
ROS 2 使用 **DDS (Data Distribution Service)** 作为默认通信中间件,提供可靠的实时数据交换。DDS 是工业标准的中间件,适用于嵌入式系统和高性能计算。
|
||||
|
||||
- **DDS 特性**:
|
||||
- 高可靠性
|
||||
- 低延迟
|
||||
- 实时支持
|
||||
- 可扩展性
|
||||
- 服务质量(QoS)配置
|
||||
|
||||
## 9. 服务质量(QoS)
|
||||
|
||||
**QoS (Quality of Service)** 配置允许您控制通信的可靠性、持久性和其他特性。QoS 设置对于确保系统在不同环境下的性能至关重要。
|
||||
|
||||
- **主要 QoS 策略**:
|
||||
- Reliability:可靠传输(保证交付)或最佳 effort(不保证交付)
|
||||
- Durability:数据是否持久化(对晚加入的节点可见)
|
||||
- History:保留消息历史的深度
|
||||
- Deadline/Lifespan:消息的截止时间和寿命
|
||||
|
||||
## 10. 系统架构概览
|
||||
|
||||
ROS 2 系统由以下层次组成:
|
||||
|
||||
1. **应用层**:节点、话题、服务、动作
|
||||
2. **中间件层**:DDS 通信系统
|
||||
3. **工具层**:命令行工具、可视化工具、调试工具
|
||||
4. **硬件抽象层**:传感器、执行器、硬件接口
|
||||
|
||||
## 11. 与 ROS 1 的主要区别
|
||||
|
||||
- **通信中间件**:ROS 1 使用 TCPROS/UDPROS,ROS 2 使用 DDS
|
||||
- **节点发现**:ROS 1 依赖 roscore,ROS 2 去中心化
|
||||
- **接口类型**:ROS 2 添加了 Actions
|
||||
- **参数系统**:ROS 2 支持动态参数配置
|
||||
- **编译系统**:ROS 1 使用 catkin,ROS 2 使用 colcon
|
||||
- **支持的语言**:ROS 2 对 Python 3 的支持更好,添加了更多语言选项
|
||||
|
||||
这些基础概念是理解和使用 ROS 2 的核心。通过掌握这些概念,您可以开始构建复杂的机器人系统,并利用 ROS 2 的强大功能。
|
||||
@@ -0,0 +1 @@
|
||||
[差速驱动移动基座和机械臂的规划 — MoveIt documentation documentation](https://www.ncnynl.com/ros2docs/cn/moveit2/doc/examples/mobile_base_arm/mobile_base_arm_tutorial.html)
|
||||
Reference in New Issue
Block a user