GPU Accelerated Human Actor in Gazebo Simulation

Gazebo is a very powerful robotics simulation tool. Recently in the release 8 branch (under development), a human actor model is added. This makes simulation of human interacting robots possible. I tried to use it to simulate quadcopter guided crowd evacuation in a research project. However, I found the animation is very slow for large crowd. After digging into code and going through the skeleton animation example code in Ogre3d, I was able to improve large crowd animation dramatically with a technique called Hardware Skinning.

 

The original Actor model design looks roughly like what is shown in picture below.

actor_original

In this design, to animate each Actor in the scene, the poses (position and rotation angles) of each bone in the skeleton are calculated on the server side, then updated to the client side one by one. The client side then uses the bone poses to transform the mesh vertices. Although the final rendering of the transformed mesh with textures is done on the GPU, this design causes significant communication overhead for large crowds. In addition, it slows down other parts of simulation because all bone pose calculations are done by the CPU. As a result, the overall simulation performance is not satisfactory. I was only able to get 10 FPS for 16 Actors for real time simulation (1:1 ratio of simulation time to real time).

 

My first attempt to improve the design was to remove the communication overhead. To do that, I rewrote the Actor implementation on the server side to just send the Actor pose (output from Menge simulation) at each time step to the client side. The client side was also modified to directly use the Ogre3d library functions to update the individual bone poses based on the actor’s pose and simulation time, “software skinning” in Ogre3d terms. With this improvement, we could simulate up to 64 actors at real-time speed and interactive frame rate. The design shown in picture below:

actor_hw

 

Then to further improve the performance, I implemented “hardware skinning” in which all the animation related calculations are done on GPU. This design, shown in Figure below, utilizes the GPU vertex shader to offload vertex transformation calculations from CPU. The gzclient code on CPU then only controls the frame of the bone animation data to be used at a particular iteration (simulation time step). This greatly improves the performance, and allowed up to 625 characters to be rendered in real time simulations. The shader program is written in Cg language, similar to the hardwareSkinningFourWeights_vp in Ogre3D sample code, only slightly modified to handle more bones.

actor_hw

 

Below is a screen shot with 625 actors and the FPS measured at a value of 13 by Gazebo GUI. I used the actor meshes and textures from another project called OgreCrowd.

screenshot_hw_skin_625_02

The code changes in Gazebo and related SDFormat library are published in my bitbucket account:

https://bitbucket.org/michaelhuang16/gazebo

https://bitbucket.org/michaelhuang16/sdformat2