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, recordingresolved_mesh_filenameandmesh_file_exists. Triangle/convex mesh geometry is loaded later by the scene builder when the selected collision mode requires it. .xacrofiles 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; inspectSceneBuilderEngine.audit_urdf(...)for unsupported-xacro warnings.parse_fileraises a Python exception on malformed XML; wrap the call in atry/exceptif you accept user-supplied URDF.