一、常用命令
rostopicrosservicerosnoderosparamrosmsgrossrv二、ros小海龟背后剖析
roscore
rosrun <package name> <node name>rosrun turtlesim turtlesim_node
#可以查看当前系统节点的关系及通讯rqt_graph
#打印Ros Node的信息rosnode
#打印Ros topic信息rostopicCommands:rostopic bwdisplay bandwidth used by topicrostopic delaydisplay delay of topic from timestamp in headerrostopic echoprint messages to screenrostopic findfind topics by typerostopic hzdisplay publishing rate of topic rostopic infoprint information about active topicrostopic listlist active topicsrostopic pubpublish data to topicrostopic typeprint 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.0y: 0.0z: 0.0angular:x: 0.0y: 0.0z: 0.0"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -hUsage: rostopic pub /topic type [args...]Options:-h, --help show this help message and exit-vprint verbose output-r RATE, --rate=RATE publishing rate (hz). For -f and stdin input, thisdefaults 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. Thislatches the first message.-s, --substitute-keywordsWhen 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:~$ rosserviceCommands:rosservice argsprint service argumentsrosservice callcall the service with the provided argsrosservice findfind services by service typerosservice infoprint information about servicerosservice listlist active servicesrosservice typeprint service typerosservice uriprint service ROSRPC uriType rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 5.0y: 5.0theta: 0.0name: 'tur2'" name: "tur2"
ll@ll-ThinkPad-P15-Gen-1:~$ rosservice call /spawn "x: 6.0y: 6.0theta: 0.0name: 'tur3'" name: "tur3"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:x: 3.0y: 0.0z: 0.0angular:x: 0.0y: 0.0z: 1.0"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 5 /tur2/cmd_vel geometry_msgs/Twist "linear:x: -5.0y: 0.0z: 0.0angular:x: 0.0y: 0.0z: 1.57"
ll@ll-ThinkPad-P15-Gen-1:~$ rostopic pub -r 12 /tur3/cmd_vel geometry_msgs/Twist "linear:x: 0.0y: 9.0z: 0.0angular:x: 0.0y: 0.0z: 2.0"
三、rosbag命令
rosbag用于记录当前执行的所有数据
记录当前数据并保存到压缩包内
rosbag record -a -O <bag name>
执行保存的包名
rosbag play <bag name>
注意:rosservice的内容未保存