Gazebo | Ignition | Community
Ask Your Question
0

How to create a model(.sdf) file that can be inserted at will in Gazebo?

asked 2020-06-06 03:08:14 -0500

pumpkin gravatar image

Hello there,

Im trying to import some model from 3dwarehouse, and I have created a .world file following this. But now,I realized if I want to insert this model to other world, I must convert it to a .sdf file which I have failed so many times. Can anyone help me? This is my .world file:

<?xml version="1.0"?>
<sdf version="1.4">
  <world name="default">
    <include>
      <uri>model://sun</uri>
    </include>
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <model name="clock">
      <pose>0 0 0.49  0 1.57079 0</pose>
      <static>true</static>
      <link name="up">
        <visual name="visual">
          <geometry>
            <mesh><uri>model://clock/model.dae</uri></mesh>
          </geometry>
        </visual>
      </link>
    </model>
  </world>
</sdf>

And I have created the model.sdf, model.config and other files, but it still doesnt work.

├── materials
│   ├── scripts
│   │   └── clock.materials
│   └── textures
│       └── material_22.png
├── meshes
│   └── model.dae
├── model.config
└── model.sdf

The .sdf file:

<?xml version='1.0'?>
<sdf version='1.6'>
  <model name='clock'>
    <link name='up'>
      <pose frame=''>0 0 0 0 -0 0</pose>
      <self_collide>0</self_collide>
      <kinematic>0</kinematic>
      <visual name='visual'>
        <geometry>
          <mesh>
            <uri>file://model.dae</uri>
          </mesh>
        </geometry>
        <material>
          <shader type='pixel'/>
          <script>
            <uri>model://clock/materials/scripts</uri>
            <uri>model://clock/materials/textures</uri>
            <name>clock</name>
          </script>
        </material>
        <pose frame=''>0 0 0 0 -0 0</pose>
        <cast_shadows>1</cast_shadows>
        <transparency>0</transparency>
      </visual>
    </link>
    <static>1</static>
    <allow_auto_disable>1</allow_auto_disable>
  </model>
</sdf>

The scripts:

material clock
{
  technique
  {
    pass
    {
      texture_unit
      {
        texture material_22.png
    scale 1 1
      }
    }
  }
}
edit retag flag offensive close merge delete

Comments

Fix the mesh uri. <uri>model://clock/meshes/model.dae</uri>

nlamprian gravatar imagenlamprian ( 2020-06-08 23:22:40 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-06-08 15:42:31 -0500

chapulina gravatar image

The bit you're missing is probably setting the GAZEBO_MODEL_PATH environment variable. Do it like this:

export GAZEBO_MODEL_PATH=<path to parent directory of clock>:$GAZEBO_MODEL_PATH

Also make sure that your model's directory is called clock.

What Gazebo does is substitute model:// with <path to parent directory of clock>. So it will load:

<mesh><uri><path to parent directory of clock>/clock/model.dae</uri></mesh>

edit flag offensive delete link more

Comments

I have put the files in the ~/.gazebo/models/ directory, and I can find the model's name in the side navigation bar but cant add the model to world.

pumpkin gravatar imagepumpkin ( 2020-06-08 19:31:26 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-06-06 03:08:14 -0500

Seen: 82 times

Last updated: Jun 08 '20