(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Moving the Base

Description: This tutorial will show you how to move the robot base.

Tutorial Level: BEGINNER

Next Tutorial: Pointing the Head

Moving the Base via Teleop

The easiest way to move the robot around is using the teleop_twist_keyboard program. CTRL-SHIFT-T will again open another tab in your terminal, in which you can type:

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

You will then be able to drive the robot around using the keyboard. Note that you have to hold down the keys to have messages sent continuously, otherwise the robot stops (this is a safety feature).

Moving the Base with Your Own Code

The tele-operation node wasn't magic. In fact, if you leave it running, you could run rxgraph and see that the teleop_twist_keyboard node is publishing to a topic called cmd_vel, to which the iRobot Create node is subscribing. We can of course publish our own commands to cmd_vel. The remainder of this tutorial will walk through doing this.

Understanding cmd_vel

The cmd_vel message is of type geometry_msgs/Twist. The expanded definition looks like:

Vector3 linear
    float64 x
    float64 y
    float64 z
Vector3 angular
    float64 x
    float64 y
    float64 z

However, our robot can't drive sideways (linear.y), or rotate about the x-axis! Therefore, we will only be using linear.x and angular.z to control our robot.

Moving Forward for 3 Seconds

Our first example will move the robot forward for 3 seconds:

Could not fetch external code from 'https://vanadium-ros-pkg.googlecode.com/svn/trunk/mini_max/mini_max_tutorials/nodes/move.py': HTTP Error 404: Not Found

Here we create a twist message, fill in the forward velocity, and publish it. As long as Mini Maxwell is running, he should move forward (slowly) for about 3 seconds. The second twist message contains all 0 velocities, and thus stops the robot. By convention, in ROS, all linear velocities are given in meters per second, and rotations in radians per second.

Drawing a Square Until Shutdown

We'll now try a more complex example, which involves multiple moves, turning, and cleaning up on shutdown.

Could not fetch external code from 'https://vanadium-ros-pkg.googlecode.com/svn/trunk/mini_max/mini_max_tutorials/nodes/square.py': HTTP Error 404: Not Found

As before, we create Twist messages and publish them. This example uses a Python class, which is a good idea for easily storing publishers which may be used again.

A More Accurate Square Using TF (Advanced)

Wiki: mini_max/Tutorials/Moving the Base (last edited 2011-09-08 08:10:40 by MichaelFerguson)