深圳市住房和城乡建设厅网站首页,潍坊网站建设价格,网站结构规划,企业网站的建设目的参考网址#xff1a;1#xff0c;小海龟例子(1) 在新的终端打开roscore$ roscore#xff0d;#xff0d;#xff0d;如果出错#xff0c;请确定关闭所有ROS命令或者路径#xff0c;重试。(2) 在新的终端打开运行小海龟界面$ rosrun turtlesimturtlesim_node得到结果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将鼠标放在此终端界面然后用键盘上的“上下左右”控制小海龟移动以下是我运行的界面是不是有点像SIAT2ROS 主题就像小海龟这个例子turtlesim_node和turtle_teleop_key 节点在ROS主题上进行通信turtle_teleop_key在该主题上发送key strokes, turtlesim在相同主题上预定该keystrokes。我们可以用rxgraph来显示该节点和主题间的交流。(1) 主题显示$ rxgraph 在新终端输入该命令得到结果如图下面的图诠释了节点主题(2) rostopic 介绍Irostopic -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 topicrostopic info print information about active topicrostopic list list active topicsrostopic pub publish data to topicrostopic type print topic typeType rostopic -h formore detailed usage, e.g. rostopic echo -hIIrostopic 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, --helpshow thishelp message and exit-b BAGFILE,--bagBAGFILElist topics in .bag file-v, --verboselist 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] 1publisherSubscribed topics:* /turtle1/command_velocity[turtlesim/Velocity] 2 subscribers* /rosout [roslib/Log] 1 subscriber3ROS消息在ROS主题上是通过消息进行通信的。发布者(turtle_teleop_key)和预定者(turtlesim_node)之间的通信发布者和预定者发送和接受的同一类型的消息这就决定了发布者决定主题类型。I rostopic type [topic]返回当前运行主题的消息类型例如小海龟例子$ rostopic type/turtle1/command_velocity得到结果turtlesim/Velocity$rosmsgshow turtlesim/Velocity 查询消息类型细节得到结果float32linear float32 angular4将消息应用到主题上Irostopic 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图显示我们可以看到小海龟运行一个圈的轨迹。IIrostopic 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: 224IIIrxplot是展示画出该主题上发布的数据比如我们对小海龟转圈这个例子$rxplot/turtle1/pose/x,/turtle1/pose/y /turtle1/pose/theta针对上面图得到