The basic’s of Gazebo include understanding how to build models and worlds in Gazebo.

Table of Contents

Creating a Model

  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:
<?xml version="1.0"?>
<model>
        <name>My Robot</name>
        <version>1.0</version>
        <sdf version='1.4'>model.sdf</sdf>

        <author>
                <name>My Name</name>
                <email>[email protected]</email>
        </author>

        <description>
                My awesome robot.
        </description>
</model>
  1. Create a ~/.gazebo/models/my_robot/model.sdf file.
gedit ~/.gazebo/models/my_robot/model.sdf
  1. Paste in the following example models of a simple two wheeled robot
<?xml version='1.0'?>
<sdf version='1.4'>
					<model name="my_robot">
	        <!-- making the model dynamic -->
            <static>false</static>

            <!-- adding the rectangular base -->
            <link name='chassis'>
                    <pose>0 0 .1 0 0 0</pose>
                    <collision name='collision'>
                            <geometry>
                                    <box>
                                            <size>.4 .2 .1</size>
                                    </box>
                            </geometry>
                    </collision>
                    <visual name='visual'>
                            <geometry>
                                    <box>
                                            <size>.4 .2 .1</size>
                                    </box>
                            </geometry>
                    </visual>

                    <!-- adding sphere -->
                    <collision name='caster_collision'>
                            <pose>-0.15 0 -0.05 0 0 0</pose>
                            <geometry>
                                    <sphere>
                                            <radius>.05</radius>
                                    </sphere>
                            </geometry>
                            <surface>
                                    <friction>
                                            <ode>
                                                    <mu>0</mu>
                                                    <mu2>0</mu2>
                                                    <slip1>1.0</slip1>
                                                    <slip2>1.0</slip2>
                                            </ode>
                                    </friction>
                            </surface>
                    </collision>
            <visual name='caster_visual'>
                    <pose>-0.15 0 -0.05 0 0 0</pose>
                    <geometry>
                            <sphere>
                                    <radius>.05</radius>
                            </sphere>
                    </geometry>
            </visual>
            </link>

            <!-- left wheel -->
            <link name="left_wheel">
                    <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
                    <collision name="collision">
                            <geometry>
                                    <cylinder>
                                            <radius>.1</radius>
                                            <length>.05</length>
                                    </cylinder>
                            </geometry>
                    </collision>
                    <visual name="visual">
                            <geometry>
                                    <cylinder>
                                            <radius>.1</radius>
                                            <length>.05</length>
                                    </cylinder>
                            </geometry>
                    </visual>
            </link>

            <!-- right wheel -->
            <link name="right_wheel">
                    <pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
                    <collision name="collision">
                            <geometry>
                                    <cylinder>
                                            <radius>.1</radius>
                                            <length>.05</length>
                                    </cylinder>
                            </geometry>
                    </collision>
                    <visual name="visual">
                            <geometry>
                                    <cylinder>
                                            <radius>.1</radius>
                                            <length>.05</length>
                                    </cylinder>
                            </geometry>
                    </visual>
            </link>

            <!-- joints connecting wheels to body-->
            <joint type="revolute" name="left_wheel_hinge">
                    <pose>0 0 -0.03 0 0 0</pose>
                    <child>left_wheel</child>
                    <parent>chassis</parent>
                    <axis>
                            <xyz>0 1 0</xyz>
                    </axis>
            </joint>

            <joint type="revolute" name="right_wheel_hinge">
                    <pose>0 0 0.03 0 0 0</pose>
                    <child>right_wheel</child>
                    <parent>chassis</parent>
                    <axis>
                            <xyz>0 1 0</xyz>
                    </axis>
            </joint>

    </model>

</sdf>
  1. Run gazebo
gazebo
  1. On the left menu bar, navigate to Insert/My Robot, and then place you’re robot in you’re gazebo world.
  2. Navigate the gazebo environment with holding left click for adjusting view, and scrolling on the mouse wheel for zoom.
  3. Click on the dots to the right of the screen and drag them to the left. Under ‘Force’ tab, increase force applied to each joint to about 0.1N-m

gazeboSim1.mp4