Incorporate xacro into SDF

Create issue
Issue #210 new
Nate Koenig created an issue

Pull in the ROS xacro capability into SDF

Comments (10)

  1. Steve Peters

    I think that xacro could simplify the generation and debugging of complex sdf models by reducing the amount of duplicate information that must be kept synchronized (e.g. geometry in both collision and visual elements).

    It's worth noting that the challenge of synchronizing duplicate information is also present when tinkering with models in the GUI with ModelListWidget. I don't think this would this be simplified by introducing xacro.

  2. Steve Peters

    As I think about it more, it would be more powerful to write a set of sdf generation tools using a full-fledged scripting language (ruby / python / etc). These tools could just generate sdf's.

  3. John Nagle

    It would be more useful to get the import and export tools working, so that robot models could be brought in from a CAD system. COLLADA can represent a robot with a skeleton and joints, but Gazebo can't import that.

    Editing geometry with a text editor is so 1970s.

  4. Steve Peters

    I just made a quick test with xml stylesheets:

    $ cat cylinder_rigid_body.xml
    <?xml version="1.0" ?>
    <?xml-stylesheet type="text/xsl" href="cylinder_rigid_body.xsl" ?>
    <!--
      Cylinder centered on z axis
    -->
    <uniform_cylinder>
      <radius>0.5</radius>
      <length>10.0</length>
      <mass>1.0</mass>
    </uniform_cylinder>
    
    $ cat cylinder_rigid_body.xsl
    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <!--
      sdf model file for a cylinder of uniform mass
    -->
    
    <xsl:output method="xml" omit-xml-declaration="no"/>
    
    <xsl:template match="uniform_cylinder">
    <sdf version="1.4">
      <model name="cylinder">
        <link name="link">
          <inertial>
            <mass><xsl:value-of select="mass"/></mass>
            <inertia>
              <ixx><xsl:value-of select="1 div 12 * mass * (3*radius*radius + length*length)"/></ixx>
              <iyy><xsl:value-of select="1 div 12 * mass * (3*radius*radius + length*length)"/></iyy>
              <izz><xsl:value-of select="0.5 * mass * radius*radius"/></izz>
              <ixy>0.0</ixy>
              <ixz>0.0</ixz>
              <iyz>0.0</iyz>
            </inertia>
          </inertial>
          <collision name="collision">
            <geometry>
              <cylinder>
                <radius><xsl:value-of select="radius"/></radius>
                <length><xsl:value-of select="length"/></length>
              </cylinder>
            </geometry>
          </collision>
          <visual name="visual">
            <geometry>
              <cylinder>
                <radius><xsl:value-of select="radius"/></radius>
                <length><xsl:value-of select="length"/></length>
              </cylinder>
            </geometry>
          </visual>
        </link>
      </model>
    </sdf>
    </xsl:template>
    </xsl:stylesheet>
    
    $ xsltproc cylinder_rigid_body.xsl cylinder_rigid_body.xml \
      | xmllint --format -
    <?xml version="1.0"?>
    <sdf version="1.4">
      <model name="cylinder">
        <link name="link">
          <inertial>
            <mass>1.0</mass>
            <inertia>
              <ixx>8.395833333333332</ixx>
              <iyy>8.395833333333332</iyy>
              <izz>0.125</izz>
              <ixy>0.0</ixy>
              <ixz>0.0</ixz>
              <iyz>0.0</iyz>
            </inertia>
          </inertial>
          <collision name="collision">
            <geometry>
              <cylinder>
                <radius>0.5</radius>
                <length>10.0</length>
              </cylinder>
            </geometry>
          </collision>
          <visual name="visual">
            <geometry>
              <cylinder>
                <radius>0.5</radius>
                <length>10.0</length>
              </cylinder>
            </geometry>
          </visual>
        </link>
      </model>
    </sdf>
    

    They have about as much math capability as xacro, but they are a w3c standard.

  5. Steve Peters
  6. Log in to comment