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

[ros2] Different interpretation of xacro/urdf files between igniton-gazebo3 and igniton-gazebo4/5 #147

Closed
doisyg opened this issue Apr 2, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@doisyg
Copy link
Contributor

doisyg commented Apr 2, 2021

Environment

  • OS Version: Ubuntu 20.04
  • Source or binary build: igniton-gazebo3 igniton-gazebo4 igniton-gazebo5

Description

Don't know if I should report here or there: https://github.com/ignitionrobotics/ign-gazebo
I have a ROS / Ignition robot simulation working well with citadel, I did few tests with the newly released edifice and run into an issue on how my xacro/files are interpreted by gazebo when spawning with ros_ign_gazebo create.
More specifically on how a lidar sensor is positioned by gazebo.
When interpreting the following xacro/urdf file:

<?xml version="1.0" ?>
<robot name="will_be_ignored" xmlns:xacro="http://www.ros.org/wiki/xacro">

<gazebo>
  <plugin filename="ignition-gazebo-sensors-system" name="ignition::gazebo::systems::Sensors">
    <render_engine>ogre2</render_engine>
  </plugin>
</gazebo>

<link name="base_footprint">
  <visual>
    <geometry>
      <sphere radius="0.5"/>
    </geometry>
  </visual>
  <collision>
    <geometry>
      <sphere radius="0.5"/>
    </geometry>
  </collision>
  <inertial>
    <mass value="1"/>
  <inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
  </inertial>
</link>

<link name="link">
  <visual>
    <geometry>
      <sphere radius="1.0"/>
    </geometry>
  </visual>
  <collision>
    <geometry>
      <sphere radius="1.0"/>
    </geometry>
  </collision>
  <inertial>
    <mass value="1"/>
    <inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
  </inertial>
</link>

<gazebo reference="link" >
  <sensor name="link" type="gpu_lidar">
    <topic>scan</topic>
    <update_rate>30</update_rate>
    <lidar>
      <scan>
        <horizontal>
          <samples>2800</samples>
          <resolution>1</resolution>
          <min_angle>-2.09</min_angle>
          <max_angle>2.09</max_angle>
        </horizontal>
        <vertical>
          <samples>1</samples>
          <resolution>0.1</resolution>
          <min_angle>0.0</min_angle>
          <max_angle>0.0</max_angle>
        </vertical>
      </scan>
      <range>
        <min>0.05</min>
        <max>30.0</max>
        <resolution>0.01</resolution>
      </range>
    </lidar>
    <alwaysOn>1</alwaysOn>
    <visualize>true</visualize>
  </sensor>
</gazebo>

<joint name="base_footprint_joint" type="fixed">
  <origin xyz="0 0 3.0" rpy="0 0 0" />
  <parent link="base_footprint"/>
  <child link="link" />
</joint>

</robot>

igniton-gazebo3 places properly the lidar sensor at the origin of the link "link", whereas igniton-gazebo4 and igniton-gazebo5 place it at the origin of the link "base_footprint"

And indeed, if I use the gazebo GUI feature "Save world as..." I get a different sdf file between igniton-gazebo3 and igniton-gazebo4/5. With igniton-gazebo3, the sensor has the attribute <pose>0 0 3 0 -0 0</pose>, whereas with igniton-gazebo4/5, the sensor has no pose attribute. Full sdf files below:

igniton-gazebo3 :

