一、常用命令
- rostopic
- rosservice
- rosnode
- rosparam
- rosmsg
- rossrv
二、ros小海龟背后剖析
roscore
rosrun <package name> <node name>
rosrun turtlesim turtlesim_node
#可以查看当前系统节点的关系及通讯
rqt_graph
#打印Ros Node的信息
rosnode
#打印Ros topic信息
rostopic
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
小tip:双击tab键可以补全内容
rostopic pub <topic name> <message>
message:<message name> <message struct> <message context>
rostopic pub /turtle1/cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -h
Usage: rostopic pub /topic type [args...]
Options:
-h, --help show this help message and exit
-v print verbose output
-r RATE, --rate=RATE publishing rate (hz). For -f and stdin input, this
defaults to 10. Otherwise it is not set.
-1, --once publish one message and exit
-f FILE, --file=FILE read args from YAML file (Bagy)
-l, --latch enable latching for -f, -r and piped input. This
latches the first message.
-s, --substitute-keywords
When publishing with a rate, performs keyword ('now'
or 'auto') substitution for each message
--use-rostime use rostime for time stamps, else walltime is used
ll@ll-ThinkPad-P15-Gen-1:~$ 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'
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 5.0
y: 5.0
theta: 0.0
name: 'tur2'"
name: "tur2"
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 6.0
y: 6.0
theta: 0.0
name: 'tur3'"
name: "tur3"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
x: 3.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.0"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 5 /tur2/cmd_vel geometry_msgs/Twist "linear:
x: -5.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.57"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 12 /tur3/cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 9.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 2.0"
三、rosbag命令
rosbag用于记录当前执行的所有数据
记录当前数据并保存到压缩包内
rosbag record -a -O <bag name>
执行保存的包名
rosbag play <bag name>
注意:rosservice的内容未保存