²é¿´: 1670  |  »Ø¸´: 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 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[»ù½ðÉêÇë] ÎÒ²»Àí½â£¡ +15 Edward_pc 2026-08-26 23/1150 2026-08-26 20:34 by zzuzxg
[»ù½ðÉêÇë] ·¶½øÖоÙÒ»ÎĵÄÖÐÐÄ˼Ïë +9 Ñ׻ƹóëÐ 2026-08-22 10/500 2026-08-26 15:40 by semaglutide
[»ù½ðÉêÇë] 2026¹ú×ÔÈ»º¯ÆÀ·Ñµ½ÕË +22 ÑòÑü°å 2026-08-21 25/1250 2026-08-26 15:00 by zuocuiping
[»ù½ðÉêÇë] ¿ÆÑй¶ùÌ«ÄÑÁË +21 ÎÒ4´ó°×²Ë 2026-08-20 22/1100 2026-08-26 11:29 by nlgza
[»ù½ðÉêÇë] ϵͳ½ø²»È¥ +4 yanglien 2026-08-26 5/250 2026-08-26 11:10 by wenfengw83
[»ù½ðÉêÇë] ÏîÄ¿ÐÅÏ¢ºÍ¾­·ÑÐÅÏ¢ÔÚϵͳÀï¶¼¿ÉÒÔ¿´µ½ÁË +6 wittyboy 2026-08-26 14/700 2026-08-26 10:55 by wittyboy
[»ù½ðÉêÇë] Ôõô¿´Çà»ùÖÐÁËûÓа¡ +4 Ò¶¾Å΢ 2026-08-26 4/200 2026-08-26 10:52 by xiacongxu
[»ù½ðÉêÇë] ¹úºÏ¿É²éÁË +3 paperzjh 2026-08-26 3/150 2026-08-26 10:41 by LemmonTr
[»ù½ðÉêÇë] ½ñÌìÎñί»á¿ªÍêÁË£¬Ã÷Ìì³ö½á¹ûÂð +19 angus9576 2026-08-25 23/1150 2026-08-26 10:03 by zp519
[Ö°³¡ÈËÉú] ѧÉúײ¼û¸¨µ¼Ô±ËÍÍâÂô£¬µÚ¶þÌìÈ«°à¶¼³ÁĬÁË +3 ¾¨ÓãÈÚ½ð_Õã½­_É 2026-08-22 3/150 2026-08-26 09:01 by zzuzxg
[»ù½ðÉêÇë] Å£À´£¡Ã×À´£¡ÃæÀ´£¡ +8 beefly 2026-08-26 8/400 2026-08-26 08:37 by xuzhipiao
[»ù½ðÉêÇë] Ã÷ÌìÓ¦¸Ã¿É²éÁË£¡£¿ +6 chengyan1220 2026-08-23 6/300 2026-08-25 19:45 by zfd97
[»ù½ðÉêÇë] Èç¹û´Ë¿ÌÄãÕýÔÚΪ¹ú»ù¸Ðµ½½¹ÂÇ£¬²»·ÁÀ´ÌýÌýÕâÊס¶»ù½ðÖ®Íâ¡· +8 scalable 2026-08-24 8/400 2026-08-25 12:52 by jnhyjjm
[»ù½ðÉêÇë] ûÓÐÈκÎÏûÏ¢-ÊDz»ÊǾÍÁ¹ÁË +9 ͼÀ²Í¼À² 2026-08-24 10/500 2026-08-25 11:59 by ÄϺ£Ð¡¸ç
[»ù½ðÉêÇë] ÈËÆø²»ÐÐÁË +11 fansofjerry 2026-08-21 11/550 2026-08-25 11:04 by ¹Â¶ÀµÄÓ¢ÐÛ6
[»ù½ðÉêÇë] ÎÒÃæÉÏÍêµ°ÁË +13 ÇÒÌý»¢Ð¥ 2026-08-20 14/700 2026-08-25 09:10 by mrkang
[½Ìʦ֮¼Ò] Ìø²ÛºóÔÚÑÐÏîÄ¿Ôõô°ì£¿ +5 ¼òµ¥»¯xn 2026-08-22 10/500 2026-08-23 12:38 by ¼òµ¥»¯xn
[»ù½ðÉêÇë] ʱ¼ä´Á½ñÌ죬20ºÅ±äÁË +5 archvillain 2026-08-20 5/250 2026-08-22 06:12 by hui_daxiao
[»ù½ðÉêÇë] ¿´À´½ñÌì²»»á·Å°ñÁË£¿ +8 chengyan1220 2026-08-21 11/550 2026-08-21 17:52 by dcqxinyang
[»ù½ðÉêÇë] Ó¦¸ÃÊÇÏÂÖÜÈý26ÈÕ¹«²¼Á˰ɣ¿ +4 ¹þ¹þ¸ò£¿ 2026-08-21 4/200 2026-08-21 10:58 by Vivilian
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û