Znn3bq.jpeg
²é¿´: 1638  |  »Ø¸´: 0

yadan33

гæ (³õÈëÎÄ̳)

[½»Á÷] ROS-topic

ÖØÐÂroscore
$ roscore
run node
$ rosrun turtlesim turtlesim_node
¼üÅÌ¿ØÖÆÎÚ¹êÒÆ¶¯£¬ÒªÆô¶¯Õâ¸öterminalÎÚ¹ê²Å»á¶¯
$ rosrun turtlesim turtle_teleop_key
¡¢

ÓÃrqt-graph²é¿´topic
Èç¹ûû°²×°£¬ÏȰ²×°
$ sudo apt-get install ros-<distro>-rqt
$ sudo apt-get install ros-<distro>-rqt-common-plugins

È»ºó
In a new terminal:
$ rosrun rqt_graph rqt_graph
¿ÉÒÔ¿´µ½ÀàËÆÏÂÃæµÄ


$ rostopic -h
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£º
rostopic echo [topic]

$ rostopic echo /turtle1/cmd_vel
ÒÆ¶¯Ð¡Îڹ꣬»á³öÏÖÏÂÃæµÄ
angular:
  x: 0.0
  y: 0.0
  z: -2.0
---
linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: -2.0
---
linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: -2.0
Ë¢ÐÂgraphÒ³Ãæ£¬¶àÁËÒ»¸ötopic


$ rostopic list -h
Usage: rostopic list [/topic]

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
For rostopic list use the verbose option:

$ rostopic list -v
This displays a verbose list of topics to publish to and subscribe to and their type.

Published topics:
* /turtle1/color_sensor [turtlesim/Color] 1 publisher
* /turtle1/command_velocity [turtlesim/Velocity] 1 publisher
* /rosout [roslib/Log] 2 publishers
* /rosout_agg [roslib/Log] 1 publisher
* /turtle1/pose [turtlesim/Pose] 1 publisher

Subscribed topics:
* /turtle1/command_velocity [turtlesim/Velocity] 1 subscriber
* /rosout [roslib/Log] 1 subscriber


4£¬½«ÏûÏ¢Ó¦Óõ½Ö÷ÌâÉÏ



I£¬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]'
ÃüÁîÚ¹ÊÍ£º
rostopic
pub £­£­£­ÔÚ¸ø¶¨Ö÷ÌâÉÏ·¢²¼ÏûÏ¢
-1
£­£­£­´ËÑ¡Ïî±íʾrostopicÖ»·¢²¼Ò»¸öÏûÏ¢£¬È»ºóÍ˳ö
/turtle1/cmd_vel
£­£­£­¸ø¶¨µÄÖ÷ÌâÃû
geometry_msgs/Twist
£­£­£­ÔÚ¸ø¶¨Ö÷ÌâÉÏ·¢²¼µÄÏûÏ¢ÀàÐÍ
--
£­£­£­Ë«¸ººÅ£¬±íʾ´Ê·¨Ñ¡ÔñÆ÷Ôڴ˺óµÄ²ÎÊý¶¼²»¿ÉÓá£ÕâÖÖÇé¿ö·¢ÉúÔÚ´íÎó²ÎÊý±ÈÈ縺Êý
'[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' £­£­£­ In this case, '[2.0, 0.0, 0.0]' becomes the linear value with x=2.0, y=0.0, and z=0.0, and '[0.0, 0.0, 1.8]' is the angular value with x=0.0, y=0.0, and z=1.8.
ÈÃСÎÚ¹êÒ»Ö±ÒÆ¶¯£¬¼ÓÒ»¸ö-r 1£¬ÈÃÆä±£³Ö1hzƵÂÊ
$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

»ñµÃµ±Ç°µÄËÙÂÊ
rostopic hz [topic]
Let's see how fast the turtlesim_node is publishing /turtle1/pose:

$ rostopic hz /turtle1/pose

plotÏÔʾ
$ rosrun rqt_plot rqt_plot

ROS-topic
1111.png