<sdf version='1.7'>
  <world name='empty'>
    <physics name='1ms' type='ignored'>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
    </physics>
    <plugin name='ignition::gazebo::systems::Physics' filename='ignition-gazebo-physics-system'/>
    <plugin name='ignition::gazebo::systems::UserCommands' filename='ignition-gazebo-user-commands-system'/>
    <plugin name='ignition::gazebo::systems::SceneBroadcaster' filename='ignition-gazebo-scene-broadcaster-system'/>
    <plugin name='ignition::gazebo::systems::Contact' filename='ignition-gazebo-contact-system'/>
    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
      <spot>
        <inner_angle>0</inner_angle>
        <outer_angle>0</outer_angle>
        <falloff>0</falloff>
      </spot>
    </light>
    <gravity>0 0 -9.8</gravity>
    <magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
    <atmosphere type='adiabatic'/>
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>1</shadows>
    </scene>
    <model name='ground_plane'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode/>
            </friction>
            <contact/>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <ambient>0.8 0.8 0.8 1</ambient>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.8 0.8 0.8 1</specular>
          </material>
          <plugin name='__default__' filename='__default__'/>
        </visual>
      </link>
      <plugin name='__default__' filename='__default__'/>
      <pose>0 0 0 0 -0 0</pose>
    </model>
    <model name='my_custom_model'>
      <link name='base_footprint'>
        <inertial>
          <pose>0 0 1.5 0 -0 0</pose>
          <mass>2</mass>
          <inertia>
            <ixx>6.5</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>6.5</iyy>
            <iyz>0</iyz>
            <izz>2</izz>
          </inertia>
        </inertial>
        <collision name='base_footprint_collision'>
          <pose>0 0 0 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>0.5</radius>
            </sphere>
          </geometry>
          <surface>
            <friction>
              <ode/>
            </friction>
            <contact/>
          </surface>
        </collision>
        <collision name='base_footprint_fixed_joint_lump__link_collision_1'>
          <pose>0 0 3 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>1</radius>
            </sphere>
          </geometry>
          <surface>
            <contact>
              <ode/>
            </contact>
            <friction>
              <ode/>
            </friction>
          </surface>
        </collision>
        <visual name='base_footprint_visual'>
          <pose>0 0 0 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>0.5</radius>
            </sphere>
          </geometry>
          <plugin name='__default__' filename='__default__'/>
        </visual>
        <visual name='base_footprint_fixed_joint_lump__link_visual_1'>
          <pose>0 0 3 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>1</radius>
            </sphere>
          </geometry>
          <plugin name='__default__' filename='__default__'/>
        </visual>
        <gravity>1</gravity>
        <velocity_decay/>
        <sensor name='link' type='gpu_lidar'>
          <topic>scan</topic>
          <update_rate>30</update_rate>
          <lidar>
            <scan>
              <horizontal>
                <samples>2800</samples>
                <resolution>1</resolution>
                <min_angle>-2.09</min_angle>
                <max_angle>2.09</max_angle>
              </horizontal>
              <vertical>
                <samples>1</samples>
                <resolution>0.1</resolution>
                <min_angle>0</min_angle>
                <max_angle>0</max_angle>
              </vertical>
            </scan>
            <range>
              <min>0.05</min>
              <max>30</max>
              <resolution>0.01</resolution>
            </range>
          </lidar>
          <visualize>1</visualize>
          <pose>0 0 3 0 -0 0</pose>
          <alwaysOn>1</alwaysOn>
          <plugin name='__default__' filename='__default__'/>
        </sensor>
      </link>
      <static>0</static>
      <plugin name='ignition::gazebo::systems::Sensors' filename='ignition-gazebo-sensors-system'>
        <render_engine>ogre2</render_engine>
      </plugin>
      <pose>1.2 0 0.5 0 -0 -2.88319</pose>
    </model>
  </world>
</sdf>

and with igniton-gazebo5 :

