Working with URDF Format
What is URDF?
URDF (Unified Robot Description Format) is an XML format used by ROS and robotics simulators such as Gazebo to describe robots — their links, joints and the geometry attached to them. Importing a URDF file gives you the robot as a regular Aspose.3D scene, so you can convert it to glTF, FBX or any other supported format.
Open URDF File Format
Aspose.3D imports the <visual> geometry of every link. Set UrdfLoadOptions.load_collision_geometry to True to also import the <collision> geometry, which robots use for physics simulation.
from aspose.threed import Scene, FileFormat
from aspose.threed.entities import Box
from aspose.threed.formats import UrdfLoadOptions
# Create a new scene
scene = Scene()
# Build a simple robot link
link = scene.root_node.create_child_node("link1")
link.entity = Box()
# Save the scene as URDF file
scene.save("output.urdf", FileFormat.URDF)
# Load it back with URDF options
load_options = UrdfLoadOptions()
# Load collision geometry from the URDF file
load_options.load_collision_geometry = True
loaded = Scene()
loaded.open("output.urdf", load_options)Save URDF File Format
Scenes are exported to URDF with the URDF file format. Links whose geometry is a mesh are written as external mesh files next to the URDF file — the UrdfSaveOptions.mesh_format property selects which mesh format to use, and indented enables pretty-printed XML output.
from aspose.threed.formats import UrdfSaveOptions
# Save with options: pretty-printed XML, meshes exported as OBJ
save_options = UrdfSaveOptions()
save_options.indented = True
save_options.mesh_format = FileFormat.WAVEFRONT_OBJ
scene.save("output_indented.urdf", save_options)For a scene containing a link named link1 with mesh geometry, this produces a URDF file that references the exported mesh:
<?xml version="1.0" encoding="utf-8"?>
<robot name="RootNode">
<link name="link1">
<visual>
<geometry>
<mesh filename="link1_visual0.obj" />
</geometry>
</visual>
</link>
</robot>