ROS-topic-1
22222.png
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ yadan33 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] 277Çóµ÷¼Á +21 Äß½¨Éè 2026-04-06 21/1050 2026-04-12 12:27 by laoshidan
[¿¼ÑÐ] µ÷¼Á +25 ²»·ê´º 2026-04-07 26/1300 2026-04-12 11:53 by ´óÁ¦Ë®ÊÖÁ¦´óÎÞÇ
[¿¼ÑÐ] 327Çóµ÷¼Á +5 ʰ¹âÈÎȾ 2026-04-06 5/250 2026-04-12 02:29 by Çï¶¹²ËÑ¿
[¿¼ÑÐ] Çóµ÷¼Á +11 ÔÂ@163.com 2026-04-07 13/650 2026-04-11 22:55 by BruceLiu320
[¿¼ÑÐ] Çóµ÷¼Á +6 µçÆø300Çóµ÷¼Á²» 2026-04-08 6/300 2026-04-11 20:14 by ÄæË®³Ë·ç
[¿¼ÑÐ] Çóµ÷¼Á +11 ôæôæÒ»ÊéÉú 2026-04-09 11/550 2026-04-11 19:57 by ÄæË®³Ë·ç
[¿¼ÑÐ] µ÷¼ÁÇóÖú +6 ¹ûÈ»ÓÐÎÒ 2026-04-11 7/350 2026-04-11 16:22 by Ã÷Ô´ËʱÓÐ
[¿¼ÑÐ] Çóµ÷¼Á +10 Á§ÜÔÒ»¶¨Éϰ¶ 2026-04-10 10/500 2026-04-11 13:31 by 1005715100
[¿¼ÑÐ] ±¾¿Æ211 ¹¤¿Æ085400 280·ÖÇóµ÷¼Á ¿É¿çרҵ +11 LZH£¨µÈ´ýµ÷¼ÁÖÐ 2026-04-10 11/550 2026-04-11 08:39 by zhq0425
[¿¼ÑÐ] 342µç×ÓÐÅϢר˶Çóµ÷¼Á +9 ÄãÈÃÎÒÔõôÀóÖ¦ 2026-04-10 10/500 2026-04-11 08:33 by zhq0425
[¿¼ÑÐ] 22408 366·Ö£¬±¾¿Æ211£¬Ò»Ö¾Ô¸Î÷¹¤´ó +4 Rubt 2026-04-09 4/200 2026-04-10 19:51 by chemisry
[¿¼ÑÐ] 071000ÉúÎïѧµ÷¼ÁÇóÖú +17 zzzzwww 2026-04-09 20/1000 2026-04-10 15:55 by Çóµ÷¼Ázz
[¿¼ÑÐ] 085800 ÄÜÔ´¶¯Á¦Çóµ÷¼Á +6 °¢biu°¡°¡°¡°¡°¡ 2026-04-10 6/300 2026-04-10 15:03 by hemengdong
[¿¼ÑÐ] Çóµ÷¼Á ²ÄÁÏÓ빤³Ì 324·Ö ר˶ +19 ôæôæÒ»ÊéÉú 2026-04-10 21/1050 2026-04-10 11:41 by wp06
[¿¼ÑÐ] 314Çóµ÷¼Á +14 weltZeng 2026-04-09 14/700 2026-04-09 23:14 by wolf97
[¿¼ÑÐ] 348Çóµ÷¼Á +3 candyyyi 2026-04-09 3/150 2026-04-09 17:20 by ¶ÎΰÑÞ
[¿¼ÑÐ] ²ÄÁÏר˶322 +14 ¹þ¹þ¹þºðºðºð¹þ 2026-04-05 14/700 2026-04-09 13:25 by 5268321
[¿¼ÑÐ] 11408 325·Ö +3 jgtxuxgkx 2026-04-07 3/150 2026-04-07 23:10 by lbsjt
[¿¼ÑÐ] ר˶085403£¬291·Ö£¬ÓÐÁ½Æª×¨Àû£¬Ò»¹úÒ»½± +3 ¹þ¼ªßä¹þ¼ªßä 2026-04-07 3/150 2026-04-07 18:21 by À¶ÔÆË¼Óê
[¿¼ÑÐ] 285Çóµ÷¼Á +5 mapmath 2026-04-06 6/300 2026-04-06 17:18 by À¶ÔÆË¼Óê
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û