Tutorials/build robot/mobile base 1.2.0


 * Prerequisites:** Model Database

This tutorial describes the process of creating a two wheeled mobile robot that uses a differential drive mechanism for movement.


 * 1) Setup your model directory

Read through the Model Database documentation. You will be creating your own model, which must follow the formatting rules for the model database.

1. Create a model directory:

cd ~/.gazebo mkdir -p models/my_robot cd models/my_robot

1. Create a `manifest.xml` file with the following contents:



My Robot 1.0          model.sdf

My Name me@my.email

My awesome robot.

1. Create a `model.sdf` file with the following contents:

  

At this point we have the basic contents for a model. The `manifest.xml` file describes the robot with some extra meta data. The `model.sdf` file contains the necessary tags to instantiate a model named `my_robot` using Gazebo linked against SDF version 1.2.


 * 1) Build the Model's Structure

This step will create a rectangular base with two wheels.

It is important to start simple, and build up a model in steps. The first step is to layout the basic shapes of the model. To do this we will make our model `static`, which means it will be ignored by the physics engine. As a result the model will stay in one place and allow us to properly align all the components.

1. Make the model static by adding a ` true ` element to the `model.sdf` file:

   true

1. Add the rectangular base by editing the `model.sdf` file:

   true  0 0 .1 0 0 0               .4 .2 .1

 .4 .2 .1

Here we have created a `box` with a size of `0.4 x 0.2 x 0.1` meters. The `collision` element specifies the shape used by the collision detection engine. The `visual` element specifies the shape used by the rendering engine. For most use cases the `collision` and `visual` elements are the same. The most common use for different `collision` and `visual` elements is to have a simplified `collision` element paired with a `visual` element that uses a complex mesh. This will help improve performance.

1. Try out your model by running gazebo, and importing your model through the Insert Model interface on the GUI.

gazebo

You should see a white box floating .1 meters above the ground plane. 1. Now we can add a caster to the robot. The caster is a sphere with no friction. This kind of caster is better than adding a wheel with a joint since it places fewer constraints on the physics engine.

~    true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='collision'> .4 .2 .1

<collision name='caster_collision'> -0.15 0 -0.05 0 0 0              .05

<mu>0</mu> 0                1.0                 1.0

<visual name='caster_visual'> -0.15 0 -0.05 0 0 0              .05   ~

Try out your model to make sure the caster appears at the end of the robot. 1. Now let's add a left wheel. Modify the `model.sdf` file to be the following:

~ <?xml version='1.0'?> <gazebo version='1.2'> <model name="my_robot"> true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='collision'> .4 .2 .1

<collision name='caster_collision'> -0.15 0 -0.05 0 0 0              .05

<mu>0</mu> 0                1.0                 1.0

<visual name='caster_visual'> -0.15 0 -0.05 0 0 0              .05       <link name="left_wheel"> 0.1 0.13 0.1 0 1.5707 1.5707              .1               .05               .1               .05   ~

Run Gazebo, insert your robot model and make sure the wheel has appeared and is in the correct location. 1. We can make a right wheel by copying the left wheel, and adjusting the wheel link's pose: ~ <?xml version='1.0'?> <gazebo version='1.2'> <model name="my_robot"> true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='collision'> .4 .2 .1

<collision name='caster_collision'> -0.15 0 -0.05 0 0 0              .05

<mu>0</mu> 0                1.0                 1.0

<visual name='caster_visual'> -0.15 0 -0.05 0 0 0              .05       <link name="left_wheel"> 0.1 0.13 0.1 0 1.5707 1.5707              .1               .05               .1               .05

<link name="right_wheel"> 0.1 -0.13 0.1 0 1.5707 1.5707              .1               .05               .1               .05   ~

At this point the robot should have a chassis with a caster and two wheels. Now let's add the joints, and remove the ` ` tag. 1. Make the model dynamic and add two hinge joints for the left and right wheels. ~ <?xml version='1.0'?> <gazebo version='1.2'> <model name="my_robot"> <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='collision'> .4 .2 .1

<collision name='caster_collision'> -0.15 0 -0.05 0 0 0              .05

<mu>0</mu> 0                1.0                 1.0

<visual name='caster_visual'> -0.15 0 -0.05 0 0 0              .05       <link name="left_wheel"> 0.1 0.13 0.1 0 1.5707 1.5707              .1               .05               .1               .05

<link name="right_wheel"> 0.1 -0.13 0.1 0 1.5707 1.5707              .1               .05               .1               .05       <joint type="revolute" name="left_wheel_hinge"> 0 0 -0.03 0 0 0        left_wheel chassis 0 1 0

<joint type="revolute" name="right_wheel_hinge"> 0 0 0.03 0 0 0        right_wheel chassis 0 1 0

~ The two joints rotate about the y axis ` 0 1 0 `, and connect each wheel to the chassis. 1. Start gazebo, and insert your model. Right-click on the model and select `Control Joints`. 1. A new window should appear that contains various controllers for each joint. 1. Under the `Force` tab, increase the force applied to each joint to about 0.1N-m. The robot should move around. 1. Congrats, you now have a basic mobile robot.

Next: Adding a Laser to your mobile robot.