|
|
ÖØÐÂ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 |
|