Skip to content
Tiago Trocoli edited this page Dec 21, 2017 · 13 revisions

Welcome to the simulation-uwmodels wiki!

In these wiki, we will show how to add OSG objects in the underwater scene, and how to configure, position and modify model properties to get differents behaviors on sonar simulator.

The tutorial was developed on UBUNTU 16.04.

Before start the tutorial is needed install:

  1. Full Sonar Simulation | TODO: command to install simulation
  2. Blender 3D editor | apt install blender

Installed the tools previously, now you are ready to to create your owner object. First, we will make a simple OSG object. Second, we will add the object in the underwater scene, set position and direction in world file. The last step we will add some material properties to the object.

1. Create a SDF Content

To start, we will create the folder that will contain all object data.

  1. Go into folder that ran sonar_simulation-buildconf and execute on terminal:

$ cd simulation/uwmodels/sdf

  1. The folder sdf must contain a folder with the object name. Here we will create a folder called monkey.

$ mkdir monkey

  1. In monkey folder we will create two files: model.config and model.sdf. The model.config file has information about the author, object name, sdf version and object description. The model.sdf has the geometric and physic information about the object, like the geometric mesh, collision mesh, inertia, mass etc. To create these files should execute the follow commands:
$ cd monkey
$ touch model.config model.sdf
  1. Now, we need to edit the files and this task can be done with any editor. It is just necessary fill with the follow content :
  • model.config
 <?xml version="1.0"?>
 <model>
   <name>monkey</name>
   <version>1.0</version>
   <sdf version='1.4'>model.sdf</sdf>

   <author>
     <name>Tiago Trocoli</name>
     <email>trocolit2@gmail.com</email>
   </author>

   <description>
     Monkey head
   </description>
 </model>
  • model.sdf
<?xml version="1.0"?>
<sdf version="1.4">
    <model name="monkey">
        <pose>0 0 0 0 0 0</pose>
        <static>true</static>
        <link name="monkey_body">
            <visual name="visual">
                <geometry>
                    <mesh>
                        <uri>model://monkey/visual.osgb</uri>
                    </mesh>
                </geometry>
            </visual>
            <collision name="collision">
                <geometry>
                    <mesh>
                        <uri>model://monkey/collision.stl</uri>
                    </mesh>
                </geometry>
            </collision>
            <inertial>
                <pose>0 0 -1 0 0 0</pose>
                <inertia>
                    <ixx>0.0</ixx>
                    <ixy>0</ixy>
                    <ixz>0.0</ixz>
                    <iyy>0.0</iyy>
                    <iyz>0</iyz>
                    <izz>0.0</izz>
                </inertia>
                <mass>1.0</mass>
            </inertial>
        </link>
    </model>
</sdf>

2. Create OSG model

Once we create all the needed files to the simulation to detect the model, it is time to create the meshes. We will create a simple mesh with open source Blender editor.

  1. Open Blender editor, and remove the initial objects (light, camera and cube). TODO -> ADD IMAGE blender_000.png

  2. Go to bottom bar, press Add -> Mesh -> Monkey. TODO -> ADD IMAGE blender_001.png

  3. Press n to show object location and scale edit menu. Select the monkey head, after set location X,Y,Z -> 0,0,0, and the scale to 2 in XYZ dimensions. TODO -> ADD IMAGE blender_002.png

  4. Save the blender project in monkey folder. Export the model as obj file and give the name visual.obj. And then export the model as stl file and give the name collision.stl. TODO -> ADD IMAGE blender_003.png

  5. We will convert the obj file to osg. Come back to terminal and go to monkey folder. Run the follow command:

$ osgconv visual.obj visual.osgb

Next, run the command to open visual.osgb in OSG viewer, and you must see a white monkey head:

$ osgviewer visual.osgb

3. Add object in world file

Finished the process to create the model, it is required fill a file which contain the pose about each object in the scene. To assemble the scene, every object must to be setted at the world file. Here we will set two monkey models.

  1. The world file can be found in folder uwmodels\scenes\scenes. So we need to go to this folder:
$ cd ../../scenes/
  1. To do not change the original scene we will make a new scene. We need to create a folder that will contain the world file, and them need to have the same name, here called as test.
$ mkdir test
$ cd test
$ touch test.world
  1. To create a new scene, it is required fill the test.world file with object poses. In follow lines is showed how the test.world file should be filled, and to do the task you can use any text editor.
<?xml version="1.0" ?>
<sdf version="1.6">
    <world name="test">

        <!-- Include the seafloor  -->
        <include>
            <uri>model://seafloor</uri>
            <name>seafloor</name>
            <!-- pose X Y Z R_X R_Y R_Z
             | X Y Z -> world coordinates
             | R_X R_Y R_Z -> rotation around axis in radian -->
            <pose>0 0 -12.3 0 0 0</pose>
        </include>

        <!-- Include the monkey model as monkey_01 -->
        <include>
            <uri>model://monkey</uri>
            <name>monkey_01</name>
            <pose>0 2 -10 0 0 0</pose>
        </include>

        <!-- Include the monkey model as monkey_02 -->
        <include>
            <uri>model://monkey</uri>
            <name>monkey_02</name>
            <pose>0 -2 -10 0 0 0</pose>
        </include>

    </world>
</sdf>
  1. Run the simulation with the new scene:

TODO -> include simulation command

4. Add propertie