Using ROS Noetic Turtle Sim on Ubuntu 20.04
In the following sections, we will investigate Turtle Sim communication commands, and will cover the following steps:
- Listing all active nodes
- Listing all topics
- Getting information about topics
- Showing message information
- Echoing messages in real-time
Prerequisites
Install ROS Noetic on Ubunutu 20.04. Follow the official page instructions for installation: https://wiki.ros.org/noetic/Installation/Ubuntu
Start Roscore
This step is necessary before launching turtlesim or any other turtlesim command.
roscore
Turtlesim Launch
Each one of these commands need to run in a new Terminal instance or a new tab.
Start TurtleSim Node
Starts turtlesim GUI
rosrun turtlesim turtlesim_node
Start TrutleSim Teleop Key
Uses keyboard to maniputale turtle robot
rosrun turtlesim turtle_teleop_key
Listing all Active Nodes
Now that we’ve launched turtlesim_node and played around with sending commands via the turtle_teleop_key node
To get a list of all nodes that are active and have been registered with the ROS Master, we can use the command rosnode list. Let’s do so now:
rosnode list
We can see that there are three active nodes that have been registered with the ROS Master: /rosout, /teleop_turtle, and /turtlesim.
- /rosout: This node is launched by roscore. It subscribes to the standard /rosout topic, the topic to which all nodes send log messages.
- /teleop_turtle: This is our keyboard teleop node. Notice that its not named turtle_teleop_key. There’s no requirement that a node’s broadcasted name is the same as the name of it’s associated executable.
- /turtlesim: The node name associated with the turtlebot_sim node.
Listing all Active Topics
In a similar fashion, we are able to query the ROS Master for a list of all topics. To do so, we use the command rostopic list.
rostopic list
- /rosout_agg: Aggregated feed of messages published to /rosout.
- /turtle1/cmd_vel: Topic on which velocity commands are sent/received. Publishing a velocity message to this topic will command turtle1 to move.
- /turtle1/color_sensor: Each turtle in turtlesim is equipped with a color sensor, and readings from the sensor are published to this topic.
- /turtle1/pose: The position and orientation of turtle1 are published to this topic.
Get Information About a Specific Topic
If we wish to get information about a specific topic, who is publishing to it, subscribed to it, or the type of message associated with it, we can use the command rostopic info . Let’s check into the `/turtle1/cmd_vel` topic:
# Recplace turtle1/cmd_vel for the topic you want
rostopic info turtle1/cmd_vel
As you might expect, there are two nodes registered on this topic. One publisher, the teleop_turtle node, and one subscriber, the turtlesim node. Additionally, we see that the type of message used on this topic is geometry_msgs/Twist.
Show Message Information
Let’s get some more information about the geometry_msgs/Twist message on the /turtle1/cmd_vel topic, to do so, we will use the rosmsg info command.
rosmsg info geometry_msgs/Twist
We can see that a Twist message consists nothing more than two Vector3 messages. One for linear velocity, and another for angular velocity, with each velocity component (x, y, z) represented by a float64.
Note: Sometimes the message definition doesn’t provide an ample amount of detail about a message type. For instance, in the example above, how can we be sure that linear and angular vectors above refer to velocities, and not positions? One way to get more detail would be to look at the comments in the message’s definition file. To do so, we can issue the following command:
rosed geometry_msgs Twist.msg.
Echo Messages on a Topic
Sometimes it may be useful to look at a topic’s published messages in real time. To do so, we can use the command rostopic echo. Let’s take a look at the /turtle1/cmd_vel topic.
rostopic echo /turtle1/cmd_vel
If we then command the turtle to move from the turtle_teleop_key window, we will be able to see the output message in real-time!