Time for the first tutorial in ROS. We'll be using a prebuilt package called turtlesim for this tutorial. It's okay if you don't understand it all on the first run, just get the gist of what's happening. Perform the following steps and note the outputs carefully
Open the terminal (Ctrl + Alt + T) and start the ROS server. Type in the following commands into the terminal and press Enter after every command to execute it:
roscore
Run the node for turtlesim graphics window. This will spawn up the turtle in a window. Type in the following commands into different terminal and press Enter after every command to execute it:
rosrun turtlesim turtlesim_node
rosnode list
Run a node to make the turtle go in rectangles (it draws rectangles on the screen). Type the following in a terminal and check the output on the screen:
rosrun turtlesim draw_square
rostopic list
Now, let's control the turtle using our keyboard. Type the following into different terminals (I'd suggest you don't use different tabs here) and press enter after every command:
rostopic echo /turtle1/cmd_vel
rosrun turtlesim turtle_teleop_key
Great. Now you can try playing around a bit more with the command line tools. I'd suggest that you do the following
rqt_graph
on a terminal and see the graph madeThis shows the communication between different nodes. It basically shows the network structure of the ROS system. We'll learn more about this in later tutorials.
This is the computation graph that ROS makes. There are three nodes: one handling the turtle GUI ("/turtlesim"), one for the keyboard controller ("/teleop_turtle") and another is for the rostopic echo /turtle1/cmd_vel
command we had previously ("/rostopic_2670_...", you might have something else, such numbers are assigned randomly).
Call a service to spawn another turtle on the same figure, move it and then kill it:
rosservice list
rosservice call /clear
rosservice info /spawn
rosservice call /spawn "x: 2.0 y: 2.0 theta: 1.0 name: 'turtle2'"
rostopic list
rostopic pub /turtle2/cmd_vel geometry_msgs/Twist "linear: x: 2.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0"
rostopic pub /turtle2/cmd_vel geometry_msgs/Twist "linear: x: 0.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: -2.0"
rostopic pub /turtle2/cmd_vel geometry_msgs/Twist "linear: x: 2.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0"
rosservice call /kill "name: 'turtle2'"
Spawned the blue turtle
Path the turtle makes
Yay, we've completed the first tutorial