文章目录
- 终端中的topic操作
- [重命名(remap) topic](#重命名(remap) topic)
- 用RQT检测topic
终端中的topic操作
bash
# 可以查看主题的信息
ros2 topic info /robot_news
# ros2终端也是一个订阅者
ros2 topic echo /robot_news
# 查看接口
ros2 interface show <Type>
ros2 interface show example_interfaces/msg/String
# 会显示一些关键词 datatype
# 消息终端的频率
ros2 topic hz /robot_news
# 消息的带宽
ros2 topic bw /robot_news
# 发布主题 -r 是rate -r 5 表示
ros2 topic pub -r 5 /robot_news example_interfaces/msg/String "{data: 'hello from the terminal'}"
重命名(remap) topic
bash
# 更改节点名称
ros2 run my_py_pkg robot_news_station --ros-args -r __node:=my_station
# 更改主题名称
ros2 run <pkg_name> <node_name> --ros-args -r <topic_name>:=<new_topic_name>
# 例子,同时更改主题和节点
ros2 run my_py_pkg robot_news_station --ros-args -r __node:=my_station -r robot_news:=abc
用RQT检测topic
bash
# 打开rqt图形界面
rqt-graph