This tutorial shows how to create a simple single body model and how to spawn it in the Gazebo simulator.
For this tutorial, you just need to be aware of:
- What the Gazebo simulator is
- Optionally run CMake
- How to create a Gazebo model from a mesh of a given object.
- How to install a Gazebo model in way that it can be found automatically by Gazebo.
- Gazebo : Tutorial : Quick Start
- Gazebo : Tutorial : Gazebo Components
- Gazebo : Tutorial : Make a Model
- Gazebo : Tutorial : Building a World
- Specifying pose in SDFormat
Follow these steps to build and properly install your module:
$ cd tutorial_gazebo-simple-model
$ mkdir build; cd build
$ cmake ../
# make is not necessary as this project does not compile anything
$ make install
the make install
will install your model and related files in the icub contrib folder which is already setup on your machine.
The repo contains the following files:
CMakeLists.txt
: The file that describes where the files contained in the are installed bymake install
.gazebo/models/simple_object/model.config
: A file containing metadata related to thesimple_object
model.gazebo/models/simple_object/simple_object.sdf
: A sdf file describing the model of thesimple_object
.gazebo/models/simple_object/simple_object.stl
: A stl file describing the shape of thesimple_object
.gazebo/worlds/simple_object_world.sdf
: A sdf file describing the world that contains thesimple_object
model.
To understand the role of each file, please open the files and see the internal comments, except for the .stl
file that is
a binary format and not a textual one.
After you installed the repository, open Gazebo by running the gazebo
command in the terminal:
gazebo
In the list of models in the panel on the left, you can find the simple_object
model, drag it in the GUI to spawn an instance of it in the simulation.
You can also run directly a simulation from a world file that contains all the models that needs to be simulated, by running gazebo from the terminal followed by the name of the world file:
gazebo simple_object_world.sdf
To launch a simulation from the yarpmanager, it is usually convenient to separate the launch
of the physics simulation program (gzserver
) and the GUI client (gzclient
). In this case,
you need to pass the name of the world to the gzserver
command:
gzserver simple_object_world.sdf
while the gzclient
can be run directly:
gzclient
In the context of this tutorial, you don't need to worry about how Gazebo is able to find the models
and the world installed by the make install
.
However, in general, to be found models directories should be installed in the directories listed in the
GAZEBO_MODEL_PATH
enviroment variable and world files in the directories listed in GAZEBO_RESOURCE_PATH
.
For more details on how models and world files are found in general in Gazebo, please check the Gazebo : Tutorial : Gazebo Components.
If you want to add a new simple single body model to this tutorial, you can proceed as follows:
- Copy the content of the
gazebo/models/simple_object
directory in a new directory, for examplegazebo/models/new_simple_object
- Update the
gazebo/models/new_simple_object/model.config
//model/name
content fromsimple_object
tonew_simple_object
, and//model/sdf
fromsimple_object.sdf
tonew_simple_object.sdf
. - Rename the
gazebo/models/new_simple_object/simple_object.sdf
togazebo/models/new_simple_object/new_simple_object.sdf
. In that file, update the//sdf/model@name
attribute fromsimple_object
tonew_simple_object
. If necessary, update the inertia values, but if the//sdf/model/static
value remains set to false, you can just ignore the inertia parameters. - Get a STL mesh for your object, and save it as
gazebo/models/new_simple_object/new_simple_object.stl
, and update theuri
values in thegazebo/models/new_simple_object/mew_simple_object.sdf
to point to the new mesh files. - If necessary, add a new world that uses the new model in
gazebo/worlds
.