内容来自ros2官方wiki的Tutorials部分:Tutorials — ROS 2 Documentation: Humble documentationhttps://docs.ros.org/en/humble/Tutorials.html
仅仅用于自查和学习,有误尽情指正!!
目录
CLI Tools
ros2 run
ros2 run <package_name> <executable_name>
ros2 interface show
传入一个消息类型,返回 具体的信息,跟一些 -t 指令连在一起用很好用,因为 -t 指令会在输出后面连带着 type。
ros2 interface show <msg type>
ro2 launch
Running a single launch file with the ros2 launch
command will start up your entire system - all nodes and their configurations - at once.
node
ros2 node list
展示所有正在运行的节点的名称。
ros2 node info
返回与该节点交互的订阅者、发布者、service和action的列表。
ros2 node info <node_name>
topic
ros2 topic list
展示所有正在运行的话题的名称。
ros2 topic list -t #同时还会返回话题的类型
ros2 topic echo
查看在话题上发布的数据,终端输入后,会增加一个subscriber,接受来自话题的数据,显示 在终端上。
ros2 topic echo <topic_name>
ros2 topic pub
和上面的 echo 是相对的一个,给一个话题发数据,此话题的subscriber就会接收到发送的消息了。
ros2 topic pub <topic_name> <msg_type> '<args>'
ros2 topic info
返回topic的信息。
ros2 topic info <topic_name>
ros2 topic hz
控制一个topic进行的速率。
service
ros2 service list
展示所有正在运行的服务。 还可以加一个 -t 指令,后面就会显示其类型,配合 ros2 interface show 很好用!
ros2 service type
返回服务的类型
ros2 service type <service_name>
ros2 service find
根据类型 查正在运行的服务
ros2 service find <type_name>
ros2 service call
调用一个service,像一个节点给另一个发请求。有一个值得注意的点就是 <arguments> 这个参数调用时要写一个双引号的,比如这个箱子:
"{x: 2, y: 2, theta: 0.2, name: ''}"
可以发现其中‘:’的后面都有个空格,这个空格得加上。
ros2 service call <service_name> <service_type> <arguments>
param
参数可以为 node 增加配置项
ros2 param list
展示每个节点的一些配置参数。
ros2 param get
显示参数类型和当前值
ros2 param get <node_name> <parameter_name>
ros2 param set
设置参数咯
ros2 param set <node_name> <parameter_name> <value>
ros2 param dump
导出节点的参数,顺便还可以把参数写进一个yaml文件
ros2 param dump <node_name>
ros2 param load
加载一个yaml文件的参数,应该叫参数文件
ros2 param load <node_name> <parameter_file>
# 也可以在启动的时候配置参数
ros2 run <package_name> <executable_name> --ros-args --params-file <file_name>
action
当使用 node info 指令的时候,有一个选项就是action,可以看到其中的action。
This action server chose to abort the first goal because it got a new one. It could have chosen something else, like reject the new goal or execute the second goal after the first one finished. Don’t assume every action server will choose to abort the current goal when it gets a new one.
ros2 action list
返回action
ros2 action info
查看一个action的信息
ros2 action send_goal
发送一个操作目标 ,会返回一个结果,如果想看到feedback的信息,就需要后面加一个 --feedback;
bag
记录操作到一个文件,然后可以复现一下子,ros1中不能完美复现,不知道2怎么样
ros2 bag record
ros2 bag record <topic_name>
ros2 bag info
ros2 bag info <bag_file_name>