This tutorial will show you how to use the Gazebo Rendering library to create an actor animation.
Compile and run the example
Clone the source code, Create a build directory and use cmake
and make
to compile the code:
When the code is compiled you can execute the example with the following command. Using the left and right button of the mouse you can move around the scene and zoom in and out.
Code
In this section we will describe the main classes and methods used to create the actor. The basic steps are:
- Load the mesh with animations
- Create the actor visual
- Load the mesh into the render engine
- Attach the mesh to the actor visual
- Animate the skeleton
Create a MeshDescriptor
class with the mesh name of the actor, then using the MeshManager
Singleton class, load the mesh and its animations using the descriptor:
The mesh is now loaded with all animations. You can also add additional animations to the mesh:
Create a Visual
pointer with the scene manager and set the position and rotation of the visual:
Create the mesh in gz-rendering - this loads the animations into the render engine
Finally, attach the mesh to the visual and add the visual to the scene:
There are two ways to play the animations:
- Update animation time: The first method is to advance the time every iteration and let the render engine handle the animations.
- Update bone pose: The second and more involved method is to manually compute and set the bone pose over time.