dfki-ric / pytransform3d

3D transformations for Python.
https://dfki-ric.github.io/pytransform3d/
Other
619 stars 65 forks source link

UrdfTransformManager. xacro:property not working in rpy definition #125

Closed mpQuintana closed 3 years ago

mpQuintana commented 3 years ago

When reading a file with the UrdfTransformManager, a xacro:property defined works fine inside de origin xyz value but not on the rpy value.

Example:

  <xacro:property name="M_PI" value="3.1415926535897931" />
  <joint name="joint1" type="fixed">
    <origin xyz="${M_PI} 0 0" rpy="0 0 0" />
    <parent link="link1"/>
    <child link="link2" />
  </joint>

works just fine, but the following does not:

  <xacro:property name="M_PI" value="3.1415926535897931" />
  <joint name="joint1" type="fixed">
    <origin xyz="$0 0 0" rpy="{M_PI} 0 0" />
    <parent link="link1"/>
    <child link="link2" />
  </joint>

The error I get:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-102-03043d9e6c11> in <module>
      3     xacro = f.read()
      4 tm = UrdfTransformManager()
----> 5 tm.load_urdf(xacro)

/usr/local/lib/python3.6/dist-packages/pytransform3d/urdf.py in load_urdf(self, urdf_xml, mesh_path, package_dir)
    175                  for link in robot.findAll("link", recursive=False)]
    176         joints = [self._parse_joint(joint, links)
--> 177                   for joint in robot.findAll("joint", recursive=False)]
    178 
    179         self.add_transform(links[0], robot_name, np.eye(4))

/usr/local/lib/python3.6/dist-packages/pytransform3d/urdf.py in <listcomp>(.0)
    175                  for link in robot.findAll("link", recursive=False)]
    176         joints = [self._parse_joint(joint, links)
--> 177                   for joint in robot.findAll("joint", recursive=False)]
    178 
    179         self.add_transform(links[0], robot_name, np.eye(4))

/usr/local/lib/python3.6/dist-packages/pytransform3d/urdf.py in _parse_joint(self, joint, links)
    310                                 "document." % j.joint_type)
    311 
--> 312         j.child2parent = self._parse_origin(joint)
    313 
    314         j.joint_axis = np.array([1, 0, 0])

/usr/local/lib/python3.6/dist-packages/pytransform3d/urdf.py in _parse_origin(self, entry)
    336                 # https://orbitalstation.wordpress.com/tag/quaternion/
    337                 rotation = active_matrix_from_extrinsic_roll_pitch_yaw(
--> 338                     roll_pitch_yaw)
    339         return transform_from(
    340             rotation, translation, strict_check=self.strict_check)

/usr/local/lib/python3.6/dist-packages/pytransform3d/rotations.py in active_matrix_from_extrinsic_roll_pitch_yaw(rpy)
   1288         Rotation matrix
   1289     """
-> 1290     return active_matrix_from_extrinsic_euler_xyz(rpy)
   1291 
   1292 

/usr/local/lib/python3.6/dist-packages/pytransform3d/rotations.py in active_matrix_from_extrinsic_euler_xyz(e)
   1107         Rotation matrix
   1108     """
-> 1109     alpha, beta, gamma = e
   1110     R = active_matrix_from_angle(2, gamma).dot(
   1111         active_matrix_from_angle(1, beta)).dot(

ValueError: not enough values to unpack (expected 3, got 0)
AlexanderFabisch commented 3 years ago

Hi @mpQuintana,

xacro is currently not supported by this library. Only plain URDF is supported. The first example might not crash at the moment but you shouldn't expect correct results. Supporting xacro completely might be a very difficult task. I am open to contributions though.