ROS 常用命令
前言
本文以“小海龟”的例程为例,记录常用的ROS命令。
一、启动ROS自带的“小海龟”
- 启动ROS Master
roscore
- 启动仿真器
rosrun turtlesim turtlesim_node
- 启动海龟控制节点
rosrun turtlesim turtle_teletop_key
此时可以用键盘来控制海龟的运动了。效果如图所示:
二、ROS 常用命令
1. rqt_graph显示节点关系
输入
rqt_graph
可得
2. rosnode
$ rosnode
rosnode is a command-line tool for printing information about ROS Nodes.
Commands:
rosnode ping test connectivity to node
rosnode list list active nodes
rosnode info print information about node
rosnode machine list nodes running on a particular machine or list machines
rosnode kill kill a running node
rosnode cleanup purge registration information of unreachable nodes
Type rosnode <command> -h for more detailed usage, e.g. 'rosnode ping -h'
列出所有活跃节点
~ rosnode list
/rosout
/teleop_turtle
/turtlesim
查询某一节点(以/turtlesim为例)的详细信息
~ rosnode info /turtlesim
--------------------------------------------------------------------------------
Node [/turtlesim]
Publications:
* /rosout [rosgraph_msgs/Log]
* /turtle1/color_sensor [turtlesim/Color]
* /turtle1/pose [turtlesim/Pose]
Subscriptions:
* /turtle1/cmd_vel [geometry_msgs/Twist]
Services:
* /clear
* /kill
* /reset
* /spawn
* /turtle1/set_pen
* /turtle1/teleport_absolute
* /turtle1/teleport_relative
* /turtlesim/get_loggers
* /turtlesim/set_logger_level
contacting node http://mxt-Yoga:44213/ ...
Pid: 25826
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound (41939 - 127.0.0.1:46220) [30]
* transport: TCPROS
* topic: /turtle1/cmd_vel
* to: /teleop_turtle (http://mxt-Yoga:39913/)
* direction: inbound (36026 - mxt-Yoga:59331) [32]
* transport: TCPROS
3. rostopic
~ rostopic
rostopic is a command-line tool for printing information about ROS Topics.
Commands:
rostopic bw display bandwidth used by topic
rostopic delay display delay of topic from timestamp in header
rostopic echo print messages to screen
rostopic find find topics by type
rostopic hz display publishing rate of topic
rostopic info print information about active topic
rostopic list list active topics
rostopic pub publish data to topic
rostopic type print topic or field type
Type rostopic <command> -h for more detailed usage, e.g. 'rostopic echo -h'
4. rosservice
~ rosservice
Commands:
rosservice args print service arguments
rosservice call call the service with the provided args
rosservice find find services by service type
rosservice info print information about service
rosservice list list active services
rosservice type print service type
rosservice uri print service ROSRPC uri
Type rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'
5. 话题记录
rosbag record -a -O cmd_record
其中
-a
是指保存所有(all)的数据-O
是指保存数据为压缩包的格式,-O后面的名字即为压缩包的命名
6. 话题复现
rosbag play cmd_record.bag