ROS主题理解
来源:互联网 发布:软件仓库 编辑:程序博客网 时间:2024/05/16 05:33
http://blog.sina.com.cn/s/blog_661159d50100od99.html
参考网址:http://www.ros.org/wiki/ROS/Tutorials/UnderstandingTopics
1,小海龟例子
注意:请确定是否是在新的终端(重新打开一个终端)运行。(1) 在新的终端打开roscore$ roscore---如果出错,请确定关闭所有ROS命令或者路径,重试。
(2) 在新的终端打开运行小海龟界面$ rosrun turtlesimturtlesim_node 得到结果:[ INFO] [1294665184.346950426]: Starting turtlesim with nodename /turtlesim[ INFO] [1294665184.358498715]: Spawning turtle [turtle1] atx=[5.555555], y=[5.555555], theta=[0.000000]此后小海龟运行的路径都记录在此终端
(3) 在新的终端打开鼠标控制终端$ rosrun turtle_teleopturtle_teleop_key 将鼠标放在此终端界面,然后用键盘上的“上,下,左,右”控制小海龟移动,以下是我运行的界面,是不是有点像SIAT?
2,ROS 主题就像小海龟这个例子,turtlesim_node和turtle_teleop_key 节点在ROS主题上进行通信,turtle_teleop_key在该主题上发送key strokes, turtlesim在相同主题上,预定该keystrokes。我们可以用rxgraph来显示该节点和主题间的交流。
(1) 主题显示$ rxgraph --在新终端输入该命令得到结果如图:
下面的图诠释了,节点,主题:
(2) rostopic 介绍
I,rostopic -h$ rostopic -h得到结果:rostopic is a command-line tool for printing information aboutROS Topics.
Commands:rostopic bw display bandwidth used by topicrostopic echo print messages to screenrostopic find find topics by typerostopic hz display publishing rate of topic rostopic info print information about active topicrostopic list list active topicsrostopic pub publish data to topicrostopic type print topic type
Type rostopic <command> -h formore detailed usage, e.g. 'rostopic echo -h'
II,rostopic echo [topic]我们查看/turtel/command_velocity主题通过turtle_teleop_key节点发布的数据,在新终端输入:$ rostopic echo/turtle1/command_velocity当我们把鼠标放在turtle_teleop_key 终端页面,运行小海龟时,得到结果:---linear: 2.0angular: 0.0---linear: 0.0angular: -2.0---linear: 0.0angular: 2.0---linear: -2.0angular: 0.0---linear: 2.0angular: 0.0---linear: 2.0angular: 0.0这样我们再看rxgraph显示的终端,如下,在INFO栏,显示了信息
III, rostopic list -h返回所有主题当前预定和发布的数据,子命令如下:Usage: rostopic list [/namespace]
Options: -h, --help show thishelp message and exit -b BAGFILE,--bag=BAGFILE list topics in .bag file -v, --verbose list full details about each topic -p list onlypublishers -s list onlysubscribers 例如,查询当前主题的预定和发布数据:$ rostopic list-v 得到结果:Published topics: * /turtle1/color_sensor [turtlesim/Color] 1publisher * /turtle1/command_velocity[turtlesim/Velocity] 1 publisher * /rosout [roslib/Log] 3 publishers * /rosout_agg [roslib/Log] 1 publisher * /turtle1/pose [turtlesim/Pose] 1publisher
Subscribed topics: * /turtle1/command_velocity[turtlesim/Velocity] 2 subscribers * /rosout [roslib/Log] 1 subscriber
3,ROS消息在ROS主题上,是通过消息进行通信的。发布者(turtle_teleop_key)和预定者(turtlesim_node)之间的通信,发布者和预定者发送和接受的同一类型的消息,这就决定了发布者决定主题类型。
I, rostopic type [topic]返回当前运行主题的消息类型,例如小海龟例子:$ rostopic type/turtle1/command_velocity得到结果:turtlesim/Velocity$ rosmsgshow turtlesim/Velocity --查询消息类型细节得到结果:float32linear float32 angular
4,将消息应用到主题上
I,rostopic pub [topic] [msg_type] [args]将数据发布到当前主题上,例如小海龟例子:$rostopic pub -1 /turtle1/command_velocity turtlesim/Velocity --2.0 1.8命令诠释:rostopicpub ---在给定主题上发布消息-1---此选项表示rostopic只发布一个消息,然后退出/turtle1/command_velocity---给定的主题名turtlesim/Velocity---在给定主题上发布的消息类型-----双负号,表示词法选择器在此后的参数都不可用。这种情况发生在错误参数比如负数2.01.8 ---当前主题消息的类型的数据值
得到的结果:终端显示:publishingand latching message for 3.0 seconds图运行的结果是:
另外,如果要保持小海龟一直移动,可以采用-r,例如:$ rostopic pub /turtle1/command_velocity turtlesim/Velocity -r 1 --2.0 -1.8运行结果:
我们查看下rxgraph图显示:我们可以看到小海龟运行一个圈的轨迹。
II,rostopic hz [topic]是用来报告哪个数据发布率,比如小海龟的例子:$ rostopic hz /turtle1/pose得到结果:subscribed to [/turtle1/pose]average rate: 44.767min: 0.000s max: 0.053s std dev: 0.02014s window: 43average rate: 44.994min: 0.000s max: 0.054s std dev: 0.02016s window: 87average rate: 45.382min: 0.000s max: 0.054s std dev: 0.01993s window: 134average rate: 45.032min: 0.000s max: 0.063s std dev: 0.02003s window: 177average rate: 45.165min: 0.000s max: 0.063s std dev: 0.01999s window: 224
III,rxplot是展示画出该主题上发布的数据,比如我们对小海龟转圈,这个例子
$ rxplot/turtle1/pose/x,/turtle1/pose/y /turtle1/pose/theta---针对上面图得到:
[ INFO] [1294665184.346950426]: Starting turtlesim with nodename /turtlesim
[ INFO] [1294665184.358498715]: Spawning turtle [turtle1] atx=[5.555555], y=[5.555555], theta=[0.000000]
rostopic is a command-line tool for printing information aboutROS Topics.
Commands:
rostopic bw display bandwidth used by topic
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 type
Type rostopic <command> -h formore detailed usage, e.g. 'rostopic echo -h'
---
linear: 2.0
angular: 0.0
---
linear: 0.0
angular: -2.0
---
linear: 0.0
angular: 2.0
---
linear: -2.0
angular: 0.0
---
linear: 2.0
angular: 0.0
---
linear: 2.0
angular: 0.0
Usage: rostopic list [/namespace]
Options:
Published topics:
Subscribed topics:
turtlesim/Velocity
我们查看下rxgraph图显示:
- ROS主题理解
- (五)ROS主题理解
- ROS(一)主题
- ROS学习笔记(四):ROS主题
- ROS 中主题、服务主要用途
- (四)理解ROS topics
- 05-理解 ROS节点
- 06-理解ROS话题
- 3、理解ros节点
- 4、理解ros话题
- 5、理解ros服务
- 理解ROS话题
- ROS节点、消息、服务、主题的关系
- 第六节---ROS操作系统----理解ROS节点
- ROS学习笔记四:理解ROS节点
- ROS学习笔记五:理解ROS topics
- ROS入门4: 理解ROS节点
- ROS入门_1.8 理解ROS节点
- FrameLayout(单帧布局)
- 揭开Socket编程的面纱
- 深入解读ESB与SOA的关系
- Java批量文件打包下载
- prepareCall()方法执行存储过程
- ROS主题理解
- loadrunner中log的使用初步总结
- 数据仓库工具箱:维度建模的完全指南
- 网站灵活的风格和文本的适当,都会给网站加分!
- UVa 12640 Largest Sum Game (water ver.)
- Testin:2013年8月中国好应用质量排行
- (2) Data source rejected establishment of connection, message from server: "Too many connections"解决办
- 二维数组的动态分配及参数传递
- Android adb shell启动应用程序的方法