Skip to content

Tutorial on how to spawn a single body model in Gazebo.

Notifications You must be signed in to change notification settings

vvv-school/tutorial_gazebo-simple-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tutorial_gazebo-simple-model

This tutorial shows how to create a simple single body model and how to spawn it in the Gazebo simulator.

Gitpod

Prerequisites

For this tutorial, you just need to be aware of:

You will see how to:

  • 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.

Related docs

Build and Install the code

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.

Contents

The repo contains the following files:

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.

Use the installed models

Spawn from GUI

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.

Spawn from a world file

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

Spawn from a world file in yarpmanager

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

How Gazebo find models and world files

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.

How to add a new model

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 example gazebo/models/new_simple_object
  • Update the gazebo/models/new_simple_object/model.config //model/name content from simple_object to new_simple_object, and //model/sdf from simple_object.sdf to new_simple_object.sdf.
  • Rename the gazebo/models/new_simple_object/simple_object.sdf to gazebo/models/new_simple_object/new_simple_object.sdf. In that file, update the //sdf/model@name attribute from simple_object to new_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 the uri values in the gazebo/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.

About

Tutorial on how to spawn a single body model in Gazebo.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages