robotics-toolbox-python icon indicating copy to clipboard operation
robotics-toolbox-python copied to clipboard

Adding Custom URDF Robot Models

Open pranshumalik14 opened this issue 4 years ago • 5 comments

Describe the bug Adding new URDF models (that refer to stl files) needs a relative path to the XACRO path in rtbdata.

ValueError: file xacro/stl/braccio_base.stl not found locally or in rtbdata

Any help on how to do this properly will be highly appreciated. Here's a snapshot of the code we have written:

class Braccio(rtb.ERobot):

    def __init__(self):

        links, name, urdf_string, urdf_filepath = self.URDF_read(
            rtb.rtb_path_to_datafile("../urdf/braccio.urdf.xacro", local=True)
        )

        super().__init__(
            links,
            name=name,
            manufacturer="Arduino",
            gripper_links=links[12],
            urdf_string=urdf_string,
            urdf_filepath=urdf_filepath,
        )

We would like to keep the URDF model information local to our project than to move it to our installation folders. The code that parses xacro files seems to look for geometry files relative to the XACRO directory.

Version information

Did you install it from PyPI or GitHub? Latest Github version (pulled) Commit hash: 51aa8bbb3663a7c815f9880d538d61e7c85bc470

Environment (please complete the following information):

  • Ubuntu 18.04.
  • Python 3.6.9.

pranshumalik14 avatar Jan 18 '22 07:01 pranshumalik14

This was despite setting the top-level directory to the project folder. Seemed like that information was not passed into the geometry parser/loadstr for the URDF.

pranshumalik14 avatar Jan 18 '22 07:01 pranshumalik14

The behaviour we should have is that if an abs path is given it should use that, rather than the package relative one.

@pranshumalik14 would that work for you?

petercorke avatar Jan 22 '22 05:01 petercorke

Yes absolutely, that should fix it, thank you!

pranshumalik14 avatar Jan 22 '22 06:01 pranshumalik14

I use os.chdir(os.path.dirname(file)) to solve the problem about absolute path.

https://github.com/olmerg/rtb_serial_robot/blob/main/planar_3dof/Planar3DOF.py

olmerg avatar Jan 31 '22 21:01 olmerg

Thanks so much @olmerg! Followed your setup step-by-step and got it to work! But a direct fix for it would still be helpful in general.

pranshumalik14 avatar Mar 05 '22 02:03 pranshumalik14