ROS2常用命令工具

包管理工具ros2 pkg

ros2 pkg create

ros2 pkg create --build-type ament_python pkg_name rclpy std_msgs sensor_msgs  

–build-type : C++或者C ament_cmake ,Python ament_python

pkg_name :创建功能包的名字

rclpy std_msgs sensor_msgs :编译依赖

ros2 pkg list

查看系统中功能包列表

ros2 pkg executeables

查看包内可执行文件列表

ros2 pkg executables pkg_name

节点运行 ros2 run

运行功能包节点程序

ros2 run pkg_name node_name  

pkg_name:功能包名字
node_name:可执行程序的名字

节点相关工具 ros2 node

ros2 node list

罗列出所有在当前域内节点名称

ros2 run pkg_name node_name  

ros2 node info

查看节点详细信息,包括订阅、发布的消息,开启的服务和动作等

ros2 node info node_name

主题相关工具 ros2 topic

ros2 topic list

罗列出当前域内的所有主题

ros2 topic list

ros2 topic info

显示主题消息类型,订阅者/发布者数量

ros2 topic info topic_name

ros2 topic type

查看话题的消息类型

ros2 topic type topic_name

ros2 topic hz

显示主题平均发布频率

ros2 topic hz topic_name

ros2 topic echo

在终端打印主题消息,类似于一个订阅者

ros2 topic echo topic_name

ros2 topic pub

在终端发布指定话题消息

ros2 topic pub topic_name message_type message_content

topic_name:需要发布话题消息的话题的名字

message_type:话题的数据类型

message_content:消息内容

接口相关工具ros2 interface

ros2 interface list

罗列当前系统的所有接口,包括话题、服务、动作。

ros2 interface list

ros2 interface show

ros2 interface show interface_name

ros2 interface show interface_name

服务相关工具 ros2 service

ros2 service list

罗列出当前域内所有的服务

ros2 interface show interface_name

ros2 service call

调用指定服务

ros2 interface call service_name service_Type arguments

service_name:需要调用的服务

service_Type:服务数据类型

arguments:提供服务需要的参数