0
$\begingroup$

How can I organize the model structure when using gazebo? I have a world file which include a robot with

        <model name='robot'>
            <pose frame=''> 0 0 0.94 0 -0 -1.57</pose>
            <include>
                <uri>robot</uri>
            </include>
        </model>

For the robot, I want to define a wheel that is used multiple times for the robot. I tried to include it as

        <link name='left_wheel_body'>
            <pose>0. 0. 0. 3.14159 0. 3.14159</pose>
            <include>
                <uri>wheel</uri>
            </include>
        </link>
        <joint name='left_wheel_joint' type='revolute'>
            <child>left_wheel_body</child>
            <parent>base_body</parent>
...

and wheel model.sdf looks like

<sdf version='1.7'>
    <model name='wheel'>
        <link name='wheel_body'>
            <inertial>
                <pose>0 0 0 0 -0 0</pose>
                <mass>0.5</mass>
            </inertial>
            <visual name='wheel_body_visual'>
                <pose>0 0 0 0 -0 0</pose>
                <geometry>
                    <cylinder>
                        <length>0.01</length>
                        <radius>0.02</radius>
                    </cylinder>
                </geometry>
            </visual>
        </link>
    </model>
</sdf>

The structure of the file is defined as

├─ robot
│  ├─ model.sdf   
│  └─ model.config
│
├─ wheel
│  ├─ model.sdf   
│  └─ model.config
│
└─ simple_world.world

However it kept saying that Error: Non-unique names detected in type model in Does anyone know how to fix this? Also I am including the absolute path to include wheel and robot into world file. But I is there a way to include relative path to include those model into the world / sdf file?

Thank you

$\endgroup$
3
  • $\begingroup$ I am only including wheel.sdf once currently to test it. But it still complain about non-unique name $\endgroup$
    – Max
    Commented Dec 22, 2023 at 0:57
  • $\begingroup$ Updated my answer. $\endgroup$
    – Mike973
    Commented Dec 22, 2023 at 13:04
  • $\begingroup$ If one of these answers helped you, please click the checkmark to turn it green. $\endgroup$
    – Mike973
    Commented Jan 21 at 17:21

2 Answers 2

0
$\begingroup$

You can add a name tag in your include to override the name in the included sdf, see the SDFormat specification.

For the relative path, use <uri>model://file.sdf</uri> and set the environment variable

  • GAZEBO_MODEL_PATH for Gazebo Classic,
  • IGN_GAZEBO_RESOURCE_PATH for Ignition Gazebo <= 7, or
  • GZ_SIM_RESOURCE_PATH for Gazebo Sim >= 7.

See also this GitHub thread.

$\endgroup$
0
$\begingroup$
  1. In sdf, if you <include> a model more than once at the same level, you must also provide a unique <name> tag for it. This is used to uniquely name that instance of the object.

  2. Also, I think your <uri> tag should look like <uri>model://wheel</uri>

  3. I doubt you can reference model 'robot' from inside <model name='robot'>

  4. According to the sdf specification, <include> is not a valid child of tag <link>.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.