Create an actor model
- In the user's home directory ~/.gazebo/models/, create a model folder, e.g. animated_box
$ cd ~/.gazebo/models/
$ mkdir -p animated_box/materials/scripts
$ mkdir -p animated_box/materials/textures
- Change directory into the animated_box folder.
$ cd animated_box
- Using a text editor, create a model.config file. Type in the following:
<?xml version="1.0" encoding="utf-8"?> <model> <name>Animated Box</name> <version>1.0</version> <sdf version="1.4">model.sdf</sdf> <description>My animated box</description> </model>
- Using a text editor, create a model.sdf file. Type in the following:
Note: instead of the model tag, use the actor tag.
<?xml version="1.0" encoding="utf-8"?> <sdf version="1.4"> <actor name="animated_box"> <static>false</static> <link name="link"> <visual name="visual"> <geometry> <box> <size>0.2 0.2 0.2</size> </box> </geometry> </visual> </link> <script> <loop>true</loop> <delay_start>0.0</delay_start> <auto_start>true</auto_start> <trajectory id="0" type="square"> <waypoint> <time>0.0</time> <pose>-1 -1 1 0 0 0</pose> </waypoint> <waypoint> <time>1.0</time> <pose>-1 1 1 0 0 0</pose> </waypoint> <waypoint> <time>2.0</time> <pose>1 1 1 0 0 0</pose> </waypoint> <waypoint> <time>3.0</time> <pose>1 -1 1 0 0 0</pose> </waypoint> <waypoint> <time>4.0</time> <pose>-1 -1 1 0 0 0</pose> </waypoint> </trajectory> </script> </actor> </sdf>
- Using a text editor, create a world file, e.g. my_animated_box.world. Type in the following commands:
<?xml version="1.0" ?> <sdf version="1.3"> <world name="default"> <include> <uri>model://sun</uri> </include> <include> <uri>model://ground_plane</uri> </include> <include> <uri>model://animated_box</uri> </include> </world> </sdf>
Note: the previously created animated_box model is included as a model.
- Run the world file.
$ gazebo my_animated_box.world
Gazebo opens and an animated box is shown circling the z axis.