Tutorials/1.5/build robot/mobile base


 * 1) Tutorial: Make a Mobile Robot#


 * Prerequisites:** Model Database

The tutorial demonstrates Gazebo's basic model management, and exercises familiarity with basic model representation inside the model database by taking the user through 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 Gazebo Model Database directory structure. Also, for details on model description formats, please refer to the SDF 1.3 reference.

1. Create a model directory:

mkdir -p ~/.gazebo/models/my_robot

1. Create a model config file: gedit ~/.gazebo/models/my_robot/model.config

1. Paste in the following contents:

 My Robot 1.0      model.sdf

My Name me@my.email

My awesome robot.

1. Create a `~/.gazebo/models/my_robot/model.sdf` file.

gedit ~/.gazebo/models/my_robot/model.sdf

1. Paste in the following.

  

At this point we have the basic contents for a model. The `model.config` 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.3.


 * 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 `~/.gazebo/models/my_robot/model.sdf` file:

   true

1. Add the rectangular base by editing the `~/.gazebo/models/my_robot/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.

<pre id="no_copy"> <?xml version='1.0'?> <sdf version='1.3'> <model name="my_robot"> true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='visual'> .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

<pre id="no_copy">

Try out your model to make sure the caster appears at the end of the robot. Spawn it in gazebo to see (you don't need to restart Gazebo; it will reload your modified model from disk each time you insert it):



1. Now let's add a left wheel. Modify the `~/.gazebo/models/my_robot/model.sdf` file to be the following:

<pre id="no_copy"> <?xml version='1.0'?> <sdf version='1.3'> <model name="my_robot"> true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='visual'> .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

<pre id="no_copy">

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:

<pre id="no_copy"> <?xml version='1.0'?> <sdf version='1.3'> <model name="my_robot"> true <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='visual'> .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

<pre id="no_copy">

At this point the robot should have a chassis with a caster and two wheels.



1. Make the model dynamic by setting ` ` to false, and add two hinge joints for the left and right wheels.

<pre id="no_copy"> <?xml version='1.0'?> <sdf version='1.3'> <model name="my_robot"> false <pre id="no_copy"> <link name='chassis'> 0 0 .1 0 0 0          <collision name='collision'> .4 .2 .1

<visual name='visual'> .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

<pre id="no_copy">

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. Click on the three white rectangles to the right of the screen and drag them to the left. 1. A new window should appear that contains various controllers for each joint. (Note Make sure the model you want to control is selected) 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.


 * 1) Try for yourself ##

1. Be creative and make a new robot.

Idea: A quadruped that consists of torso with four cylindrical legs. Each leg is attached to the torso with a revolute joint.

Idea: A six wheeled vehicle with a scoop front loading mechanism.

Next: Attach Meshes
 * 1) Next ##