A guide to create animated human models for Gazebo using MakeHuman and Blender

Import animated human model in Gazebo

Hi there, Welcome back!

Finally, we are on our last step to render the animated models in Gazebo simulator. Note that the animated models in gazebo are called actors. If interested in learning more, see this tutorial for a gentle introduction to actors in Gazebo.

If you are not familiar with Gazebo, I would also suggest reading the tutorials related to creating importing and attaching meshes to a model.

Let’s get to work now. . .

For importing actors in Gazebo, we will create a simple world file. In order to ensure that we can see the colors of clothes in Gazebo, it is very important that the world file contains a light source. Otherwise, the actors may look completely dark. This is where I struggled until I found the details here.

  1. Before we dive into creating a test world file, make sure that you are following a folder hierarchy suggested by Gazebo. See example below. If not already done so, adjust the folder hierarchy. So, we have a main folder for the project, within which we will create 2 folders (materials and meshes). We must put the texture folder into a folder called materials. And the COLLADA (.dae) file that was exported from Blender must be within the meshes folder.

Ignore the model.config and model.sdf references below for now.

Figure 8: Example of a folder structure for Gazebo

2. Next, create a simple .world file that we will use to test the animated model we created in MakeHuman and Blender. This .world file is added to the main project folder that already contains materials and meshes folder.

<?xml version="1.0"?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://ground_plane</uri>
    </include>
    
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.25 0.25 0.25 1</background>
      <shadows>false</shadows>
    </scene>
    <light type="directional" name="some_light">
      <diffuse>0.7 0.7 0.7 0</diffuse>
      <specular>1 1 1 0</specular>
      <direction>-1 -1 -1</direction>
    </light>
    
    <actor name="Conv_SubA">
      <skin>
      <filename>/home/prabhjot/Desktop/MK_Blender_Gazebo/Conv_SubA_18_8/meshes/HumanA_18_8_blenderexport.dae</filename>
      </skin>
    </actor>
  </world>
</sdf>

This world file has 2 parts. Firstly, it defines the light source and secondly, it loads an actor from the .dae file that was created in Blender. It is very important to pay close attention to the path of the file under filename. The .world file is saved in the main folder. See below.

The world file will not work just yet, there is one more thing that needs to be taken care of.

Figure 9: Folder Hierarchy

3. Make sure the paths for textures given in <library_images> are relative to the COLLADA file. See <init_from> …………….. /init_from>.

Figure 10: Adjust the filepath of the texture files relative to the .dae file.

To do so, open the COLLADA file in your favorite text editor and make sure the filepaths for the .png files under the tag ‘library_images’ is correct. It must be a path relative to where the .dae file. See example above for the folder structure shown in Figure 9.

4. Next, launch the test world file. To do so, simply, navigate to the folder where the .world file is saved and type gazebo nameOfTheWorldFine.world

~/Desktop/MK_Blender_Gazebo/Conv_SubA_18_8$ gazebo test_actor_ConvSubA.world

That is it!

If everything went fine, you will see an animated human model in Gazebo. Below is an example of my model.

Video in Gazebo

Additional Details

Further, if you want to have more than one actor in the scene, that is possible too. See video below.

The corresponding world file for the scene above is shown below.

<?xml version="1.0"?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://ground_plane</uri>
    </include>
    
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.25 0.25 0.25 1</background>
      <shadows>false</shadows>
    </scene>
    <light type="directional" name="some_light">
      <diffuse>0.7 0.7 0.7 0</diffuse>
      <specular>1 1 1 0</specular>
      <direction>-1 -1 -1</direction>
    </light>
    
    <actor name="Conv_SubB">
      <skin>
      <filename>/home/prabhjot/Desktop/MK_Blender_Gazebo/Conv_SubB_19_8/meshes/HumanB_19_8_blenderexport.dae</filename>
      </skin>
    </actor>
    
    <actor name="Conv_SubA">
      <skin>
      <filename>/home/prabhjot/Desktop/MK_Blender_Gazebo/Conv_SubA_18_8/meshes/HumanA_18_8_blenderexport.dae</filename>
      </skin>
    </actor>
    
  </world>
</sdf>

Summary

In this tutorial, we learned how to create animated human models from scratch. Firstly, a static human model is created in MakeHuman, which is exported as .mhx2 into Blender. Within Blender, we attach the motion capture files to the static human model and export the animated file as .dae. Finally, a test .world file is created in for launching in Gazebo.

PS: Pay close attention on details such as when exporting from Belnder, export with texture (Figure ). Also, when preparing for launching animated model in Gazebo, be careful with the file paths. These are the source of errors or at least were for me.

I hope you enjoyed the tutorial!

References

  1. (Tutorial for creating a model in MakeHuman and exporting it/Importing into Blender/Adding motion capture files) https://www.youtube.com/watch?v=dFLPjVWjmCY
  2. (Tutorial for exporting from Blender and Importing into Gazebo) https://www.youtube.com/watch?v=7kEmT-NE75c&t=7s
  3. (Downloading and Installing Mhx2 plugin) https://bitbucket.org/Diffeomorphic/mhx2-makehuman-exchange/src/master/
  4. (Gazebo tutorial on adding color and texture to a Model) http://gazebosim.org/tutorials?tut=color_model#Ambient
  5. (Gazebo tutorial on creating an animated actor) http://gazebosim.org/tutorials?tut=actor&cat=build_robot
  6. (Gazebo tutorial on importing meshes) http://gazebosim.org/tutorials?tut=import_mesh
  7. (Gazebo tutorial on attaching meshes for visual element tag) http://gazebosim.org/tutorials/?tut=attach_meshes
  8. (Collada detailed tutorial) http://wazim.com/collada-tutorial1/
  9. https://answers.gazebosim.org//question/23398/exporting-model-and-textures-from-blender/
  10. https://answers.gazebosim.org/question/6601/settings-for-exporting-collada-dae-from-blender-scene-specifically-human-actors/

Leave a Reply

Your email address will not be published. Required fields are marked *