Skip to content

novaphy.UrdfParser

Read / write entry point for URDF. Parses URDF documents into UrdfModelData, and serializes a UrdfModelData object back out to URDF for round-trip workflows.

The parser is stateless — no per-instance configuration is required; options that influence parsing belong on UrdfImportOptions and are consumed by SceneBuilderEngine.

Methods

Method Description
parse_file(urdf_path) -> UrdfModelData Parse a URDF file from disk.
write_string(model) -> str Serialize UrdfModelData to a URDF XML string.
write_file(model, urdf_path) -> None Serialize UrdfModelData to a file.

Example

import novaphy

parser = novaphy.UrdfParser()
data = parser.parse_file("robot.urdf")

# Round-trip the parsed asset representation.
parser.write_file(data, "robot_roundtrip.urdf")

# Build a simulation model separately.
result = novaphy.SceneBuilderEngine().build_from_urdf(
    data, novaphy.UrdfImportOptions()
)

Notes

  • Mesh references (<mesh filename="...">) are resolved relative to the URDF file's directory, recording resolved_mesh_filename and mesh_file_exists. Triangle/convex mesh geometry is loaded later by the scene builder when the selected collision mode requires it.
  • .xacro files receive a minimal pre-pass for simple <xacro:macro ... /> expansion and $(find package) substitutions. Full ROS xacro constructs such as includes, properties, conditionals, and block macros are not expanded; inspect SceneBuilderEngine.audit_urdf(...) for unsupported-xacro warnings.
  • parse_file raises a Python exception on malformed XML; wrap the call in a try / except if you accept user-supplied URDF.

See Also