2
$\begingroup$

I'm trying to export an URDF to a 3D model, I can only find ways to do it the opposite way. The URDF consist out of basic geometory, any help would be expreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

https://wiki.ros.org/collada_urdf (https://github.com/ros/collada_urdf) hasn't been updated in a long time but still works and can convert to the dae format. Blender or other tools can load dae and convert to many other formats. It's for ros1 but possibly can run fine in a ros1 context using the urdf you've created in ros2 (was there any change in urdf from ros1 to ros2?).

It compiles fine for me (on Ubuntu 23.10) but https://github.com/wxmerkt/collada_urdf/tree/topic/fix-collada-color-support has more recent changes that could be useful. There's also this ros2 port PR https://github.com/ros/collada_urdf/pull/39.

rosrun collada_urdf urdf_to_collada <input-urdf> <output.dae>

I tried it on a pr2 urdf in moveit:

rosrun collada_urdf urdf_to_collada `rospack find moveit_resources_pr2_description`/urdf/robot.xml pr2.dae

Document successfully written to pr2.dae

enter image description here (how do I move the joints around in Blender to prove they exported properly?)

pr2.dae:

<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2008/03/COLLADASchema" version="1.5.0">
  <asset>
    <contributor>
      <authoring_tool>URDF Collada Writer</authoring_tool>
    </contributor>
    <created>2024-01-18T08:01:01.000000</created>
    <modified>2024-01-18T08:01:01.000000</modified>
    <unit/>
    <up_axis>Z_UP</up_axis>
  </asset>
  <library_visual_scenes id="vscenes">
    <visual_scene id="vscene" name="URDF Visual Scene">
...

If collada_urdf doesn't work or if you just want to do it from scratch you could write something that parses /robot_description or the urdf file and parses it using https://github.com/ros/urdf_parser_py/tree/ros2 or https://github.com/ros/urdfdom/, and then outputs the 3D primitives into another format. It'll be more work if you want joints in the output format (which needs to support joints, so not stl), easier if you want a static model with everything positioned at a set angle (which could be stl). The rviz robot model plugin is a useful code reference for turning urdf into geometry along with collada_urdf, https://github.com/ros/robot_state_publisher could be useful as well.


Converting from URDF to STL is mostly the same question but the answer there is that you have to do it manually.

There's also https://answers.ros.org/question/208838/export-robot-model-in-given-pose-to-single-mesh-file/ but no answer there (that question wasn't converted to robotics stackexchange because it didn't have an answer?).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.