ROS笔记 Topics

http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics

  • rostopic
  • rqt_graph
  • rosmsg

rqt_graph

一个用于查看topic的sub/pub关系的node.

rostopic

获取与topic相关的信息

rostopic bw     display bandwidth used by topic
rostopic echo   print messages to screen
rostopic hz     display publishing rate of topic    
rostopic list   print information about active topics
rostopic pub    publish data to topic
rostopic type   print topic type

几种用法简介

rostopic echo [topic]
实际上就是subscribe了一个topic  当有向这个topic的消息发出时,打印出msg在屏幕上

rostopic list
输出当前的系统有哪些topic及publisher/sunscriber,如下
Published topics:
 * /turtle1/color_sensor [turtlesim/Color] 1 publisher
 * /turtle1/cmd_vel [geometry_msgs/Twist] 1 publisher
 * /rosout [rosgraph_msgs/Log] 2 publishers
 * /rosout_agg [rosgraph_msgs/Log] 1 publisher
 * /turtle1/pose [turtlesim/Pose] 1 publisher

Subscribed topics:
 * /turtle1/cmd_vel [geometry_msgs/Twist] 1 subscriber
 * /rosout [rosgraph_msgs/Log] 1 subscriber
 
 
rostopic type [topic]
显示该topic的消息类型
rostopic type /turtle1/cmd_vel -->  geometry_msgs/Twist

rosmsg show [msgtype]
显示当前type的msg的具体信息
rosmsg show geometry_msgs/Twist,输出如下
geometry_msgs/Vector3 linear
  float64 x
  float64 y
  float64 z
geometry_msgs/Vector3 angular
  float64 x
  float64 y
  float64 z

rostopic pub [topic] [msg_type] [args]
发送一个消息
rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'
-1代表发完就退出.  --意思是其后面的内容不是option,不用解析.防止你的具体消息内容里带-

rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
-r 1的意思是每秒发1次


rostopic hz [topic]
查看某个topic的发送频率

rqt_plot

rqt_plot displays a scrolling time plot of the data published on topics. Here we'll use rqt_plot to plot the data being published on the /turtle1/pose topic.

posted @ 2019-03-18 15:52  core!  阅读(448)  评论(0编辑  收藏  举报