<sdf version='1.8'>
  <world name='empty'>
    <physics name='1ms' type='ignored'>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
    </physics>
    <plugin name='ignition::gazebo::systems::Physics' filename='ignition-gazebo-physics-system'/>
    <plugin name='ignition::gazebo::systems::UserCommands' filename='ignition-gazebo-user-commands-system'/>
    <plugin name='ignition::gazebo::systems::SceneBroadcaster' filename='ignition-gazebo-scene-broadcaster-system'/>
    <plugin name='ignition::gazebo::systems::Contact' filename='ignition-gazebo-contact-system'/>
    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.90000000000000002</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
      <spot>
        <inner_angle>0</inner_angle>
        <outer_angle>0</outer_angle>
        <falloff>0</falloff>
      </spot>
    </light>
    <gravity>0 0 -9.8</gravity>
    <magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
    <atmosphere type='adiabatic'/>
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>1</shadows>
    </scene>
    <model name='ground_plane'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode/>
            </friction>
            <bounce/>
            <contact/>
          </surface>
        </collision>
        <visual name='visual'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <ambient>0.8 0.8 0.8 1</ambient>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.8 0.8 0.8 1</specular>
          </material>
          <plugin name='__default__' filename='__default__'/>
        </visual>
      </link>
      <plugin name='__default__' filename='__default__'/>
      <pose>0 0 0 0 -0 0</pose>
    </model>
    <model name='my_custom_model'>
      <link name='base_footprint'>
        <inertial>
          <pose>0 0 1.5 0 -0 0</pose>
          <mass>2</mass>
          <inertia>
            <ixx>6.5</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>6.5</iyy>
            <iyz>0</iyz>
            <izz>2</izz>
          </inertia>
        </inertial>
        <collision name='base_footprint_collision'>
          <pose>0 0 0 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>0.5</radius>
            </sphere>
          </geometry>
          <surface>
            <friction>
              <ode/>
            </friction>
            <bounce/>
            <contact/>
          </surface>
        </collision>
        <collision name='base_footprint_fixed_joint_lump__link_collision_1'>
          <pose>0 0 3 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>1</radius>
            </sphere>
          </geometry>
          <surface>
            <contact>
              <ode/>
            </contact>
            <friction>
              <ode/>
            </friction>
            <bounce/>
          </surface>
        </collision>
        <visual name='base_footprint_visual'>
          <pose>0 0 0 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>0.5</radius>
            </sphere>
          </geometry>
          <plugin name='__default__' filename='__default__'/>
        </visual>
        <visual name='base_footprint_fixed_joint_lump__link_visual_1'>
          <pose>0 0 3 0 -0 0</pose>
          <geometry>
            <sphere>
              <radius>1</radius>
            </sphere>
          </geometry>
          <plugin name='__default__' filename='__default__'/>
        </visual>
        <gravity>1</gravity>
        <velocity_decay/>
        <sensor name='link' type='gpu_lidar'>
          <topic>scan</topic>
          <update_rate>30</update_rate>
          <lidar>
            <scan>
              <horizontal>
                <samples>2800</samples>
                <resolution>1</resolution>
                <min_angle>-2.0899999999999999</min_angle>
                <max_angle>2.0899999999999999</max_angle>
              </horizontal>
              <vertical>
                <samples>1</samples>
                <resolution>0.10000000000000001</resolution>
                <min_angle>0</min_angle>
                <max_angle>0</max_angle>
              </vertical>
            </scan>
            <range>
              <min>0.050000000000000003</min>
              <max>30</max>
              <resolution>0.01</resolution>
            </range>
          </lidar>
          <visualize>1</visualize>
          <alwaysOn>1</alwaysOn>
          <plugin name='__default__' filename='__default__'/>
        </sensor>
      </link>
      <static>0</static>
      <plugin name='ignition::gazebo::systems::Sensors' filename='ignition-gazebo-sensors-system'>
        <render_engine>ogre2</render_engine>
      </plugin>
      <pose>1.2 0 0.5 0 -0 -2.88319</pose>
    </model>
  </world>
</sdf>
@doisyg doisyg added the bug Something isn't working label Apr 2, 2021
@doisyg doisyg changed the title [ros2] Different interpretation of xacro/urdf files between **igniton-gazebo3** and **igniton-gazebo4/5** [ros2] Different interpretation of xacro/urdf files between igniton-gazebo3 and igniton-gazebo4/5 Apr 2, 2021
@chapulina
Copy link
Contributor

I suspect this may be related to changes from libSDFormat 9 (Citadel) to libSDFormat 10 (Dome), because that's where the URDF gets parsed into SDF. In fact, a quicker way of reproducing this can be achieved with the ign sdf tool:

Citadel has the sensor pose:

