|
HOWTO: Creating a Static ModelThe are two distinct type of models in Gazebo:
This page describes the basic steps for creating a static model; it describes how the source files should be laid out, how to register models with the server and how to work with GNU Autotools. N.B. These instructions assume you are working from CVS, not a source snap-shot or distribution. For details of how to write the contents of the model, read HOWTO: Creating a Plugin Model. Developers are also advised to read Coding Standards and Conventions before adding their model to the respository (lest I come wading through the source tree with my big red pen). Model Source FilesSource code for models is located underserver/models/ , with a separate directory for each model. Model directory names should match model class names, i.e., the ExampleModel model is found the server/models/ExampleModel/ directory. Layout of files within the model directory is at the developers discretion; by convention, however, models are comprised of a single header file containing the model class declarations, and one or more source files containing the class definitions. Thus, the ExampleModel model is comprised of ExampleModel.hh and ExampleModel.cc .The recommended way to create a new model is to copy an existing model with similar functionality, and perform some judicious search-and-replacing. Registering the ModelModels must be registered with the server. Registration is handled by theModelFactory class, which can be found in server/ModelFactory.cc .Static model registration is handled by a macro defined in ModelFactory.hh:
GZ_REGISTER_STATIC("ExampleModel", ExampleModel) The first argument gives the model name as it appears in the world file; the second argument gives the class name. Note that static and dynamic registration macros can co-exist in the same source file, but only one of them will be used. Working with GNU AutotoolsGazebo uses GNU Autotools to managing the build process; while Autotools can be daunting for newcomers, the rewards are well worth the effort. When using Autotools, there are two key notions to bear in mind:
These configuration files are used to generate the The basic process for adding a new model to the Autotools setup is as follows.
Run |