节点
- 查看所有node:ros2 node list
- 查看某个node的信息:ros2 node info node_name
topic
- 查看topic输出:
ros2 topic echo <topic_name>
- 查看topic频率:
ros2 topic hz <topic_name>
- 查看有哪些topic:
ros2 topic list
- 查看每个topic及其message type:
ros2 topic list -t
- 查看每个topic及其message type:
- 查看topic有哪些pub和sub:
ros2 topic info -v <topic_name>
- 在某个topic上使用命令行pub数据:
- 按默认周期发送:
ros2 topic pub <topic_name> <msg_type> '<args>'
注意,args要使用yaml格式 - 只发送一次:
ros2 topic pub --once <topic_name> <msg_type> '<args>'
- 按指定周期发送:
ros2 topic pub --rate 1 <topic_name> <msg_type> '<args>'
- 按默认周期发送:
参数
launch
录包
录包
命令:ros2 bag record
,通过这个命令录制的包是一个包含了选定topic消息的db3文件(文件形式为.db3)。ros2中的bag文件使用了SQLite数据库来存储消息。
-a
或--all
:录制所有topic- -o:指定录包的文件名,如:
ros2 topic record -a -o my_bag.db3
- 录制指定topic的包:
ros2 bag record /topic1 /topic2
查看
- 查看录包信息:
ros2 bag info <bag_file>
- 查看录制的实际内容:
- 播放录制的数据:
ros2 bag play <bag_file>
,循环播放:ros2 bag play <bag_file> -l
- 继续打开一个新的终端窗口,然后使用ros2 topic命令查看,如
ros2 topic list, ros2 topic echo <topic_name>
等
- 播放录制的数据: