只记录ROS2 和 ROS1 不同的命令
pkg 1 2 3 4 5 6 7 8 9 10 ros2 pkg executables pkg_name ros2 pkg list ros2 pkg prefix pkg_name ros2 pkg xml pkg_name
topic
ros2 topic info topic_name
现在必须加/
了1 2 3 4 5 6 7 user@robot :~$ ros2 topic info imu Unknown topic 'imu' user@robot :~$ ros2 topic info /imu Type: sensor_msgs/msg/Imu Publisher count: 1 Subscription count: 1
输出话题的详细信息,包括发布订阅者: ros2 topic info /odom -v
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Type: nav_msgs/msg/Odometry Publisher count: 1 Node name: turtlebot3_diff_drive Node namespace: / Topic type: nav_msgs/msg/Odometry Endpoint type: PUBLISHER GID: 01.0f .ea.0f .41 .6a.0c.34 .01 .00 .00 .00 .00 .00 .a5.03 .00 .00 .00 .00 .00 .00 .00 .00 QoS profile: Reliability: RMW_QOS_POLICY_RELIABILITY_RELIABLE Durability: RMW_QOS_POLICY_DURABILITY_VOLATILE Lifespan: 2147483651294967295 nanoseconds Deadline: 2147483651294967295 nanoseconds Liveliness: RMW_QOS_POLICY_LIVELINESS_AUTOMATIC Liveliness lease duration: 2147483651294967295 nanoseconds Subscription count: 1 Node name: my_node Node namespace: / Topic type: nav_msgs/msg/Odometry Endpoint type: SUBSCRIPTION GID: 01.0f .ea.0f .0d .6a.5d .f0.01 .00 .00 .00 .00 .00 .13 .04 .00 .00 .00 .00 .00 .00 .00 .00 QoS profile: Reliability: RMW_QOS_POLICY_RELIABILITY_RELIABLE Durability: RMW_QOS_POLICY_DURABILITY_VOLATILE Lifespan: 2147483651294967295 nanoseconds Deadline: 2147483651294967295 nanoseconds Liveliness: RMW_QOS_POLICY_LIVELINESS_AUTOMATIC Liveliness lease duration: 2147483651294967295 nanoseconds
ros2 interface show msg_name
显示 Topic 发送的消息定义 ros2 interface show sensor_msgs/msg/Imu
获知某个消息类型是谁在用1 2 user@robot :~$ ros2 topic find sensor_msgs/msg/Imu /imu
1 ros2 topic pub /chatter std_msgs/msg/String 'data:"123"
interface
分类显示消息、动作、服务的所有类型
ros2 interface package pkg_name
1 2 3 4 5 user@robot :~$ ros2 interface package action_msgs action_msgs /srv /CancelGoal action_msgs /msg /GoalInfo action_msgs /msg /GoalStatus action_msgs /msg /GoalStatusArray
获知某个消息类型是谁在用,可以这样查1 2 3 4 5 6 7 8 user@robot :~$ ros2 interface packages | grep pendulum_msgs pendulum_msgs user @robot :~$ ros2 interface package pendulum_msgs pendulum_msgs /msg /RttestResults pendulum_msgs /msg /JointState pendulum_msgs /msg /JointCommand user @robot :~$ ros2 topic find pendulum_msgs /msg /RttestResults
1 2 user@robot :~$ ros2 interface proto std_msgs /msg /String "data : ''"
service
可以看到服务的定义。
找出指定类型的所有服务
显示服务的定义
param
ros2 param list
ros2 param describe
1 2 3 4 5 6 7 8 ros2 param describe /turtlesim background_r Parameter name: background_r Type: integer Description: Red channel of the background color Constraints: Min value: 0 Max value: 255 Step: 1
1 2 ros2 param get /turtlesim background_r Integer value is: 69
rqt_graph
能够可视化节点和主题之间的连接。这个命令和ROS1一样,也是ROS2为数不多的GUI可视界面
tf
ros2 run tf2_tools view_frames.py
运行结果:1 2 3 4 5 6 7 8 9 10 At time 197.27000000 - Translation: [0.008, -0.000, 0.064] - Rotation: in Quaternion [-0.000, -0.001, -0.010, 1.000] - Rotation: in RPY (radian) [-0.000, -0.002, -0.020] - Rotation: in RPY (degree) [-0.001, -0.092, -1.160] - Matrix: 1.000 0.020 -0.002 0.008 -0.020 1.000 0.000 -0.000 0.002 -0.000 1.000 0.064 0.000 0.000 0.000 1.000