Search code examples
drake

How to use ROS urdf package in Drake?


I'm new to Drake.And I want to use my robot model which is a ROS urdf package converted from SolidWorks plugin.I've tried to use

builder = DiagramBuilder()
plant, scene_graph = AddMultibodySceneGraph(builder,0.0)
parser = Parser(plant)
pkg_map = parser.package_map()
pkg_map.AddPackageXml("myxmlfilepath")
robot_file = "my_urdf_file_path"
robot = parser.AddModelFromFile(robot_file, "robot")

But I got an errorRuntimeError:The WaveFront obj file has no faces in the last line.I try to use ROS to display and it works well. My urdf file has some .stl format mesh file for visual and collision. I see some comments here, so I guess Drake maybe can't deal with .stl in a default way so far.What should I do except manually converting .stl mesh file to .obj file? Thanks in Advance.


Solution

  • As you noted in your comment above, once you converted your STL file to an OBJ file, you were able to load your URDF file.

    This is because Drake does not yet support loading STL (or DAE) meshes at runtime; they must be converted (either manually as you had done, or via the build system). For more info, please see:
    https://github.com/RobotLocomotion/drake/issues/2941

    In that issue, I've referenced your post as a motivator towards adding additional mesh support.

    Thanks!