urdf

    URDF modeling, kinematics, inertia, parsing, and ROS bundle export for MoonBit

    cad
    3d
    ros
    urdf
    Download zip
    Author
    Version
    0.2.27
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    507

    #gmlewis/urdf (MoonBit)

    moonbit step mascot

    A URDF (Unified Robot Description Format) library for MoonBit: a typed robot model, a fluent builder DSL, analytical and triangle-mesh inertia math, mate-connector snapping, forward kinematics, a lossless XML parser, deterministic serialization, validation diagnostics, and multi-file ROS package export.

    gmlewis/urdf reuses the shared mate-connector types from gmlewis/step/components/common, so a connector authored on a component snaps the same way in the CAD and robotics pipelines. It is the robotics pillar that the upcoming gmlewis/cad package imports alongside gmlewis/step.

    #Quick start

    let robot = @urdf.Robot::new("demo")
    .add_link(
    @urdf.Link::new("base").with_inertial(
    @urdf.Inertial::from_box_density(
    0.2, 0.1, 0.05, density=@urdf.Density::aluminum_6061(),
    ),
    ).add_visual(
    @urdf.Visual::new(@urdf.Geometry::box(0.2, 0.1, 0.05))
    .with_color("body", @urdf.Rgba::orange()),
    ),
    )
    .add_link(@urdf.Link::new("arm"))
    .add_joint(
    @urdf.Joint::revolute(
    "shoulder",
    parent="base",
    child="arm",
    axis=(0.0, 1.0, 0.0),
    limit=@urdf.JointLimit::new(
    lower=Some(-1.5), upper=Some(1.5), effort=10.0, velocity=2.0,
    ),
    ),
    )

    robot.write_urdf(Some("demo.urdf"), checked=true)

    Round-tripping the model is also exercised by the test suite:

    ///|
    test "serialize and reparse a two-link robot" {
    let robot = @urdf.Robot::new("demo")
    .add_link(@urdf.Link::new("base"))
    .add_link(@urdf.Link::new("arm"))
    .add_joint(
    @urdf.Joint::revolute(
    "shoulder",
    parent="base",
    child="arm",
    axis=(0.0, 0.0, 1.0),
    limit=@urdf.JointLimit::new(
    lower=Some(-1.5),
    upper=Some(1.5),
    effort=10.0,
    velocity=2.0,
    ),
    ),
    )
    let xml = robot.to_urdf_xml()
    inspect(xml.contains("<robot name=\"demo\">"), content="true")
    match @urdf.parse_urdf_from_string_result(xml) {
    @urdf.ParseUrdfResult::Ok(parsed) =>
    inspect(parsed.links.length(), content="2")
    @urdf.ParseUrdfResult::Err(info) =>
    fail(@urdf.format_urdf_parse_error(info))
    }
    }

    #Mate connectors and kinematics

    ///|
    let hip = @urdf.MateConnector::from_mm_deg("hip", x=100.0, axis=(1.0, 0.0, 0.0))

    ///|
    let leg = @urdf.MateConnector::new("leg_mount")

    ///|
    let joint = @urdf.Joint::from_mates(
    "hip_joint",
    @urdf.JointType::Revolute,
    parent_link="base",
    parent_mate=hip,
    child_link="leg",
    child_mate=leg,
    limit=Some(@urdf.JointLimit::new(effort=20.0, velocity=5.0)),
    )

    ///|
    let poses = robot.forward_kinematics(joint_positions={ "hip_joint": 0.5 })

    Joint axes follow the shared MatePair::resolve convention, including the anti-parallel insertion rule for shaft/bore and plane/plane interfaces, so a joint points the same way as the CAD-side mate.

    #Inertia from CAD meshes

    // triangles is Array[(Vec3, Vec3, Vec3)] in millimeters.

    ///|
    let inertial = @urdf.Inertial::from_triangles_mm(
    triangles,
    density=@urdf.Density::pla(),
    )

    #Lossless parsing

    match @urdf.parse_urdf_from_string_result(xml) {
    @urdf.ParseUrdfResult::Ok(robot) => { /* ... */ }
    @urdf.ParseUrdfResult::Err(info) =>
    println(@urdf.format_urdf_parse_error(info))
    }

    Unknown elements such as <gazebo> and <ros2_control> are preserved in Robot.extra, Link.extra, and Joint.extra and survive serialization.

    #Pairing with gmlewis/step

    gmlewis/cad composes parameterized mechanical components and emits STEP, glTF, and URDF from one model. gmlewis/step owns B-Rep/STEP, gmlewis/urdf owns links, joints, inertial properties, mate snapping, forward kinematics, and ROS package bundles. Mates live in gmlewis/step/components/common, which gmlewis/urdf builds on; gmlewis/cad imports both.

    #Validation

    ./test-all.sh # moon fmt, moon info, moon test python3 scripts/validate_urdf_test.py # validator self-tests python3 scripts/validate_urdf.py robot.urdf # structural/physics checks

    Robot::diagnostics() reports topological errors (missing links, multiple parents, cycles, disconnected roots) and physical warnings (non-positive mass, non-physical inertia), while Robot::write_urdf(..., checked=true) refuses to write an invalid model.

    #API documentation

    Doc comments on every public declaration feed hover docs in editors and the command line:

    moon doc # static site into _build/doc/ moon doc --serve # ... served locally moon ide doc 'Robot' # a type and its methods moon ide doc 'Robot::new' # signature + doc for one symbol moon ide doc '' # every symbol in the package

    moon info regenerates pkg.generated.mbti, the committed public-API surface; CI fails on unreviewed changes to it.

    #License

    Apache-2.0

    #Status

    The code has been updated to support compiler:

    $ moon version --all moon 0.1.20261126 (ccd306a 2026-11-26) ~/.moon/bin/moon moonc v1.0.0-rc1+3c0520448 (2026-11-26) ~/.moon/bin/moonc moonrun 0.1.20261126 (ccd306a 2026-11-26) ~/.moon/bin/moonrun

    MateConnector

    A named attachment frame on a component.

    The canonical definition lives in gmlewis/step/components/common; this alias keeps the URDF-facing name without defining a second struct. The shared connector stores millimetres and degrees internally and provides from_m_rad / to_m_rad for the URDF XML boundary.

    Vec3

    type Vec3 = (Double, Double, Double)

    A 3-component vector: (x, y, z).

    UrdfParseError

    pub suberror UrdfParseError {
    UrdfParseError(UrdfParseErrorInfo)
    }

    Error raised by the URDF parser. Carries a structured UrdfParseErrorInfo; format it for display with format_urdf_parse_error.

    Actuator

    pub(all) struct Actuator {
    name : String
    hardware_interfaces : Array[String]
    mechanical_reduction : Double?
    } derive(Eq,
    Debug
    )

    A transmission actuator entry.

    Actuator::equal

    fn Actuator::equal(Actuator, Actuator) -> Bool
    automatically derived

    Actuator::not_equal

    fn Actuator::not_equal(x : Actuator, y : Actuator) -> Bool
    automatically derived

    Actuator::to_repr

    automatically derived

    Angle

    pub struct Angle {
    radians : Double
    }

    An angle stored internally in radians (the URDF/SI unit).
    impl Add for Angle
    impl Neg for Angle
    impl Sub for Angle

    Angle::add

    fn Angle::add(self : Angle, other : Angle) -> Angle

    Angle::deg

    fn Angle::deg(value : Double) -> Angle

    Creates an Angle from a value in degrees, converting to radians internally.

    Angle::neg

    fn Angle::neg(self : Angle) -> Angle

    Angle::rad

    fn Angle::rad(value : Double) -> Angle

    Creates an Angle from a value in radians, the URDF/SI base unit.

    Angle::sub

    fn Angle::sub(self : Angle, other : Angle) -> Angle

    Angle::to_deg

    fn Angle::to_deg(self : Angle) -> Double

    Returns the angle in degrees.

    Angle::to_rad

    fn Angle::to_rad(self : Angle) -> Double

    Returns the angle in radians.

    Collision

    pub(all) struct Collision {
    name : String?
    origin : Origin
    geometry : Geometry
    } derive(Eq,
    Debug
    )

    A collision element on a link.

    Collision::equal

    fn Collision::equal(Collision, Collision) -> Bool
    automatically derived

    Collision::new

    fn Collision::new(geometry : Geometry, name? : String?, origin? : Origin) -> Collision

    Builds a collision element for geometry; name defaults to no name and origin to the identity frame. Geometry dimensions are in metres.

    Collision::not_equal

    fn Collision::not_equal(x : Collision, y : Collision) -> Bool
    automatically derived

    Collision::to_repr

    automatically derived

    Collision::with_name

    fn Collision::with_name(self : Collision, name : String) -> Collision

    Returns a copy of this collision with name set; the receiver is returned unmodified.

    Collision::with_origin

    fn Collision::with_origin(self : Collision, origin : Origin) -> Collision

    Returns a copy of this collision with its <origin> replaced by origin.

    Density

    pub struct Density {
    kg_per_m3 : Double
    }

    A material density stored internally in kg/m³ (the URDF/SI unit).

    Density::abs

    fn Density::abs() -> Density

    Common FDM 3D-printing filament: ABS.

    Density::aluminum_6061

    fn Density::aluminum_6061() -> Density

    Aluminum 6061 alloy.

    Density::brass

    fn Density::brass() -> Density

    Brass, typical of standoffs and bushings.

    Density::carbon_fiber

    fn Density::carbon_fiber() -> Density

    Carbon-fiber composite (approximate).

    Density::cf_nylon

    fn Density::cf_nylon() -> Density

    Carbon-fiber reinforced nylon, typical of printed structural links.

    Density::delrin

    fn Density::delrin() -> Density

    Acetal (Delrin/POM), typical of low-friction bushings and gears.

    Density::fr4_pcb

    fn Density::fr4_pcb() -> Density

    FR-4 printed-circuit board (approximate, copper included).

    Density::g_per_cm3

    fn Density::g_per_cm3(value : Double) -> Density

    Creates a Density from a value in grams per cubic centimeter (1 g/cm³ = 1000 kg/m³).

    Density::kg_per_m3

    fn Density::kg_per_m3(value : Double) -> Density

    Creates a Density from a value in kilograms per cubic meter, the URDF/SI base unit.

    Density::lipo_battery

    fn Density::lipo_battery() -> Density

    Lithium-polymer battery pack, including cells, packaging, and wiring.

    Density::petg

    fn Density::petg() -> Density

    Common FDM 3D-printing filament: PETG.

    Density::pla

    fn Density::pla() -> Density

    Common FDM 3D-printing filament: PLA.

    Density::rubber

    fn Density::rubber() -> Density

    Rubber, typical of tires, feet, and vibration isolators.

    Density::steel

    fn Density::steel() -> Density

    Short alias for mild steel (steel_mild), the material robotics builders reach for most often.

    Density::steel_mild

    fn Density::steel_mild() -> Density

    Mild steel.

    Density::titanium

    fn Density::titanium() -> Density

    Titanium alloy (approximate).

    Density::to_kg_per_m3

    fn Density::to_kg_per_m3(self : Density) -> Double

    Returns the density in kilograms per cubic meter.

    Density::tpu

    fn Density::tpu() -> Density

    Common FDM 3D-printing filament: TPU.

    Diagnostic

    pub(all) enum Diagnostic {
    EmptyRobot(String)
    DuplicateLinkName(String)
    DuplicateJointName(String)
    MissingParentLink(String, String)
    MissingChildLink(String, String)
    SelfLoopJoint(String, String)
    MultipleParentJoints(String)
    KinematicCycle(String)
    DisconnectedGraph(String)
    ZeroJointAxis(String)
    MissingJointLimit(String)
    InvalidJointLimit(String, String)
    InvalidMimicJoint(String, String)
    InvalidGeometry(String, String)
    NonPositiveMass(String, Double)
    NonPhysicalInertia(String, String)
    } derive(Eq,
    Debug
    )

    One validation finding about a robot model; see the variants for the topological and physical checks performed by Robot::diagnostics.

    Diagnostic::equal

    fn Diagnostic::equal(Diagnostic, Diagnostic) -> Bool
    automatically derived

    Diagnostic::message

    fn Diagnostic::message(self : Diagnostic) -> String

    Human-readable one-line description of the diagnostic, including the offending link/joint name and a detail string where applicable.

    Diagnostic::not_equal

    fn Diagnostic::not_equal(x : Diagnostic, y : Diagnostic) -> Bool
    automatically derived

    Diagnostic::severity

    fn Diagnostic::severity(self : Diagnostic) -> Severity

    Classifies this diagnostic. Mass/inertia problems are reported as Warning; every structural problem (duplicates, missing references, cycles, invalid limits, bad geometry) is an Error.

    Diagnostic::to_repr

    automatically derived

    Geometry

    pub(all) enum Geometry {
    Box((Double, Double, Double))
    Cylinder(Double, Double)
    Sphere(Double)
    Mesh(String, (Double, Double, Double)?)
    } derive(Eq,
    Debug
    )

    The shape of a link's visual or collision geometry.

    Geometry::box

    fn Geometry::box(sx : Double, sy : Double, sz : Double) -> Geometry

    Creates a box geometry with side lengths sx, sy, sz in metres.

    Geometry::box_mm

    fn Geometry::box_mm(sx_mm : Double, sy_mm : Double, sz_mm : Double) -> Geometry

    Creates a box geometry from side lengths in millimetres, converted to metres.

    Geometry::cylinder

    fn Geometry::cylinder(radius : Double, length : Double) -> Geometry

    Creates a cylinder with radius and length in metres, its axis along the local Z axis.

    Geometry::cylinder_mm

    fn Geometry::cylinder_mm(radius_mm : Double, length_mm : Double) -> Geometry

    Creates a cylinder from radius_mm and length_mm in millimetres, converted to metres; axis along local Z.

    Geometry::equal

    fn Geometry::equal(Geometry, Geometry) -> Bool
    automatically derived

    Geometry::mesh

    fn Geometry::mesh(filename : String, scale? : (Double, Double, Double)?) -> Geometry

    Creates a mesh geometry referencing filename (resolved by the consumer, typically relative to the URDF file) with an optional per-axis scale.

    Geometry::mesh_mm

    fn Geometry::mesh_mm(filename : String) -> Geometry

    Creates a mesh geometry referencing filename (typically in millimetre units) with a uniform 0.001 scale, yielding metre-sized geometry.

    Geometry::not_equal

    fn Geometry::not_equal(x : Geometry, y : Geometry) -> Bool
    automatically derived

    Geometry::sphere

    fn Geometry::sphere(radius : Double) -> Geometry

    Creates a sphere with radius in metres.

    Geometry::sphere_mm

    fn Geometry::sphere_mm(radius_mm : Double) -> Geometry

    Creates a sphere from radius_mm in millimetres, converted to metres.

    Geometry::to_repr

    automatically derived

    Inertia

    pub(all) struct Inertia {
    ixx : Double
    ixy : Double
    ixz : Double
    iyy : Double
    iyz : Double
    izz : Double
    } derive(Eq,
    Debug
    )

    The symmetric 3x3 inertia tensor of a rigid body.

    Inertia::add

    fn Inertia::add(self : Inertia, other : Inertia) -> Inertia

    Element-wise sum of two inertia tensors (kg·m²), useful for combining rigid sub-parts expressed in the same frame.

    Inertia::diagonal

    fn Inertia::diagonal(ixx : Double, iyy : Double, izz : Double) -> Inertia

    Creates a diagonal tensor from the three principal moments in kg*m^2; all Ixy/Ixz/Iyz products are zero.

    Inertia::equal

    fn Inertia::equal(Inertia, Inertia) -> Bool
    automatically derived

    Inertia::from_matrix

    fn Inertia::from_matrix(m : Matrix3x3) -> Inertia

    Builds an Inertia (tensor units kg·m²) from a 3x3 matrix. Off-diagonal entries are symmetrized by averaging m[i][j] and m[j][i], so a slightly asymmetric matrix still yields a valid symmetric inertia tensor. The tensor is expressed in the same frame as m.

    Inertia::new

    fn Inertia::new(ixx~ : Double, iyy~ : Double, izz~ : Double, ixy? : Double, ixz? : Double, iyz? : Double) -> Inertia

    Creates a tensor from explicit components in kg*m^2; the off-diagonal products default to zero.

    Inertia::not_equal

    fn Inertia::not_equal(x : Inertia, y : Inertia) -> Bool
    automatically derived

    Inertia::rotate

    fn Inertia::rotate(self : Inertia, rot : Matrix3x3) -> Inertia

    Rotates the inertia tensor into a new frame: R * I * R^T.

    Inertia::scale

    fn Inertia::scale(self : Inertia, factor : Double) -> Inertia

    Multiplies every component of the inertia tensor (kg·m²) by factor; scales a tensor by a unitless scalar such as a mass ratio.

    Inertia::shift_by_offset

    fn Inertia::shift_by_offset(self : Inertia, mass : Double, d : (Double, Double, Double)) -> Inertia

    Applies the parallel-axis theorem, shifting the tensor from the center of mass by displacement d.

    Inertia::to_matrix

    fn Inertia::to_matrix(self : Inertia) -> Matrix3x3

    Inertia::to_repr

    automatically derived

    Inertia::zero

    fn Inertia::zero() -> Inertia

    Returns the zero tensor: every component, including the products of inertia, is zero.

    Inertial

    pub(all) struct Inertial {
    origin : Origin
    mass : Double
    inertia : Inertia
    } derive(Eq,
    Debug
    )

    The inertial properties of a link: center-of-mass frame, mass, and tensor.

    Inertial::combine

    fn Inertial::combine(parts : Array[Inertial]) -> Inertial

    Combines rigid sub-parts, expressed in the same link frame, into one equivalent inertial whose origin is the combined center of mass.

    Inertial::equal

    fn Inertial::equal(Inertial, Inertial) -> Bool
    automatically derived

    Inertial::from_box

    fn Inertial::from_box(sx : Double, sy : Double, sz : Double, mass~ : Double, origin? : Origin) -> Inertial

    Solid box with side lengths sx, sy, sz (m), centered on the origin of its inertial frame and axis-aligned with it. The resulting tensor (kg·m²) is diagonal with mass*(sy²+sz²)/12 etc. origin records where the box's center of mass sits relative to the parent link frame; mass is in kg.

    Inertial::from_box_density

    fn Inertial::from_box_density(sx : Double, sy : Double, sz : Double, density~ : Density, origin? : Origin) -> Inertial

    Like Inertial::from_box, but derives the mass from the box volume (m³) and density (kg/m³) instead of taking it explicitly.

    Inertial::from_cylinder

    fn Inertial::from_cylinder(radius : Double, length : Double, mass~ : Double, origin? : Origin) -> Inertial

    Solid cylinder with radius (m) and length (m), centered on the origin of its inertial frame with its axis along the local z axis. The resulting tensor (kg·m²) is diagonal with izz = mass*r²/2 about the axis and ixx = iyy = mass*(3r²+L²)/12 perpendicular to it. mass is in kg.

    Inertial::from_cylinder_density

    fn Inertial::from_cylinder_density(radius : Double, length : Double, density~ : Density, origin? : Origin) -> Inertial

    Like Inertial::from_cylinder, but derives the mass from the cylinder volume (m³) and density (kg/m³) instead of taking it explicitly.

    Inertial::from_geometry_density

    fn Inertial::from_geometry_density(geom : Geometry, density~ : Density, origin? : Origin) -> Inertial?

    Builds an Inertial from a Geometry and a density (kg/m³), deriving mass from the primitive's volume. Returns None for Mesh geometries, whose volume is not known analytically; use Inertial::from_triangles or from_triangles_mm for meshes instead.

    Inertial::from_sphere

    fn Inertial::from_sphere(radius : Double, mass~ : Double, origin? : Origin) -> Inertial

    Solid sphere of radius (m), centered on the origin of its inertial frame. The resulting tensor (kg·m²) is isotropic: i = 2/5 * mass * r² on every diagonal entry. mass is in kg.

    Inertial::from_sphere_density

    fn Inertial::from_sphere_density(radius : Double, density~ : Density, origin? : Origin) -> Inertial

    Like Inertial::from_sphere, but derives the mass from the sphere volume (m³) and density (kg/m³) instead of taking it explicitly.

    Inertial::from_triangles

    fn Inertial::from_triangles(triangles : Array[((Double, Double, Double), (Double, Double, Double), (Double, Double, Double))], density~ : Density, scale? : Double) -> Inertial

    Computes exact mass properties from a closed triangle mesh using signed tetrahedron integration.

    Inertial::from_triangles_mm

    fn Inertial::from_triangles_mm(triangles : Array[((Double, Double, Double), (Double, Double, Double), (Double, Double, Double))], density~ : Density) -> Inertial

    Convenience wrapper for triangle meshes authored in millimeters.

    Inertial::from_tube

    fn Inertial::from_tube(inner_radius : Double, outer_radius : Double, length : Double, mass~ : Double, origin? : Origin) -> Inertial

    Hollow (tube) cylinder with inner_radius, outer_radius, and length (all m), centered on the origin of its inertial frame with its axis along the local z axis. Masses are in kg and the resulting tensor (kg·m²) is diagonal, with the axial term izz = mass*(r_o²+r_i²)/2.

    Inertial::from_tube_density

    fn Inertial::from_tube_density(inner_radius : Double, outer_radius : Double, length : Double, density~ : Density, origin? : Origin) -> Inertial

    Like Inertial::from_tube, but derives the mass from the annular cross-section area (m²), length (m), and density (kg/m³).

    Inertial::new

    fn Inertial::new(mass : Double, inertia : Inertia, origin? : Origin) -> Inertial

    Builds the inertial properties of a link from mass in kilograms and inertia in kg·m^2; origin locates the center-of-mass frame relative to the link frame and defaults to the link frame.

    Inertial::not_equal

    fn Inertial::not_equal(x : Inertial, y : Inertial) -> Bool
    automatically derived

    Inertial::to_repr

    automatically derived

    Inertial::transform_by

    fn Inertial::transform_by(self : Inertial, parent_transform : Transform) -> Inertial

    Maps an inertial frame through a parent transform. The local inertia tensor is unchanged because the URDF <inertial><origin> defines both the center of mass and the tensor's orientation.

    Inertial::with_origin

    fn Inertial::with_origin(self : Inertial, origin : Origin) -> Inertial

    Returns a copy of this inertial with its center-of-mass origin replaced.

    Joint

    pub(all) struct Joint {
    name : String
    joint_type : JointType
    origin : Origin
    parent : String
    child : String
    axis : (Double, Double, Double)
    limit : JointLimit?
    dynamics : JointDynamics?
    calibration : JointCalibration?
    safety_controller : SafetyController?
    mimic : JointMimic?
    extra : Array[RawXmlNode]
    } derive(Eq,
    Debug
    )

    A kinematic joint connecting a parent link to a child link.

    Joint::add_extra

    fn Joint::add_extra(self : Joint, node : RawXmlNode) -> Joint

    Returns a copy of this joint with node appended to the verbatim extension nodes preserved on serialization.

    Joint::continuous

    fn Joint::continuous(name : String, parent~ : String, child~ : String, origin? : Origin, axis? : (Double, Double, Double), limit? : JointLimit?) -> Joint

    Builds a continuous (unbounded rotation) joint about axis (default z). limit, when given, carries effort (N·m) and velocity (rad/s); URDF ignores lower/upper for continuous joints.

    Joint::equal

    fn Joint::equal(Joint, Joint) -> Bool
    automatically derived

    Joint::fixed

    fn Joint::fixed(name : String, parent~ : String, child~ : String, origin? : Origin) -> Joint

    Builds a fixed joint (no motion) between parent and child with the given origin.

    Joint::floating

    fn Joint::floating(name : String, parent~ : String, child~ : String, origin? : Origin) -> Joint

    Builds a floating joint with six degrees of freedom between parent and child; axis and limit are not used.

    Joint::from_mates

    fn Joint::from_mates(name : String, joint_type : JointType, parent_link~ : String, parent_mate~ :
    MateConnector
    , child_link~ : String, child_mate~ :
    MateConnector
    , offset? : Double, angle_rad? : Double, flip_axis? : Bool, limit? : JointLimit?, dynamics? : JointDynamics?) -> Joint

    Builds a joint by snapping a child component's mate onto a parent's mate.

    Joint::from_pair

    fn Joint::from_pair(name : String, joint_type : JointType, parent_link~ : String, parent_mate~ :
    MateConnector
    , child_link~ : String, child_mate~ :
    MateConnector
    , pair~ :
    MatePair
    , limit? : JointLimit?, dynamics? : JointDynamics?) -> Joint

    Builds a joint from a shared mate pair.

    The pair owns the parent/child connector names, offset, twist, and flip; kinematic data stays in the joint arguments. Callers that already use @step_common.MatePair can pass it directly instead of restating its geometric fields.

    Joint::mimic_joint

    fn Joint::mimic_joint(self : Joint, driver_joint : String, multiplier? : Double, offset? : Double) -> Joint

    Couples this joint to driver_joint with <mimic> multiplier and offset: q_this = multiplier * q_driver + offset.

    Joint::new

    fn Joint::new(name : String, joint_type : JointType, parent~ : String, child~ : String, origin? : Origin, axis? : (Double, Double, Double)) -> Joint

    Builds a joint of joint_type connecting the parent link to the child link. origin locates the child frame relative to the parent at zero joint position; axis (default (1, 0, 0)) is the motion axis in the child frame — a unit vector, joint rotation in radians, prismatic travel in metres.

    Joint::not_equal

    fn Joint::not_equal(x : Joint, y : Joint) -> Bool
    automatically derived

    Joint::planar

    fn Joint::planar(name : String, parent~ : String, child~ : String, origin? : Origin, axis? : (Double, Double, Double)) -> Joint

    Builds a planar joint allowing translation in the plane perpendicular to axis (default z) plus rotation about it.

    Joint::prismatic

    fn Joint::prismatic(name : String, parent~ : String, child~ : String, limit~ : JointLimit, origin? : Origin, axis? : (Double, Double, Double)) -> Joint

    Builds a prismatic joint translating along axis (default z) whose limit is required; lower/upper are in metres, effort in N and velocity in m/s.

    Joint::revolute

    fn Joint::revolute(name : String, parent~ : String, child~ : String, limit~ : JointLimit, origin? : Origin, axis? : (Double, Double, Double)) -> Joint

    Builds a revolute joint rotating about axis (default z) whose limit is required; lower/upper are in radians, effort in N·m and velocity in rad/s.

    Joint::to_repr

    automatically derived

    Joint::with_axis

    fn Joint::with_axis(self : Joint, axis : (Double, Double, Double)) -> Joint

    Returns a copy of this joint with its axis of motion set to axis, which should be a unit vector.

    Joint::with_calibration

    fn Joint::with_calibration(self : Joint, calibration : JointCalibration) -> Joint

    Returns a copy of this joint with calibration (rising/falling reference positions, in the joint's units) attached.

    Joint::with_dynamics

    fn Joint::with_dynamics(self : Joint, dynamics : JointDynamics) -> Joint

    Returns a copy of this joint with dynamics (viscous damping and Coulomb friction) attached.

    Joint::with_gear_reduction

    fn Joint::with_gear_reduction(self : Joint, driver_joint : String, reduction : Double, offset? : Double) -> Joint

    Couples this joint to driver_joint through a mechanical gear reduction reduction (e.g. 5.0 for a 5:1 planetary stage so output turns at 1/5 the speed of driver_joint; negative values reverse direction).

    Joint::with_limit

    fn Joint::with_limit(self : Joint, limit : JointLimit) -> Joint

    Returns a copy of this joint with limit attached; required for revolute and prismatic joints (bounds in radians or metres respectively).

    Joint::with_mimic

    fn Joint::with_mimic(self : Joint, mimic : JointMimic) -> Joint

    Returns a copy of this joint coupled to another joint via <mimic>: this joint's position equals multiplier * driver + offset.

    Joint::with_origin

    fn Joint::with_origin(self : Joint, origin : Origin) -> Joint

    Returns a copy of this joint with its <origin> replaced.

    Joint::with_safety_controller

    fn Joint::with_safety_controller(self : Joint, controller : SafetyController) -> Joint

    Returns a copy of this joint with controller (soft position/velocity limits and stiffness gains) attached.

    JointCalibration

    pub(all) struct JointCalibration {
    rising : Double?
    falling : Double?
    } derive(Eq,
    Debug
    )

    Joint calibration reference positions.

    JointCalibration::equal

    automatically derived

    JointCalibration::not_equal

    fn JointCalibration::not_equal(x : JointCalibration, y : JointCalibration) -> Bool
    automatically derived

    JointCalibration::to_repr

    automatically derived

    JointDynamics

    pub(all) struct JointDynamics {
    damping : Double
    friction : Double
    } derive(Eq,
    Debug
    )

    Joint damping and friction.

    JointDynamics::equal

    automatically derived

    JointDynamics::new

    fn JointDynamics::new(damping? : Double, friction? : Double) -> JointDynamics

    Creates joint dynamics coefficients in joint-appropriate units; both default to 0.0.

    JointDynamics::not_equal

    fn JointDynamics::not_equal(x : JointDynamics, y : JointDynamics) -> Bool
    automatically derived

    JointDynamics::to_repr

    automatically derived

    JointLimit

    pub(all) struct JointLimit {
    lower : Double?
    upper : Double?
    effort : Double
    velocity : Double
    } derive(Eq,
    Debug
    )

    Joint travel limits.

    JointLimit::equal

    fn JointLimit::equal(JointLimit, JointLimit) -> Bool
    automatically derived

    JointLimit::new

    fn JointLimit::new(effort~ : Double, velocity~ : Double, lower? : Double?, upper? : Double?) -> JointLimit

    Creates joint limits; effort and velocity are required, lower/upper are optional (omit for continuous joints).

    JointLimit::not_equal

    fn JointLimit::not_equal(x : JointLimit, y : JointLimit) -> Bool
    automatically derived

    JointLimit::to_repr

    automatically derived

    JointMimic

    pub(all) struct JointMimic {
    joint : String
    multiplier : Double
    offset : Double
    } derive(Eq,
    Debug
    )

    A joint whose motion is derived from another joint.

    JointMimic::equal

    fn JointMimic::equal(JointMimic, JointMimic) -> Bool
    automatically derived

    JointMimic::new

    fn JointMimic::new(joint : String, multiplier? : Double, offset? : Double) -> JointMimic

    Creates a mimic declaration for joint; multiplier defaults to 1.0 and offset to 0.0.

    JointMimic::not_equal

    fn JointMimic::not_equal(x : JointMimic, y : JointMimic) -> Bool
    automatically derived

    JointMimic::to_repr

    automatically derived

    JointType

    pub(all) enum JointType {
    Revolute
    Continuous
    Prismatic
    Fixed
    Floating
    Planar
    } derive(Eq,
    Debug
    )

    The kind of motion a joint permits.

    JointType::equal

    fn JointType::equal(JointType, JointType) -> Bool
    automatically derived

    JointType::from_urdf_str

    fn JointType::from_urdf_str(s : String) -> JointType?

    Parses a URDF joint type attribute; returns None for unrecognized strings.

    JointType::not_equal

    fn JointType::not_equal(x : JointType, y : JointType) -> Bool
    automatically derived

    JointType::to_repr

    automatically derived

    JointType::to_urdf_str

    fn JointType::to_urdf_str(self : JointType) -> String

    Returns the URDF attribute string for this joint type, e.g. "revolute".

    Length

    pub struct Length {
    meters : Double
    }

    A length stored internally in meters (the URDF/SI unit).
    impl Add for Length
    impl Neg for Length
    impl Sub for Length

    Length::add

    fn Length::add(self : Length, other : Length) -> Length

    Length::cm

    fn Length::cm(value : Double) -> Length

    Creates a Length from a value in centimeters (1 cm = 0.01 m).

    Length::inches

    fn Length::inches(value : Double) -> Length

    Creates a Length from a value in international inches (1 in = 0.0254 m).

    Length::m

    fn Length::m(value : Double) -> Length

    Creates a Length from a value in meters, the URDF/SI base unit.

    Length::mm

    fn Length::mm(value : Double) -> Length

    Creates a Length from a value in millimeters (1 mm = 0.001 m).

    Length::neg

    fn Length::neg(self : Length) -> Length

    Length::scale

    fn Length::scale(self : Length, factor : Double) -> Length

    Returns a new Length scaled by factor (unitless); the result stays in meters.

    Length::sub

    fn Length::sub(self : Length, other : Length) -> Length

    Length::to_m

    fn Length::to_m(self : Length) -> Double

    Returns the length in meters.

    Length::to_mm

    fn Length::to_mm(self : Length) -> Double

    Returns the length in millimeters.
    pub(all) struct Link {
    name : String
    inertial : Inertial?
    visuals : Array[Visual]
    collisions : Array[Collision]
    extra : Array[RawXmlNode]
    } derive(Eq,
    Debug
    )

    A rigid link in the robot tree.

    Link::add_collision

    fn Link::add_collision(self : Link, collision : Collision) -> Link

    Returns a copy of this link with collision appended; the original link's array is left unmodified.

    Link::add_extra

    fn Link::add_extra(self : Link, node : RawXmlNode) -> Link

    Returns a copy of this link with node appended to the verbatim extension nodes preserved on serialization.

    Link::add_visual

    fn Link::add_visual(self : Link, visual : Visual) -> Link

    Returns a copy of this link with visual appended; the original link's array is left unmodified.

    Link::equal

    fn Link::equal(Link, Link) -> Bool
    automatically derived

    Link::new

    fn Link::new(name : String) -> Link

    Creates an empty link named name with no inertial, no visuals, no collisions and no extension nodes.

    Link::not_equal

    fn Link::not_equal(x : Link, y : Link) -> Bool
    automatically derived

    Link::rebase_to_mate

    Moves the link's coordinate frame onto mate, rewriting every inertial, visual, and collision origin accordingly. This is what makes a component modeled around its own center usable as a URDF child link, whose pivot is always at the link origin.

    Link::to_repr

    automatically derived

    Link::with_body

    fn Link::with_body(self : Link, geometry : Geometry, name? : String?, origin? : Origin, material? : Material?) -> Link

    Adds both a Visual and a matching Collision sharing geometry and origin to this link in a single fluent call.

    Link::with_colored_body

    fn Link::with_colored_body(self : Link, geometry : Geometry, color_name : String, color : Rgba, name? : String?, origin? : Origin) -> Link

    Convenience shorthand for Link::with_body with an inline color material.

    Link::with_inertial

    fn Link::with_inertial(self : Link, inertial : Inertial) -> Link

    Returns a copy of this link with inertial set, replacing any existing inertial.

    LoopConstraint

    pub(all) struct LoopConstraint {
    name : String
    body1 : String
    anchor1 : (Double, Double, Double)
    body2 : String
    anchor2 : (Double, Double, Double)
    } derive(Eq,
    Debug
    )

    A closed-chain constraint between two link frames. Anchors are metres in each link's local frame.

    LoopConstraint::connect

    fn LoopConstraint::connect(name~ : String, body1~ : String, anchor1~ : (Double, Double, Double), body2~ : String, anchor2~ : (Double, Double, Double)) -> LoopConstraint

    LoopConstraint::connect builds a closed-chain constraint.

    Mass

    pub struct Mass {
    kilograms : Double
    }

    A mass stored internally in kilograms (the URDF/SI unit).
    impl Add for Mass
    impl Sub for Mass

    Mass::add

    fn Mass::add(self : Mass, other : Mass) -> Mass

    Mass::grams

    fn Mass::grams(value : Double) -> Mass

    Creates a Mass from a value in grams (1 g = 0.001 kg).

    Mass::kg

    fn Mass::kg(value : Double) -> Mass

    Creates a Mass from a value in kilograms, the URDF/SI base unit.

    Mass::lbs

    fn Mass::lbs(value : Double) -> Mass

    Creates a Mass from a value in avoirdupois pounds (1 lb = 0.45359237 kg).

    Mass::sub

    fn Mass::sub(self : Mass, other : Mass) -> Mass

    Mass::to_grams

    fn Mass::to_grams(self : Mass) -> Double

    Returns the mass in grams.

    Mass::to_kg

    fn Mass::to_kg(self : Mass) -> Double

    Returns the mass in kilograms.

    Material

    pub(all) struct Material {
    name : String
    color : Rgba?
    texture : String?
    } derive(Eq,
    Debug
    )

    A named material with an optional color and texture.

    Material::color_only

    fn Material::color_only(name : String, color : Rgba) -> Material

    Creates a material with the given RGBA color and no texture.

    Material::equal

    fn Material::equal(Material, Material) -> Bool
    automatically derived

    Material::new

    fn Material::new(name : String, color? : Rgba?, texture? : String?) -> Material

    Creates a material with the given name; color and texture are both optional.

    Material::not_equal

    fn Material::not_equal(x : Material, y : Material) -> Bool
    automatically derived

    Material::to_repr

    automatically derived

    Matrix3x3

    pub(all) struct Matrix3x3 {
    m00 : Double
    m01 : Double
    m02 : Double
    m10 : Double
    m11 : Double
    m12 : Double
    m20 : Double
    m21 : Double
    m22 : Double
    } derive(Eq,
    Debug
    )

    A 3x3 matrix stored in row-major order.

    Matrix3x3::apply

    fn Matrix3x3::apply(self : Matrix3x3, v : (Double, Double, Double)) -> (Double, Double, Double)

    Returns self applied to the column vector v.

    Matrix3x3::equal

    fn Matrix3x3::equal(Matrix3x3, Matrix3x3) -> Bool
    automatically derived

    Matrix3x3::identity

    fn Matrix3x3::identity() -> Matrix3x3

    Returns the 3x3 identity matrix.

    Matrix3x3::mul

    fn Matrix3x3::mul(self : Matrix3x3, other : Matrix3x3) -> Matrix3x3

    Returns the matrix product self * other in the standard row-major convention, i.e. other is applied to vectors before self.

    Matrix3x3::not_equal

    fn Matrix3x3::not_equal(x : Matrix3x3, y : Matrix3x3) -> Bool
    automatically derived

    Matrix3x3::to_repr

    automatically derived

    Matrix3x3::transpose

    fn Matrix3x3::transpose(self : Matrix3x3) -> Matrix3x3

    Returns the transpose of self; for an orthonormal rotation matrix this equals its inverse.

    MeshAsset

    pub(all) struct MeshAsset {
    rel_path : String
    bytes : Bytes
    }

    A mesh file to embed in the bundle, addressed by its bundle-relative path.

    MjcfActuator

    pub(all) enum MjcfActuator {
    Motor(String, String, Double, Double, Double)
    Position(String, String, Double, Double, Double, Double, Double?)
    Velocity(String, String, Double, Double, Double, Double?)
    } derive(Eq,
    Debug
    )

    One actuator declaration for the MJCF <actuator> section.

    The tuple fields are (joint, name, ...); use the snake-case constructors (MjcfActuator::motor, ::position, ::velocity) for readable call sites.

    MjcfActuator::motor

    fn MjcfActuator::motor(joint~ : String, name? : String, ctrl_min~ : Double, ctrl_max~ : Double, gear? : Double) -> MjcfActuator

    Emits a <motor> (direct torque/force actuator) into the MJCF <actuator> section, limited to [ctrl_min, ctrl_max]; gear is the motor-to-joint gear ratio and is omitted from the XML when it is 1.0.

    MjcfActuator::position

    fn MjcfActuator::position(joint~ : String, name? : String, kp~ : Double, kv~ : Double, ctrl_min~ : Double, ctrl_max~ : Double, forcerange? : Double) -> MjcfActuator

    Emits a <position> servo into the MJCF <actuator> section: proportional position control with gains kp (and derivative gain kv), control range [ctrl_min, ctrl_max], and an optional symmetric force limit (forcerange).

    MjcfActuator::velocity

    fn MjcfActuator::velocity(joint~ : String, name? : String, kv~ : Double, ctrl_min~ : Double, ctrl_max~ : Double, forcerange? : Double) -> MjcfActuator

    Emits a <velocity> servo into the MJCF <actuator> section: velocity control with gain kv, control range [ctrl_min, ctrl_max], and an optional symmetric force limit (forcerange).

    MjcfOptions

    pub(all) struct MjcfOptions {
    mesh_dir : String
    include_floor : Bool
    root_z_m : Double?
    home_qpos : Map[String, Double]
    actuators : Array[MjcfActuator]
    freeze_joints : Array[String]
    default_damping : Double
    default_armature : Double
    exclude_adjacent_contacts : Bool
    }

    Simulation-oriented MJCF options.

    The defaults reproduce the original exporter's structure; the CAD compiler fills these in for a standing-pose, contact-clean RL model.

    MjcfOptions::new

    fn MjcfOptions::new(mesh_dir? : String, include_floor? : Bool, root_z_m? : Double?, home_qpos? : Map[String, Double], actuators? : Array[MjcfActuator], freeze_joints? : Array[String], default_damping? : Double, default_armature? : Double, exclude_adjacent_contacts? : Bool) -> MjcfOptions

    Builds the options for Robot::to_mjcf_with_options. Loop-closure constraints from the robot are always emitted as <equality><connect> elements pairing two anchor sites, regardless of these options; the options control mesh location, floor, root height, keyframe, actuators, contact exclusions, and joint defaults.

    Origin

    pub(all) struct Origin {
    xyz : (Double, Double, Double)
    rpy : (Double, Double, Double)
    } derive(Eq,
    Debug
    )

    A URDF <origin>: translation in meters and fixed-axis roll/pitch/yaw in radians.

    Origin::equal

    fn Origin::equal(Origin, Origin) -> Bool
    automatically derived

    Origin::from_mm_deg

    fn Origin::from_mm_deg(x? : Double, y? : Double, z? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Origin

    Builds an origin from millimeter translations and degree rotations, which is the natural input unit for CAD-authored components.

    Origin::identity

    fn Origin::identity() -> Origin

    Returns the identity origin: zero translation and zero rotation.

    Origin::is_identity

    fn Origin::is_identity(self : Origin) -> Bool

    Returns true when every translation and rotation component is within 1e-12 of zero.

    Origin::new

    fn Origin::new(xyz? : (Double, Double, Double), rpy? : (Double, Double, Double)) -> Origin

    Creates an origin from a translation in metres and fixed-axis roll/pitch/yaw in radians; both default to zero.

    Origin::not_equal

    fn Origin::not_equal(x : Origin, y : Origin) -> Bool
    automatically derived

    Origin::to_repr

    automatically derived

    ParseUrdfResult

    pub(all) enum ParseUrdfResult {
    Ok(Robot)
    Err(UrdfParseErrorInfo)
    }

    Outcome of a non-raising URDF parse: either the parsed Robot or structured error details. Returned by parse_urdf_from_string_result for callers that prefer values over raise.

    RawXmlNode

    pub(all) struct RawXmlNode {
    tag : String
    attrs : Array[(String, String)]
    text : String
    children : Array[RawXmlNode]
    } derive(Eq,
    Debug
    )

    A verbatim XML element, used to preserve extension tags (<gazebo>, <ros2_control>, <sensor>, ...) across parse/serialize roundtrips.

    RawXmlNode::equal

    fn RawXmlNode::equal(RawXmlNode, RawXmlNode) -> Bool
    automatically derived

    RawXmlNode::not_equal

    fn RawXmlNode::not_equal(x : RawXmlNode, y : RawXmlNode) -> Bool
    automatically derived

    RawXmlNode::to_repr

    automatically derived

    Rgba

    pub(all) struct Rgba {
    r : Double
    g : Double
    b : Double
    a : Double
    } derive(Eq,
    Debug
    )

    An RGBA color, with each component in [0, 1].

    Rgba::black

    fn Rgba::black() -> Rgba

    Creates the opaque black preset, (0.0, 0.0, 0.0).

    Rgba::blue

    fn Rgba::blue() -> Rgba

    Creates the opaque steel-blue preset, (0.2, 0.6, 1.0).

    Rgba::cyan

    fn Rgba::cyan() -> Rgba

    Creates the opaque cyan preset, (0.0, 0.8, 0.8).

    Rgba::equal

    fn Rgba::equal(Rgba, Rgba) -> Bool
    automatically derived

    Rgba::green

    fn Rgba::green() -> Rgba

    Creates the opaque green preset, (0.0, 0.8, 0.0).

    Rgba::grey

    fn Rgba::grey() -> Rgba

    Creates the opaque dark grey preset, (0.2, 0.2, 0.2).

    Rgba::magenta

    fn Rgba::magenta() -> Rgba

    Creates the opaque magenta preset, (1.0, 0.0, 1.0).

    Rgba::new

    fn Rgba::new(r : Double, g : Double, b : Double, a? : Double) -> Rgba

    Creates an RGBA color from channels in [0, 1]; a defaults to 1.0 (opaque).

    Rgba::not_equal

    fn Rgba::not_equal(x : Rgba, y : Rgba) -> Bool
    automatically derived

    Rgba::orange

    fn Rgba::orange() -> Rgba

    Creates the opaque orange preset, (1.0, 0.6, 0.0).

    Rgba::purple

    fn Rgba::purple() -> Rgba

    Creates the opaque purple preset, (0.5, 0.0, 0.5).

    Rgba::red

    fn Rgba::red() -> Rgba

    Creates the opaque red preset, (0.8, 0.0, 0.0).

    Rgba::silver

    fn Rgba::silver() -> Rgba

    Creates the opaque light grey preset, (0.75, 0.75, 0.75).

    Rgba::to_repr

    automatically derived

    Rgba::white

    fn Rgba::white() -> Rgba

    Creates the opaque white preset, (1.0, 1.0, 1.0).

    Rgba::yellow

    fn Rgba::yellow() -> Rgba

    Creates the opaque yellow preset, (1.0, 1.0, 0.0).

    Robot

    pub(all) struct Robot {
    name : String
    version : String?
    documentation : String
    materials : Array[Material]
    links : Array[Link]
    joints : Array[Joint]
    transmissions : Array[Transmission]
    loop_constraints : Array[LoopConstraint]
    extra : Array[RawXmlNode]
    } derive(Eq,
    Debug
    )

    A complete URDF robot model.

    Robot::add_extra

    fn Robot::add_extra(self : Robot, node : RawXmlNode) -> Robot

    Returns a copy of this robot with node appended to the verbatim extension nodes (e.g. <gazebo>) preserved on serialization.

    Robot::add_joint

    fn Robot::add_joint(self : Robot, joint : Joint) -> Robot

    Returns a copy of this robot with joint appended to the joint list; the original array is left unmodified.

    Robot::add_joints

    fn Robot::add_joints(self : Robot, joints : Array[Joint]) -> Robot

    Returns a copy of this robot with every joint in joints appended in order; the original array is left unmodified.
    fn Robot::add_link(self : Robot, link : Link) -> Robot

    Returns a copy of this robot with link appended to the link list; the original array is left unmodified.
    fn Robot::add_links(self : Robot, links : Array[Link]) -> Robot

    Returns a copy of this robot with every link in links appended in order; the original array is left unmodified.

    Robot::add_loop_constraint

    fn Robot::add_loop_constraint(self : Robot, constraint : LoopConstraint) -> Robot

    Adds a closed-chain constraint (ignored by URDF readers, emitted as a native <equality><connect> in MJCF).

    Robot::add_material

    fn Robot::add_material(self : Robot, material : Material) -> Robot

    Returns a copy of this robot with material appended to the named materials table.

    Robot::add_transmission

    fn Robot::add_transmission(self : Robot, transmission : Transmission) -> Robot

    Returns a copy of this robot with transmission appended to the transmission list; the original array is left unmodified.

    Robot::attach_child

    fn Robot::attach_child(self : Robot, parent~ : String, joint_name~ : String, child : Link, joint_type? : JointType, origin? : Origin, axis? : (Double, Double, Double), limit? : JointLimit, dynamics? : JointDynamics, mimic? : JointMimic) -> Robot

    Adds child link AND attaches it to parent via a new Joint in one fluent call — keeping serial kinematic trees concise and impossible to leave disconnected.

    Robot::attach_continuous

    fn Robot::attach_continuous(self : Robot, parent~ : String, joint_name~ : String, child : Link, origin? : Origin, axis? : (Double, Double, Double), limit? : JointLimit, dynamics? : JointDynamics, mimic? : JointMimic, reduction? : Double) -> Robot

    Adds child link and attaches it to parent with a Continuous joint (and optional Transmission::simple when reduction is provided).

    Robot::attach_fixed

    fn Robot::attach_fixed(self : Robot, parent~ : String, joint_name~ : String, child : Link, origin? : Origin) -> Robot

    Adds child link and attaches it to parent with a Fixed joint.

    Robot::attach_prismatic

    fn Robot::attach_prismatic(self : Robot, parent~ : String, joint_name~ : String, child : Link, limit~ : JointLimit, origin? : Origin, axis? : (Double, Double, Double), dynamics? : JointDynamics, mimic? : JointMimic, reduction? : Double) -> Robot

    Adds child link and attaches it to parent with a Prismatic joint (and optional Transmission::simple when reduction is provided).

    Robot::attach_revolute

    fn Robot::attach_revolute(self : Robot, parent~ : String, joint_name~ : String, child : Link, limit~ : JointLimit, origin? : Origin, axis? : (Double, Double, Double), dynamics? : JointDynamics, mimic? : JointMimic, reduction? : Double) -> Robot

    Adds child link and attaches it to parent with a Revolute joint (and optional Transmission::simple when reduction is provided).

    Robot::diagnostics

    fn Robot::diagnostics(self : Robot) -> Array[Diagnostic]

    Runs the full validation suite and returns every problem found. Checks: empty robot; duplicate link and joint names; joints referencing missing parent/child links; self-loop joints; links with more than one parent joint; zero-length axes on revolute/continuous/prismatic/planar joints; missing <limit> on revolute/prismatic joints and invalid limits (negative effort/velocity, lower bound above upper); mimic joints with an unknown target or a mimic cycle; kinematic cycles via parent-pointer traversal; more than one root link (disconnected graph); invalid geometry dimensions (non-positive box/cylinder/sphere sizes, empty mesh filename); non-positive mass; and non-physical inertia (non-positive principal moments or violated triangle inequality). Severity per diagnostic is given by Diagnostic::severity.

    Robot::equal

    fn Robot::equal(Robot, Robot) -> Bool
    automatically derived

    Robot::forward_kinematics

    fn Robot::forward_kinematics(self : Robot, joint_positions? : Map[String, Double]) -> Map[String, Transform]

    Computes world poses for every link reachable from the robot's root link(s). Mimic joints are resolved before propagation.

    Robot::get_joint

    fn Robot::get_joint(self : Robot, name : String) -> Joint?

    Returns the first joint named name, or None if no joint in the list matches; names are not required to be unique.
    fn Robot::get_link(self : Robot, name : String) -> Link?

    Returns the first link named name, or None if no link in the list matches; names are not required to be unique.

    Robot::has_errors

    fn Robot::has_errors(self : Robot) -> Bool

    True when diagnostics() reports at least one Error-severity problem; warnings alone return false.
    fn Robot::link_world_origins(self : Robot, joint_positions? : Map[String, Double]) -> Map[String, Origin]

    Convenience wrapper returning each link's world origin (xyz + rpy).

    Robot::new

    fn Robot::new(name : String, version? : String?, documentation? : String) -> Robot

    Creates an empty robot named name. version is written to the <robot> element when set; documentation is emitted as an XML comment above the element. Links, joints, materials, transmissions and loop constraints all start empty.

    Robot::not_equal

    fn Robot::not_equal(x : Robot, y : Robot) -> Bool
    automatically derived
    fn Robot::root_link(self : Robot) -> String?

    Returns the unique root link, or None when there are zero or several.

    Robot::to_mjcf_string

    fn Robot::to_mjcf_string(self : Robot, mesh_dir? : String, include_floor? : Bool) -> String

    Converts the robot to MuJoCo MJCF XML with the legacy defaults.

    The root link is floating (<freejoint/>), collisions are used as geoms when present (visuals otherwise), and every LoopConstraint becomes a native <equality><connect> between two site frames (site1/site2) placed at the constraint anchors.

    Robot::to_mjcf_with_options

    fn Robot::to_mjcf_with_options(self : Robot, options : MjcfOptions) -> String

    Converts the robot to MuJoCo MJCF XML with simulation options.

    Robot::to_repr

    automatically derived

    Robot::to_string

    fn Robot::to_string(self : Robot) -> String

    Alias for to_urdf_xml, matching the usual to_string convention.

    Robot::to_urdf_file_checked

    fn Robot::to_urdf_file_checked(self : Robot) -> String

    Returns the URDF XML, aborting with the first error diagnostic if the robot is not valid.

    Robot::to_urdf_xml

    fn Robot::to_urdf_xml(self : Robot) -> String

    Serializes the robot to a deterministic URDF XML string.

    Robot::with_documentation

    fn Robot::with_documentation(self : Robot, documentation : String) -> Robot

    Returns a copy of this robot whose documentation string is emitted as an XML comment above the <robot> element.

    Robot::with_version

    fn Robot::with_version(self : Robot, version : String) -> Robot

    Returns a copy of this robot with version set on the <robot> element.

    Robot::write_urdf

    async fn Robot::write_urdf(self : Robot, out_path : String?, checked? : Bool) -> Unit

    Alias for write_urdf_file.

    Robot::write_urdf_file

    async fn Robot::write_urdf_file(self : Robot, out_path : String?, checked? : Bool) -> Unit

    Writes the robot's URDF XML to a file or stdout. When checked is true, validation diagnostics abort the write on the first error.

    SafetyController

    pub(all) struct SafetyController {
    soft_lower_limit : Double
    soft_upper_limit : Double
    k_position : Double
    k_velocity : Double
    } derive(Eq,
    Debug
    )

    Joint safety controller limits.

    SafetyController::equal

    automatically derived

    SafetyController::not_equal

    fn SafetyController::not_equal(x : SafetyController, y : SafetyController) -> Bool
    automatically derived

    SafetyController::to_repr

    automatically derived

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    Severity::all

    fn Severity::all() -> Array[Severity]

    All severity values in increasing order of severity: [Info, Warning, Error].

    Severity::equal

    fn Severity::equal(Severity, Severity) -> Bool
    automatically derived

    Severity::is_error

    fn Severity::is_error(self : Severity) -> Bool

    True only for Severity::Error; Info and Warning diagnostics do not fail validation.

    Severity::not_equal

    fn Severity::not_equal(x : Severity, y : Severity) -> Bool
    automatically derived

    Severity::to_repr

    automatically derived

    Transform

    pub(all) struct Transform {
    rot : Matrix3x3
    trans : (Double, Double, Double)
    } derive(Eq,
    Debug
    )

    A rigid transform: rotation followed by translation.

    Transform::apply_dir

    fn Transform::apply_dir(self : Transform, v : (Double, Double, Double)) -> (Double, Double, Double)

    Returns the image of direction vector v under this transform: rotation only, the translation is ignored. Unit vectors stay unit.

    Transform::apply_point

    fn Transform::apply_point(self : Transform, p : (Double, Double, Double)) -> (Double, Double, Double)

    Returns the image of point p under this transform: rotation applied first, then translation. p and the result are in metres.

    Transform::compose

    fn Transform::compose(self : Transform, other : Transform) -> Transform

    Composes self followed by other.

    Transform::equal

    fn Transform::equal(Transform, Transform) -> Bool
    automatically derived

    Transform::from_origin

    fn Transform::from_origin(origin : Origin) -> Transform

    Builds a transform from a URDF <origin>: the rotation comes from the fixed-axis roll/pitch/yaw rpy (radians) and the translation is xyz (metres).

    Transform::identity

    fn Transform::identity() -> Transform

    Returns the identity transform: no rotation, zero translation.

    Transform::inverse

    fn Transform::inverse(self : Transform) -> Transform

    Returns the inverse transform: R transposed with translation -R^T * t. Assumes the rotation part is orthonormal; a non-orthonormal matrix is transposed, not truly inverted.

    Transform::not_equal

    fn Transform::not_equal(x : Transform, y : Transform) -> Bool
    automatically derived

    Transform::to_origin

    fn Transform::to_origin(self : Transform) -> Origin

    Converts self back into an Origin: the translation becomes xyz (metres) and the rotation is re-expressed as fixed-axis roll/pitch/yaw radians via matrix_to_rpy.

    Transform::to_repr

    automatically derived

    Transmission

    pub(all) struct Transmission {
    name : String
    trans_type : String
    joints : Array[TransmissionJoint]
    actuators : Array[Actuator]
    } derive(Eq,
    Debug
    )

    A ros_control transmission description.

    Transmission::equal

    automatically derived

    Transmission::not_equal

    fn Transmission::not_equal(x : Transmission, y : Transmission) -> Bool
    automatically derived

    Transmission::simple

    fn Transmission::simple(name : String, joint_name : String, actuator_name : String, reduction? : Double, hardware_interface? : String) -> Transmission

    Builds a transmission_interface/SimpleTransmission mapping one actuator onto one joint: joint_name and actuator_name both claim hardware_interface, and reduction is the actuator-to-joint mechanical reduction (1.0 means direct drive) stored as the actuator's mechanical_reduction.

    Transmission::to_repr

    automatically derived

    TransmissionJoint

    pub(all) struct TransmissionJoint {
    name : String
    hardware_interfaces : Array[String]
    } derive(Eq,
    Debug
    )

    A transmission joint entry.

    TransmissionJoint::equal

    automatically derived

    TransmissionJoint::not_equal

    fn TransmissionJoint::not_equal(x : TransmissionJoint, y : TransmissionJoint) -> Bool
    automatically derived

    TransmissionJoint::to_repr

    automatically derived

    UrdfBundle

    pub(all) struct UrdfBundle {
    package_name : String
    robot : Robot
    meshes : Array[MeshAsset]
    mjcf_options : MjcfOptions?
    }

    A complete ROS 2 package bundle: the robot model plus mesh assets and the options for the companion MJCF file. Build one with UrdfBundle::new, attach meshes with add_mesh_bytes/add_mesh_text, and export with write_to_dir.

    UrdfBundle::add_mesh_bytes

    fn UrdfBundle::add_mesh_bytes(self : UrdfBundle, rel_path : String, bytes : Bytes) -> UrdfBundle

    Returns a copy of the bundle with bytes added as a mesh asset at rel_path (relative to the bundle root). Existing meshes are preserved; no validation of the path or mesh contents is performed.

    UrdfBundle::add_mesh_text

    fn UrdfBundle::add_mesh_text(self : UrdfBundle, rel_path : String, text : String) -> UrdfBundle

    Like add_mesh_bytes, but takes the mesh file contents as a UTF-8 string (useful for ASCII STL or DAE) and encodes them before storing.

    UrdfBundle::new

    fn UrdfBundle::new(package_name : String, robot : Robot) -> UrdfBundle

    Creates an empty bundle for robot under package_name. The mesh list starts empty and mjcf_options is None (legacy MJCF defaults); add meshes with add_mesh_bytes/add_mesh_text and set MJCF options with with_mjcf_options.

    UrdfBundle::package_xml

    fn UrdfBundle::package_xml(self : UrdfBundle, version? : String, description? : String, maintainer? : String, email? : String, license? : String) -> String

    Generates a standard ROS 2 package.xml.

    UrdfBundle::with_mjcf_options

    fn UrdfBundle::with_mjcf_options(self : UrdfBundle, options : MjcfOptions) -> UrdfBundle

    Sets the MJCF simulation options written alongside the URDF.

    UrdfBundle::write_to_dir

    async fn UrdfBundle::write_to_dir(self : UrdfBundle, out_dir : String, checked? : Bool) -> Unit

    Writes package.xml, urdf/<robot>.urdf, and every mesh asset to out_dir, creating parent directories as needed.

    UrdfParseErrorInfo

    pub(all) struct UrdfParseErrorInfo {
    message : String
    line : Int?
    col : Int?
    snippet : String?
    } derive(Eq,
    Debug
    )

    UrdfParseErrorInfo::equal

    automatically derived

    UrdfParseErrorInfo::not_equal

    automatically derived

    UrdfParseErrorInfo::to_repr

    automatically derived

    Visual

    pub(all) struct Visual {
    name : String?
    origin : Origin
    geometry : Geometry
    material : Material?
    } derive(Eq,
    Debug
    )

    A visual element on a link.

    Visual::equal

    fn Visual::equal(Visual, Visual) -> Bool
    automatically derived

    Visual::new

    fn Visual::new(geometry : Geometry, name? : String?, origin? : Origin, material? : Material?) -> Visual

    Visual::not_equal

    fn Visual::not_equal(x : Visual, y : Visual) -> Bool
    automatically derived

    Visual::to_repr

    automatically derived

    Visual::with_color

    fn Visual::with_color(self : Visual, name : String, color : Rgba) -> Visual

    Returns a copy of this visual with a color-only material named name set to color (RGBA components in [0, 1]).

    Visual::with_material

    fn Visual::with_material(self : Visual, material : Material) -> Visual

    Returns a copy of this visual with material attached, replacing any existing material.

    Visual::with_name

    fn Visual::with_name(self : Visual, name : String) -> Visual

    Returns a copy of this visual with name set; the receiver is returned unmodified.

    Visual::with_origin

    fn Visual::with_origin(self : Visual, origin : Origin) -> Visual

    Returns a copy of this visual with its <origin> replaced by origin.

    fmt_num

    fn fmt_num(n : Double) -> String

    Formats a double for URDF attributes: trigonometric residue is rounded to zero, near-integers print without a decimal point, and -0 never appears.

    fmt_rgba

    fn fmt_rgba(c : Rgba) -> String

    Formats an RGBA color as four space-separated numbers using fmt_num, matching the URDF rgba attribute syntax.

    fmt_vec3

    fn fmt_vec3(v : (Double, Double, Double)) -> String

    Formats a 3D vector as three space-separated numbers using fmt_num, matching the URDF x y z attribute syntax.

    format_urdf_parse_error

    fn format_urdf_parse_error(info : UrdfParseErrorInfo) -> String

    Formats a parse error as @line:col: message, plus an optional snippet.

    matrix_to_rpy

    fn matrix_to_rpy(m : Matrix3x3) -> (Double, Double, Double)

    Extracts (roll, pitch, yaw) radians from a rotation matrix.

    parse_urdf_from_file

    async fn parse_urdf_from_file(path : String) -> Robot

    Reads and parses a URDF file.

    parse_urdf_from_string

    fn parse_urdf_from_string(xml : String) -> Robot raise UrdfParseError

    Parses a URDF XML string into a Robot.

    parse_urdf_from_string_result

    fn parse_urdf_from_string_result(xml : String) -> ParseUrdfResult

    Parses a URDF XML string, returning ParseUrdfResult instead of raising.

    parse_xml_node

    fn parse_xml_node(xml : String) -> RawXmlNode raise UrdfParseError

    Parses XML text into a generic RawXmlNode tree.

    rotation_matrix_axis_angle

    fn rotation_matrix_axis_angle(axis : (Double, Double, Double), angle_rad : Double) -> Matrix3x3

    Builds a rotation matrix from a unit axis and angle using Rodrigues' formula.

    rotation_matrix_rpy

    fn rotation_matrix_rpy(roll : Double, pitch : Double, yaw : Double) -> Matrix3x3

    Builds the URDF fixed-axis roll/pitch/yaw rotation matrix R = Rz(yaw) * Ry(pitch) * Rx(roll).

    snap_mates

    fn snap_mates(parent_mate :
    MateConnector
    , child_mate :
    MateConnector
    , offset? : Double, angle_rad? : Double, flip_axis? : Bool) -> (Origin, (Double, Double, Double))

    Snaps a child mate onto a parent mate. Returns the joint origin (the child-link pose at q = 0) and the joint axis expressed in the child frame.

    This is a metre/radian wrapper around the shared snap_connectors; the offset is converted to millimetres and the result back to a URDF Origin. The returned axis follows the same anti-parallel insertion convention as @step_common.MatePair::resolve, so a joint built from component connectors uses the same axis direction as the CAD mate.

    v3_add

    fn v3_add(a : (Double, Double, Double), b : (Double, Double, Double)) -> (Double, Double, Double)

    v3_cross

    fn v3_cross(a : (Double, Double, Double), b : (Double, Double, Double)) -> (Double, Double, Double)

    Returns the right-handed cross product of a and b; the result is perpendicular to both, with magnitude |a||b|sin(theta).

    v3_dot

    fn v3_dot(a : (Double, Double, Double), b : (Double, Double, Double)) -> Double

    Returns the inner (dot) product of a and b; for unit vectors this is the cosine of the angle between them.

    v3_len

    fn v3_len(a : (Double, Double, Double)) -> Double

    Returns the Euclidean (L2) norm of a.

    v3_norm

    fn v3_norm(a : (Double, Double, Double)) -> (Double, Double, Double)

    Returns the unit vector in the direction of a; returns the zero vector when a has length below 1.0e-15 instead of dividing by zero.

    v3_scale

    fn v3_scale(a : (Double, Double, Double), s : Double) -> (Double, Double, Double)

    Returns the component-wise product a scaled by s in every axis.

    v3_sub

    fn v3_sub(a : (Double, Double, Double), b : (Double, Double, Double)) -> (Double, Double, Double)

    Returns the component-wise difference a - b.

    write_text_file

    async fn write_text_file(text : String, out_path : String?) -> Unit

    Writes text to out_path, or to stdout when out_path is None.

    xml_escape

    fn xml_escape(s : String) -> String

    Escapes text or an attribute value for XML output.