0

I'm working on an SDF file written in XML used to describe a robotic arm. There are many repeated parts in the robot and I'm trying to declare a variable of int type and reuse it in different parts of the code. However, I can't seem to get the code working properly in a simulator.

This is a snippet of my code (I've omitted some unrelated portions of the code):

<?xml version='1.0'?>
<sdf version='1.7'>

<!DOCTYPE model [<!ENTITY basesize "1 1 0.1">]>

  <model name='working_arm'>
    <link name='base'>
      <visual name='base_visual'>
        <pose>0 0 0.05 0 -0 0</pose>
        <geometry>
          <box>
            <size>&basesize;</size>
          </box>
        </geometry>
      </visual>
    <link>
   <model>
<sdf>

I think this fails because entities can only be declared as strings and size does not accept strings. However, I am unable to find any documentation on how to specify the entity declared to be an integer.

Replacing &basesize; with this manual input works so I know that it's not an issue with other parts of the code:

<size>1 1 0.1</size>

Edit: Something like this? Because it still doesn't seem to work.

<?xml version='1.0'?>

<!DOCTYPE sdf [<!ENTITY basesize "1 1 0.1">]>    
<sdf version='1.7'>
  <model name='working_arm'>
    <link name='base'>
      <visual name='base_visual'>
        <pose>0 0 0.05 0 -0 0</pose>
        <geometry>
          <box>
            <size>&basesize;</size>
          </box>
        </geometry>
      </visual>
    <link>
   <model>
<sdf>
gerald ek
  • 1
  • 1
  • The ` ` declaration needs to come before the start tag of the outermost element (``) and the name needs to match the outermost element. Your theory as to why it's failing seems implausible to me: XML only deals in strings. – Michael Kay Jan 06 '22 at 14:56
  • @MichaelKay I think maybe the Gazebo simulator doesn't support such variables... I've tested the edited code using a online xml viewer and it produces the xml tree without any errors. – gerald ek Jan 07 '22 at 05:10
  • You've fixed the error that I commented on. I think it's now a question about gazebo, not about XML, so (a) it would be useful to change the title of the question, and (b) I'm afraid I can't help you with it any more. – Michael Kay Jan 07 '22 at 08:39

0 Answers0