曾少贤 2018-02-22
roscore # making sure that we have roscore running rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key # Now you can use the arrow keys of the keyboard to drive the turtle around.
sudo apt-get install ros-kinetic-rqt sudo apt-get install ros-kinetic-rqt-common-plugins rosrun rqt_graph rqt_graph
rostopic -h rostopic echo /turtle1/cmd_vel # you will now see topic datas when you press the arrow key in <tt class="backtick">turtle_teleop_key</tt> terminal
rostopic list -h # figure out what argument the list sub-command needs rostopic list -v # displays a verbose list of topics to publish to and subscribe to and their type
rostopic type /turtle1/cmd_vel # You should get the message type of the topic: geometry_msgs/Twist rosmsg show geometry_msgs/Twist # look at the details of the message using rosmsg
# publishes data on to a topic, rostopic pub [topic] [msg_type] [args] rostopic pub - /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' # publishes the velocity commands at a rate of Hz on the velocity topic rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]' # Now We can also look at what is happening in rqt_graph. # and see the data published by our turtlesim rostopic echo /turtle1/pose<br /><br /># see how fast the <tt class="backtick">turtlesim_node</tt> is publishing <tt class="backtick">/turtle1/pose, $ rostopic hz [topic]<br /></tt>rostopic hz /turtle1/pose<br /><br /># get in depth information about a topic<br />rostopic type /turtle1/cmd_vel | rosmsg show
rosrun rqt_plot rqt_plot # a text box in the upper left corner gives you the ability to add any topic to the plot. # Typing /turtle1/pose/x and add it. # Typing /turtle1/pose/y and add it.