Setup
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.
ROS Topics
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 turtle_teleop_key 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
Using rostopic pub
# publishes data on to a topic, 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]‘ # publishes the velocity commands at a rate of 1 Hz on the velocity topic rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- ‘[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
# see how fast the turtlesim_node is publishing /turtle1/pose, $ rostopic hz [topic]
rostopic hz /turtle1/pose
# get in depth information about a topic
rostopic type /turtle1/cmd_vel | rosmsg show
Using rqt_plot
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.