TurtleBot's odometry

In this section, we explore the TurtleBot's odometry. The general definition of odometry is the use of data from motion sensors to estimate change in position over time. Odometry is used by the TurtleBot to estimate its position and orientation relative to a starting location given in terms of an x and y position and an orientation around the z (upward) axis. The topic is /odom and the command to view the form of the /odom message is as follows:

$ rostopic echo /odom

When you execute this echo command, the output will be updated continuously on the screen. However, we wish to display TurtleBot's motion using rviz. When the odometry option is chosen in rviz, the TurtleBot's position and orientation will be displayed with arrows that are generated as TurtleBot moves.

Odom for the simulated TurtleBot

The simulated TurtleBot will be used to demonstrate the odometry display possible in rviz.

Note

To run Gazebo on your remote computer, you must reassign the ROS Master if it is assigned to the TurtleBot in the .bashrc file. In each terminal window you open, type the following command:

$ export ROS_MASTER_URI=http://localhost:11311

The commands executed on the remote computer to start Gazebo for simulation and rviz for visualization are as follows:

$ roslaunch turtlebot_gazebo turtlebot_world.launch

In another terminal window, run this command:

$ roslaunch turtlebot_rviz_launchers view_robot.launch

Gazebo includes the physics of the robot and rviz allows a variety of visualization options. In particular, it is useful to show the pose of the robot as indicated by arrows that point in the direction of motion of the TurtleBot on the screen.

In rviz, it is necessary to choose several options to show the TurtleBot's odometry arrows on the screen. As shown in the following screenshot, we choose the following:

  1. Under Global Options on the left side panel for Fixed Frame, change base_link or base_footprint to odom.
  2. Click on Add, and select the By topic tab shown.
  3. Choose Odometry and click on OK.
  4. On the left side panel, click on the small arrow to the left of Odometry to show the various options. The topic is odom and the screen will keep 100 arrows that point to the direction of the simulated TurtleBot as it moves:
    Odom for the simulated TurtleBot

    Selection of the odom topic in rviz showing a list of topics

  5. Once these selections are made, the simulated TurtleBot will appear on the screen with an arrow pointing in its forward direction, as shown in the following screenshot:
    Odom for the simulated TurtleBot

    Rviz showing odom arrow for initial position of simulated TurtleBot

To track the motion of the simulated TurtleBot on the screen and display the arrows, we issue a movement command. Once the two screens are up for Gazebo and rviz, any commands to move the robot are possible, including the execution of a Python script. For example, in a third terminal window, issue one of the following commands to make the TurtleBot move in a circle on the screen:

$ rostopic pub -r 10 /cmd_vel_mux/input/teleop geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}'
$ rostopic pub -r 10 /mobile_base/commands/velocity geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}'

The result is the same in terms of the movement of the robot in our examples, but the /mobile_base/commands/velocity topic is used to control the mobile base as explained in the Kobuki tutorial at: http://wiki.ros.org/kobuki/Tutorials/Kobuki's%20Control%20System.

The /cmd_vel_mux variable is used to multiplex velocity commands from different sources, such as the keyboard or a Python script. Either commands make the TurtleBot move in a circle with the result shown in the following screenshot:

Odom for the simulated TurtleBot

Simulated TurtleBot moving in a circle with the direction shown in rviz

Real TurtleBot's odometry display in rviz

The commands used in simulation can be used with the physical TurtleBot. After bringing up the real TurtleBot with the minimal launch, start rviz on the remote computer:

$ roslaunch turtlebot_rviz_launchers view_robot.launch

TurtleBot will appear in rviz, as shown in the following screenshot:

Real TurtleBot's odometry display in rviz

TurtleBot on rviz bringup

Then, set up rviz with odom for Fixed Frame and navigate to Add | By topic | Odometry, as was done with the simulated TurtleBot.

Run the following command to move TurtleBot in a circle:

$ rostopic pub -r 10 /mobile_base/commands/velocity geometry_msgs/Twist '{linear: {x: 0.1, y: 0, z: 0}, angular: {x: 0, y: 0, z: -0.5}}'

Stop the TurtleBot by pressing Ctrl + C with focus on the window in which you executed the command to move the robot.

In the following screenshot, TurtleBot's turning was stopped by pressing Ctrl + C, and the Python script was executed that drives TurtleBot straight forward until the Ctrl + C keys are pressed again.

The command is as follows:

$ python ControlTurtleBot.py
Real TurtleBot's odometry display in rviz

TurtleBot's path after the Twist message and running of the Python script

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset