urdf

    Simple URDF support for MoonBit

    cad
    3d
    ros
    urdf
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    4 days ago
    Downloads
    23

    #gmlewis/urdf (MoonBit)

    A standalone, dependency-clean 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 has zero dependency on gmlewis/step. 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)

    #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 },
    )

    #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. Neither depends on the other; gmlewis/cad imports both.

    #Examples

    ExampleDescription
    01-single-link-boxParameterized box: millimeter units, density, analytical inertia
    02-two-link-pendulumRevolute pendulum assembled with mate connectors
    03-planetary-gearbox-urdfSun/ring/planets/carrier with mimic coupling
    04-six-dof-armSix-axis arm with Inertial::combine, safety controllers, transmissions
    05-wheeled-quadrupedGalileo-style quadruped: 17 links, 16 joints, full mesh bundle
    06-assistive-scooterRider-parameterized assistive scooter/wheelchair

    Run any example (numbers resolve to the matching folder):

    ./run-example.sh 01 -o box.urdf ./run-example.sh 02 --length1 200 -o pendulum.urdf --validate ./run-example.sh 05 -o galileo.urdf ./run-example.sh 05 --bundle /tmp/galileo_pkg python3 scripts/validate_urdf.py --check-meshes \ /tmp/galileo_pkg/urdf/galileo_quadruped.urdf

    #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.

    #License

    Apache-2.0

    Vec3

    type Vec3 = (Double, Double, Double)

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

    UrdfParseError

    pub suberror UrdfParseError {
    UrdfParseError(UrdfParseErrorInfo)
    }

    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

    Actuator::to_repr

    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

    Angle::neg

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

    Angle::rad

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

    Angle::sub

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

    Angle::to_deg

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

    Angle::to_rad

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

    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

    Collision::new

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

    Collision::with_name

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

    Collision::with_origin

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

    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::carbon_fiber

    fn Density::carbon_fiber() -> Density

    Carbon-fiber composite (approximate).

    Density::g_per_cm3

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

    Density::kg_per_m3

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

    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::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

    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
    )

    Diagnostic::equal

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

    Diagnostic::message

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

    Diagnostic::severity

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

    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

    Geometry::box_mm

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

    Geometry::cylinder

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

    Geometry::cylinder_mm

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

    Geometry::equal

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

    Geometry::mesh

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

    Geometry::mesh_mm

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

    Geometry::sphere

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

    Geometry::sphere_mm

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

    Geometry::to_repr

    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

    Inertia::diagonal

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

    Inertia::equal

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

    Inertia::from_matrix

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

    Inertia::new

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

    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

    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

    Inertia::zero

    fn Inertia::zero() -> Inertia

    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

    Inertial::from_box

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

    Inertial::from_box_density

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

    Inertial::from_cylinder

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

    Inertial::from_cylinder_density

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

    Inertial::from_geometry_density

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

    Inertial::from_sphere

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

    Inertial::from_sphere_density

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

    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

    Inertial::from_tube_density

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

    Inertial::new

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

    Inertial::to_repr

    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

    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

    Joint::continuous

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

    Joint::equal

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

    Joint::fixed

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

    Joint::floating

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

    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::new

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

    Joint::planar

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

    Joint::prismatic

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

    Joint::revolute

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

    Joint::to_repr

    Joint::with_axis

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

    Joint::with_calibration

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

    Joint::with_dynamics

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

    Joint::with_limit

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

    Joint::with_mimic

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

    Joint::with_origin

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

    Joint::with_safety_controller

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

    JointCalibration

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

    Joint calibration reference positions.

    JointCalibration::equal

    JointDynamics

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

    Joint damping and friction.

    JointDynamics::equal

    JointDynamics::new

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

    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

    JointLimit::new

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

    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

    JointMimic::new

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

    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

    JointType::from_urdf_str

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

    JointType::to_urdf_str

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

    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

    Length::inches

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

    Length::m

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

    Length::mm

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

    Length::neg

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

    Length::scale

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

    Length::sub

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

    Length::to_m

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

    Length::to_mm

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

    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

    Link::add_extra

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

    Link::add_visual

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

    Link::equal

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

    Link::new

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

    Link::rebase_to_mate

    fn Link::rebase_to_mate(self : Link, mate : MateConnector) -> Link

    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

    Link::with_inertial

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

    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

    Mass::kg

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

    Mass::lbs

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

    Mass::sub

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

    Mass::to_grams

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

    Mass::to_kg

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

    MateConnector

    pub(all) struct MateConnector {
    name : String
    origin : Origin
    axis : (Double, Double, Double)
    } derive(Eq,
    Debug
    )

    A named attachment frame on a component. Mate connectors are the CAD-side ports that let parameterized parts snap together without hand-computed coordinates.

    MateConnector::equal

    MateConnector::from_mm_deg

    fn MateConnector::from_mm_deg(name : String, x? : Double, y? : Double, z? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double, axis? : (Double, Double, Double)) -> MateConnector

    Builds a mate from millimeter/degree inputs, normalizing its axis.

    MateConnector::new

    fn MateConnector::new(name : String, origin? : Origin, axis? : (Double, Double, Double)) -> MateConnector

    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

    Material::equal

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

    Material::new

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

    Material::to_repr

    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)

    Matrix3x3::equal

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

    Matrix3x3::identity

    fn Matrix3x3::identity() -> Matrix3x3

    Matrix3x3::mul

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

    Matrix3x3::transpose

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

    MeshAsset

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

    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

    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

    Origin::is_identity

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

    Origin::new

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

    Origin::to_repr

    ParseUrdfResult

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

    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

    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

    Rgba::blue

    fn Rgba::blue() -> Rgba

    Rgba::cyan

    fn Rgba::cyan() -> Rgba

    Rgba::equal

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

    Rgba::green

    fn Rgba::green() -> Rgba

    Rgba::grey

    fn Rgba::grey() -> Rgba

    Rgba::magenta

    fn Rgba::magenta() -> Rgba

    Rgba::new

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

    Rgba::orange

    fn Rgba::orange() -> Rgba

    Rgba::purple

    fn Rgba::purple() -> Rgba

    Rgba::red

    fn Rgba::red() -> Rgba

    Rgba::silver

    fn Rgba::silver() -> Rgba

    Rgba::to_repr

    Rgba::white

    fn Rgba::white() -> Rgba

    Rgba::yellow

    fn Rgba::yellow() -> Rgba

    Robot

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

    A complete URDF robot model.

    Robot::add_extra

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

    Robot::add_joint

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

    Robot::add_joints

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

    fn Robot::add_link(self : Robot, link : Link) -> Robot

    fn Robot::add_links(self : Robot, links : Array[Link]) -> Robot

    Robot::add_material

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

    Robot::add_transmission

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

    Robot::diagnostics

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

    Robot::equal

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

    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?

    fn Robot::get_link(self : Robot, name : String) -> Link?

    Robot::has_errors

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

    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

    fn Robot::root_link(self : Robot) -> String?

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

    Robot::to_repr

    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

    Robot::with_version

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

    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

    Severity

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

    Severity::all

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

    Severity::equal

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

    Severity::is_error

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

    Severity::to_repr

    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)

    Transform::apply_point

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

    Transform::compose

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

    Composes self followed by other.

    Transform::equal

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

    Transform::from_origin

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

    Transform::identity

    fn Transform::identity() -> Transform

    Transform::inverse

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

    Transform::to_origin

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

    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

    Transmission::simple

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

    TransmissionJoint

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

    A transmission joint entry.

    TransmissionJoint::equal

    UrdfBundle

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

    UrdfBundle::add_mesh_bytes

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

    UrdfBundle::add_mesh_text

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

    UrdfBundle::new

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

    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::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

    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

    Visual::new

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

    Visual::to_repr

    Visual::with_color

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

    Visual::with_material

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

    Visual::with_name

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

    Visual::with_origin

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

    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

    fmt_vec3

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

    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.

    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)

    v3_dot

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

    v3_len

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

    v3_norm

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

    v3_scale

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

    v3_sub

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

    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.