How to create a model(.sdf) file that can be inserted at will in Gazebo?
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
}
}
}
}
Asked by pumpkin on 2020-06-06 03:08:14 UTC
Answers
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>
Asked by chapulina on 2020-06-08 15:42:31 UTC
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.
Asked by pumpkin on 2020-06-08 19:31:26 UTC
Comments
Fix the mesh uri.
<uri>model://clock/meshes/model.dae</uri>
Asked by nlamprian on 2020-06-08 23:22:40 UTC