ign sdf --force-version 9.5.0 -p /tmp/urdf
<sdf version='1.7'>
  <model name='will_be_ignored'>
    <link name='base_footprint'>
      <inertial>
        <pose>0 0 1.5 0 -0 0</pose>
        <mass>2</mass>
        <inertia>
          <ixx>6.5</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>6.5</iyy>
          <iyz>0</iyz>
          <izz>2</izz>
        </inertia>
      </inertial>
      <collision name='base_footprint_collision'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>0.5</radius>
          </sphere>
        </geometry>
      </collision>
      <collision name='base_footprint_fixed_joint_lump__link_collision_1'>
        <pose>0 0 3 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>1</radius>
          </sphere>
        </geometry>
        <surface>
          <contact>
            <ode/>
          </contact>
          <friction>
            <ode/>
          </friction>
        </surface>
      </collision>
      <visual name='base_footprint_visual'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>0.5</radius>
          </sphere>
        </geometry>
      </visual>
      <visual name='base_footprint_fixed_joint_lump__link_visual_1'>
        <pose>0 0 3 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>1</radius>
          </sphere>
        </geometry>
      </visual>
      <gravity>1</gravity>
      <velocity_decay/>
      <sensor name='link' type='gpu_lidar'>
        <topic>scan</topic>
        <update_rate>30</update_rate>
        <lidar>
          <scan>
            <horizontal>
              <samples>2800</samples>
              <resolution>1</resolution>
              <min_angle>-2.09</min_angle>
              <max_angle>2.09</max_angle>
            </horizontal>
            <vertical>
              <samples>1</samples>
              <resolution>0.1</resolution>
              <min_angle>0</min_angle>
              <max_angle>0</max_angle>
            </vertical>
          </scan>
          <range>
            <min>0.05</min>
            <max>30</max>
            <resolution>0.01</resolution>
          </range>
        </lidar>
        <visualize>1</visualize>
        <pose>0 0 3 0 -0 0</pose>
        <alwaysOn>1</alwaysOn>
      </sensor>
    </link>
    <static>0</static>
    <plugin name='ignition::gazebo::systems::Sensors' filename='ignition-gazebo-sensors-system'>
      <render_engine>ogre2</render_engine>
    </plugin>
  </model>
</sdf>

Dome doesn't:

ign sdf --force-version 10.3.0 -p /tmp/urdf
<sdf version='1.7'>
  <model name='will_be_ignored'>
    <link name='base_footprint'>
      <inertial>
        <pose>0 0 1.5 0 -0 0</pose>
        <mass>2</mass>
        <inertia>
          <ixx>6.5</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>6.5</iyy>
          <iyz>0</iyz>
          <izz>2</izz>
        </inertia>
      </inertial>
      <collision name='base_footprint_collision'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>0.5</radius>
          </sphere>
        </geometry>
      </collision>
      <collision name='base_footprint_fixed_joint_lump__link_collision_1'>
        <pose>0 0 3 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>1</radius>
          </sphere>
        </geometry>
        <surface>
          <contact>
            <ode/>
          </contact>
          <friction>
            <ode/>
          </friction>
        </surface>
      </collision>
      <visual name='base_footprint_visual'>
        <pose>0 0 0 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>0.5</radius>
          </sphere>
        </geometry>
      </visual>
      <visual name='base_footprint_fixed_joint_lump__link_visual_1'>
        <pose>0 0 3 0 -0 0</pose>
        <geometry>
          <sphere>
            <radius>1</radius>
          </sphere>
        </geometry>
      </visual>
      <gravity>1</gravity>
      <velocity_decay/>
      <sensor name='link' type='gpu_lidar'>
        <topic>scan</topic>
        <update_rate>30</update_rate>
        <lidar>
          <scan>
            <horizontal>
              <samples>2800</samples>
              <resolution>1</resolution>
              <min_angle>-2.09</min_angle>
              <max_angle>2.09</max_angle>
            </horizontal>
            <vertical>
              <samples>1</samples>
              <resolution>0.1</resolution>
              <min_angle>0</min_angle>
              <max_angle>0</max_angle>
            </vertical>
          </scan>
          <range>
            <min>0.05</min>
            <max>30</max>
            <resolution>0.01</resolution>
          </range>
        </lidar>
        <visualize>1</visualize>
        <alwaysOn>1</alwaysOn>
      </sensor>
    </link>
    <static>0</static>
    <plugin name='ignition::gazebo::systems::Sensors' filename='ignition-gazebo-sensors-system'>
      <render_engine>ogre2</render_engine>
    </plugin>
  </model>
</sdf>

Looking through SDFormat's changelog, nothing stood out as being the culprit though.

@scpeters
Copy link
Member

scpeters commented Apr 5, 2021

I believe this is connected to fixed-joint reduction with the libsdformat parser_urdf.cc file

@chapulina
Copy link
Contributor

I think this was fixed by gazebosim/sdformat#525

@doisyg
Copy link
Contributor Author

doisyg commented Apr 6, 2021

Hopefully. It looks like it is related. Will test once merged or released in sdf11

@doisyg
Copy link
Contributor Author

doisyg commented Apr 10, 2021

Confirmed fixed in dome/sdf10, still need a merge in edifice/sdf11

@chapulina
Copy link
Contributor

The SDFormat fix has been forward-ported to Edifice. I'm closing this. ROS users will get the updated versions as the fix is released and ported to packages.ros.org.

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

No branches or pull requests

3 participants