Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URDF gazebo material tags incorrectly translated #513

Open
barulicm opened this issue Mar 15, 2021 · 1 comment
Open

URDF gazebo material tags incorrectly translated #513

barulicm opened this issue Mar 15, 2021 · 1 comment
Labels
bug Something isn't working URDF URDF parsing

Comments

@barulicm
Copy link

Environment

  • OS Version: Ubuntu 20.04
  • Source or binary build? Binary, apt, 9.4.0-1

Description

  • Expected behavior:
    Gazebo material tags in the URDF that are already valid SDF material tags should be translated unchanged.
  • Actual behavior:
    The translation process breaks the material tag by attempting to convert it to a reference to a Gazebo material script.

Steps to reproduce

  1. Create a URDF including a gazebo material tag. Example:
    <?xml version="1.0"?>
    <robot name="example">
    <link name="link1">
        <collision>
            <geometry>
                <box size="1 1 1"/>
            </geometry>
        </collision>
        <visual>
            <geometry>
                <box size="1 1 1"/>
            </geometry>
        </visual>
        <inertial>
            <mass value="1"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
    </link>
    <gazebo reference="link1">
        <material>
            <ambient>0 0 1 1</ambient>
            <diffuse>0 0 1 1</diffuse>
            <specular>0 0 1 1</specular>
        </material>
    </gazebo>
    </robot>
    
  2. Convert the URDF file to SDF
    ign sdf -p example.urdf
    

Output

The generated SDF with the now broken material tag.

<sdf version='1.7'>
  <model name='example'>
    <link name='link1'>
      <inertial>
        <pose>0 0 0 0 -0 0</pose>
        <mass>1</mass>
        <inertia>
          <ixx>1</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>1</iyy>
          <iyz>0</iyz>
          <izz>1</izz>
        </inertia>
      </inertial>
      <collision name='link1_collision'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
        <surface>
          <contact>
            <ode/>
          </contact>
          <friction>
            <ode/>
          </friction>
        </surface>
      </collision>
      <visual name='link1_visual'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
        <material>
          <script>
            <name>ambient</name>
            <uri>file://media/materials/scripts/gazebo.material</uri>
          </script>
        </material>
      </visual>
      <gravity>1</gravity>
      <velocity_decay/>
    </link>
  </model>
</sdf>
@barulicm barulicm added the bug Something isn't working label Mar 15, 2021
@peci1
Copy link
Contributor

peci1 commented Mar 29, 2021

There's much more ign sdf -p messes with materials when generating files for Ignition Gazebo. I'm really curious if someone will do something about it, because this way, materials are just unusable. They can't even be passed as blobs to the final SDF because <material> is one of the unfortunate tags which get touched by ign sdf which mangle them like you posted. This is a real blocker for keeping your robot description written in Xacro while using it in Ignition Gazebo - yet this approach has so many benefits that I still choose it over all the other approaches. It seems that so far you have to make friends with sed to polish the result of ign sdf -p.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working URDF URDF parsing
Projects
None yet
Development

No branches or pull requests

3 participants