scpeters-test / sdformat

Simulation Description Format (SDF) parser and description files.
http://sdformat.org
Other
1 stars 0 forks source link

URDF to SDF parser does not allow attachment of light to links #214

Closed scpeters-test closed 5 years ago

scpeters-test commented 5 years ago

Original report (archived issue) by Auguste Bourgois (Bitbucket: AugusteBourgois).

The original report had attachments: file.sdf, file.urdf


Hello,

Prerequisites

Description

I am trying to use the FlashLightPlugin from Gazebo to attach a light to the link of a robot. Unfortunately, it doesn't work, and the reason might be the following : When converting a URDF file to SDF, whether manually using the command gz sdf --print file.urdf > file.sdf or automatically when launching gazebo, the light components attached to links are not parsed and do not appear in the resulting SDF file.

Steps to Reproduce

  1. Create a simple URDF file (See test.urdf)
  2. Convert the file to SDF using gz sdf --print file.urdf > file.sdf (See file.sdf)
  3. The component has disappeared during the conversion from URDF to SDF.

Expected behavior:

The light component should be in the resulting SDF file.

Actual behavior:

The light component is not in the resulting SDF file.

Reproduces how often:

Every time I tried.

Versions

Gazebo 9, Ubuntu 16.04, ROS Kinetic, SDF 1.6

Additional Information

The problem comes from the URDF parser used to convert URDF files into SDF files. It only looks for , and elements in a . A way of avoiding that could be to just copy-n-paste the element directly in the right place of the resulting SDF file. Another way, which seems a bit longer, could be to parse the element just like any other element, and recreate it in the right place in the resulting SDF file.

I guess this "bug" could be considered as a feature request, so I apologize in advance in that case.

If necessary, I could take part in the development of this bugfix/feature, even though I don't really know where to start.

scpeters-test commented 5 years ago

Original comment by Auguste Bourgois (Bitbucket: AugusteBourgois).


scpeters-test commented 5 years ago

Original comment by Addisu Z. Taddese (Bitbucket: azeey, GitHub: azeey).


Thanks for reporting the issue. I think the proper way to specify gazebo specific tags to a link is using <gazebo reference="link_name">. And the plugin needs to be under <robot> instead of <link>. So I modified your example and it seems to work for me. Can you give it a try?

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro                                     | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot name="test_light_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <!-- Base Link -->
  <link name="robot">
    <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" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
    </inertial>
  </link>
  <joint name="j_robot_light_link" type="revolute">
    <parent link="robot"/>
    <child link="light_link"/>
    <limit effort="0" lower="0" upper="0" velocity="0"/>
    <origin rpy="0 0 0" xyz="0 0 1.5"/>
  </joint>
  <!-- Light link -->
  <link name="light_link">
    <collision>
      <origin rpy="0 1.57079632679 0" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.15" radius="0.025"/>
      </geometry>
    </collision>
    <visual>
      <origin rpy="0 1.57079632679 0" xyz="0 0 0"/>
      <geometry>
        <cylinder length="0.15" radius="0.025"/>
      </geometry>
    </visual>
    <inertial>
      <mass value="0.0001"/>
      <inertia ixx="0.0001" ixy="0.0" ixz="0.0" iyy="0.0001" iyz="0.0" izz="0.0001"/>
    </inertial>
  </link>
  <!-- Light -->
  <gazebo reference="light_link">
    <light name="light" type="spot">
      <pose>1 0 0 0 0 0</pose>
      <diffuse>1 1 1 1</diffuse>
      <specular>1 1 1 1</specular>
      <attenuation>
        <range>20</range>
        <linear>0.05</linear>
        <constant>0.05</constant>
        <quadratic>0.01</quadratic>
      </attenuation>
      <direction>1 0 0</direction>
      <spot>
        <inner_angle>0.25</inner_angle>
        <outer_angle>1.0</outer_angle>
        <falloff>1.0</falloff>
      </spot>
    </light>
  </gazebo>
  <!-- Flashlight plugin -->
  <gazebo>
    <plugin filename="libUnderwaterLightPlugin.so" name="light">
      <serviceName>light_control</serviceName>
      <enable>true</enable>
      <light>
        <id>light_link/light</id>
        <duration>1</duration>
        <interval>0</interval>
      </light>
    </plugin>
  </gazebo>
</robot>
scpeters-test commented 5 years ago

Original comment by Auguste Bourgois (Bitbucket: AugusteBourgois).


Indeed, your solution works perfectly.

Thank you very much !

scpeters-test commented 5 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters).