This is an old revision of the document!


2D Simulation

Using simulations is a good way to learn ROS without having to own a physical robot. In this chapter we just use a 2D simulation called Turtlesim.

First, run roscore:

 $ roscore

Run a node named turtlesim_node from the library turtlesim:

 $ rosrun turtlesim turtlesim_node

When the node is run, a simulation with a graphical user interface opens.

The library also contains a node that can be used to send keyboard movement messages to the robot.

Run the robot remote control node in a new terminal window:

 $ rosrun turtlesim turtle_teleop_key

Now by pressing the arrow keys in this terminal, we can move the robot in the simulation:

Rqt_graph

Let's see how it works using the rqt_graph tool, which visualizes the relationships between nodes and themes:

 $ rqt_graph

Launching the command opens a graphical user interface. We see that the /teleop_turtle node reads the arrow keys and turns them into a robot speed geometry_msgs/twist. It is sent to /turtle1/command_velocity, which is listened to by a robot simulation. By running the same nodes on different computers, we can control the robot from another computer. A similar configuration is often used to control real robots.

Command line command

The robot type is controlled by the message type geometry_msgs/twist, which consists of linear and angular velocities. Let's try to speed ourselves from the command line. The TAB key can be used to automatically complete the command. We use the rostopic pub tool argument to r 1, which sends the given message at 1 Hz:

 $ rostopic pub/turtle1/cmd_vel geometry_msgs /Twist -r 1 - '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

We see that the robot moves from a circular motion in the simulation.

Rqt_plot

The rqt_plot tool is used to visualize the subject data over time. With this tool you can display the values ​​of the messages as a graph. This tool can be used, for example, to visualize sensor values. Turtlesim simulator publishes the x and y coordinates of a robot in /turtle1/pose/x and /turtle1/pose/y. Let's try to display these topics on the graph.

Run rqt_plot:

 $ rqt_plot

Adding /turtle1/pose/x and /turtle1/pose/y to the graph shows the real-time position of the robot on the x and y axes:

Sponsored by the IT Academy of Education Information Technology Foundation program
en/ros/turtlesim.1584953635.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0