日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

marker主题 ros_(五)ROS主题理解

發布時間:2023/12/2 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 marker主题 ros_(五)ROS主题理解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考網址:

1,小海龜例子

(1) 在新的終端打開roscore

$ roscore

---如果出錯,請確定關閉所有ROS命令或者路徑,重試。

(2) 在新的終端打開運行小海龜界面

$ rosrun turtlesim

turtlesim_node

得到結果:

[ INFO] [1294665184.346950426]: Starting turtlesim with node

name /turtlesim

[ INFO] [1294665184.358498715]: Spawning turtle [turtle1] at

x=[5.555555], y=[5.555555], theta=[0.000000]

此后小海龜運行的路徑都記錄在此終端

(3) 在新的終端打開鼠標控制終端

$?rosrun turtle_teleop

turtle_teleop_key

將鼠標放在此終端界面,然后用鍵盤上的“上,下,左,右”控制小海龜移動,以下是我運行的界面,是不是有點像SIAT?

2,ROS 主題

就像小海龜這個例子,turtlesim_node和turtle_teleop_key 節點在ROS

主題上進行通信,turtle_teleop_key在該主題上發送key strokes, turtlesim在相同主題上,預定該key

strokes。我們可以用rxgraph來顯示該節點和主題間的交流。

(1) 主題顯示

$ rxgraph --在新終端輸入該命令

得到結果如圖:

下面的圖詮釋了,節點,主題:

(2) rostopic 介紹

I,rostopic -h

$ rostopic -h

得到結果:

rostopic is a command-line tool for printing information about

ROS 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 -h for

more 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.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

這樣我們再看rxgraph顯示的終端,如下,在INFO欄,顯示了信息

III, rostopic list -h

返回所有主題當前預定和發布的數據,子命令如下:

Usage: rostopic list [/namespace]

Options:

-h, --help

show this

help message and exit

-b BAGFILE,

--bag=BAGFILE

list topics in .bag file

-v, --verbose

list full details about each topic

-p ?list only

publishers

-s ?list only

subscribers

例如,查詢當前主題的預定和發布數據:

$ rostopic ?list

-v

得到結果:

Published topics:

* /turtle1/color_sensor [turtlesim/Color] 1

publisher

* /turtle1/command_velocity

[turtlesim/Velocity] 1 publisher

* /rosout [roslib/Log] 3 publishers

* /rosout_agg [roslib/Log] 1 publisher

* /turtle1/pose [turtlesim/Pose] 1

publisher

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

$rosmsg

show turtlesim/Velocity --查詢消息類型細節

得到結果:

float32

linear float32 angular

4,將消息應用到主題上

I,rostopic pub [topic] [msg_type] [args]

將數據發布到當前主題上,例如小海龜例子:

$rostopic pub -1 /turtle1/command_velocity turtlesim/Velocity --

2.0 1.8

命令詮釋:

rostopic

pub ---在給定主題上發布消息

-1

---此選項表示rostopic只發布一個消息,然后退出

/turtle1/command_velocity

---給定的主題名

turtlesim/Velocity

---在給定主題上發布的消息類型

--

---雙負號,表示詞法選擇器在此后的參數都不可用。這種情況發生在錯誤參數比如負數

2.0

1.8 ---當前主題消息的類型的數據值

得到的結果:

終端顯示:

publishing

and 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.767

min: 0.000s max: 0.053s std dev: 0.02014s window: 43

average rate: 44.994

min: 0.000s max: 0.054s std dev: 0.02016s window: 87

average rate: 45.382

min: 0.000s max: 0.054s std dev: 0.01993s window: 134

average rate: 45.032

min: 0.000s max: 0.063s std dev: 0.02003s window: 177

average rate: 45.165

min: 0.000s max: 0.063s std dev: 0.01999s window: 224

III,rxplot

是展示畫出該主題上發布的數據,比如我們對小海龜轉圈,這個例子

$rxplot

/turtle1/pose/x,/turtle1/pose/y /turtle1/pose/theta

---針對上面圖得到:

總結

以上是生活随笔為你收集整理的marker主题 ros_(五)ROS主题理解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。