cad

    Pluggable parametric CAD and URDF robotics component library in MoonBit

    cad
    step
    urdf
    robotics
    3d-modeling
    Download zip
    Author
    Version
    0.2.37
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    152

    #gmlewis/cad (MoonBit)

    moonbit step mascot

    A pluggable parametric CAD and robotics component library for MoonBit. One parametric Component tree compiles to a STEP assembly, a glTF scene, a URDF robot, a ROS 2 bundle, or a complete build package. It combines the STEP B-Rep kernel from gmlewis/step with the URDF kinematics and inertia model from gmlewis/urdf.

    #Project status

    This repository is a MoonBit experiment in authoring parametric CAD. Everything here is design intent and generated geometry: no part has been fabricated, assembled, or physically validated, and none of the examples has a physical prototype. The STEP, URDF, glTF, BOM and assembly outputs describe a proposed design, not a tested machine.

    #Quick start

    ./test-all.sh ./build-part.sh 02 ./run-example.sh 02 --view

    Open build/02/START-HERE.html: it covers what to print, what to buy, and how to assemble. --view opens the model in SolidCraft; -o model.step writes a STEP file instead. ./run-example.sh <n> --help lists every shared and example-specific flag. The numbered examples live in examples/, each with its own README.

    Treat each package under build/<n>/ as the source of truth for parts, quantities, supplier links, assembly steps, mass/inertia, control constants and views — bom.csv, assembly.txt, inspect.json, control_params.h, START-HERE.html, and the STEP/URDF/glTF outputs.

    An exploded view is a stack of ExplodeLayer values. The example below is compiled and run by moon test, so the API shown here always works:

    ///|
    test {
    let layer = @cad.ExplodeLayer::new(label="bearing", patterns=["bearing"]).exact()
    let stack = @cad.ExplodeStack::z_axis(anchor="base", gap_mm=10.0).group(layer)
    let design = @step_cad.Design::new(name="es")
    .add(@step_cad.Cylinder::new(10.0, 5.0).with_name("base").translate(z=0.0))
    .add(
    @step_cad.Cylinder::new(8.0, 4.0).with_name("bearing").translate(z=7.0),
    )
    inspect(stack.diagnostics(design).is_ok(), content="true")
    }

    #Shared output flags

    Every example accepts the same output flags. ./run-example.sh <n> --help prints the full list, including the example-specific options.

    • --detail simplified|detailed|fully-modeled — geometry detail.
    • --threads none|cosmetic|helical — thread representation override.
    • --print-parts <dir> — standalone 3D-printable STEP parts and print-list.csv, each in its own local datum frame, with purchased motors, screws, bearings and PCBs excluded.
    • --posed-parts <dir> — world-posed per-link STEP files for interference analysis.
    • --collisions — conservative OBB/AABB collision and interference audit.
    • --analyze — whole-robot mass, CoM, inertia, static joint torque margins, and wheel/foot ground-contact alignment.
    • --inspect-json — deterministic JSON summary on stdout; --package also writes the same document to inspect.json.
    • --rl-task — print the RL observation/action/reward contract (also written to rl_task.json by --package).
    • -o, --assembly, --assembly-instanced, --gltf, --blender, --urdf, --bundle, --package, --bom, --plan, --report, --control, --pins, and --check.

    #Generated file metadata

    Every STEP and 3MF file written by this repository records this repository's version (from get_version()) and the command line that produced it in the file's metadata section. STEP files carry a HEADER comment block; 3MF archives carry <metadata> tags and Metadata/provenance.json. The gmlewis/step writer also stamps its own version, so a model documents both layers. Printed parts additionally embed their slicer settings (maker, layer height, infill, support type, nozzle diameter) in a maker=... STEP HEADER comment; the 3MF exporter lifts those values into CadMaker / CadLayerHeightMm / CadInfillPct / CadSupport / CadNozzleMm metadata tags and a print_settings object in Metadata/provenance.json.

    #Architecture

    A Component is a reusable parameterized module with bodies (STEP geometry plus inertia), named mates, child attachments and joints, and purchasing metadata (PartMeta, fasteners, fits, ports, actuator/sensor/PCB specs, wiring and control bindings). JointSpec::merge_rigid() folds a child's bodies into the parent link; the other joint types emit kinematic URDF joints. A BodyPart keeps the millimeter/degree CAD solid and the metre/radian inertia together so they cannot drift.

    • CAD (@step_cad): millimeters, degrees (R = Rz * Ry * Rx).
    • URDF (@urdf): metres, radians, inertia in kg·m².
    • URDF primitives are centered on their frame; the centered_* bridges keep the CAD primitives centered too.

    Three tiers: gmlewis/step/components/* (hardware primitives), gmlewis/cad/components (reusable mechatronic subassemblies), and examples/ (end-to-end models). Every builder accepts detail~ and, for threaded hardware, threads?. See docs/architecture.md for the layer boundaries.

    #Tools

    CommandPurpose
    ./build-part.sh <n>Complete build package under build/<n>/.
    ./run-example.sh <n> --viewOpen one example in SolidCraft.
    ./run-example.sh <n> -o model.stepWrite a STEP assembly for one example.
    ./run-example.sh <n> --package <dir>Write the full build package to a directory of your choice.
    ./test-all.shmoon fmt, moon info, and the full unit suite.
    ./customize.sh <n>Local parameter editor for one example.
    ./train-rl.sh <n>Train a policy for examples with an RlTaskSpec.
    scripts/new-example.sh <name>Scaffold a new example.
    scripts/validate_step.py --no-mesh <file.step>STEP topology and OCCT checkshape checks.
    scripts/validate_urdf.py --check-meshes <file.urdf>URDF structural and mesh checks.
    scripts/check_interferences.py --parts-dir <dir>OCCT solid-solid interference.
    scripts/make_drawings.py build/<n>A3 drawing sheets.
    scripts/fea_check.py build/<n>Optional gmsh/CalculiX structural check.
    ./view-md.sh <file.md>Render Markdown to a self-contained HTML page.

    Validation and rendering helpers live in scripts/; each documents its own external requirements.

    #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 'Component::add_body' # signature + doc for one symbol moon ide doc 'Component' # a type and its methods 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

    ExplodeError

    pub suberror ExplodeError {
    ExplodeError(String)
    }

    The strict offsets() refuses a stack with classification or host errors.

    ActuatorKind

    pub(all) enum ActuatorKind {
    Stepper
    Bldc
    Servo
    Hub
    }

    The kind of actuator a component represents.

    ActuatorLine

    pub(all) struct ActuatorLine {
    path : String
    spec : ActuatorSpec
    }

    One actuator line in the power budget.

    ActuatorSpec

    pub(all) struct ActuatorSpec {
    kind : ActuatorKind
    model : String
    voltage_v : Double
    current_rated_a : Double
    current_stall_a : Double
    torque_rated_nm : Double
    driver : String
    interface : String
    encoder : String
    }

    Electrical and mechanical ratings for one actuator.

    ActuatorSpec::new

    fn ActuatorSpec::new(kind : ActuatorKind, model? : String, voltage_v? : Double, current_rated_a? : Double, current_stall_a? : Double, torque_rated_nm? : Double, driver? : String, interface? : String, encoder? : String) -> ActuatorSpec

    Creates an actuator spec; unspecified electrical fields default to 0 and text fields to empty strings.

    AssemblyStep

    pub(all) struct AssemblyStep {
    sequence : Int
    title : String
    component : String
    joint : String?
    fasteners : Array[String]
    tools : Array[String]
    notes : String
    }

    One step in a derived assembly plan: a fastener installation or a child attachment, numbered in the order the tree should be built.

    AssemblyStep::new

    fn AssemblyStep::new(sequence : Int, title : String, component~ : String, joint? : String?, fasteners? : Array[String], tools? : Array[String], notes? : String) -> AssemblyStep

    Creates an assembly step; sequence is the 1-based build order and component the slash-separated path used in the plan output.

    AssemblyStep::to_line

    fn AssemblyStep::to_line(self : AssemblyStep) -> String

    Renders one step as a single human-readable line.

    Attachment

    pub(all) struct Attachment {
    joint_name : String
    child : Component
    spec : JointSpec
    bom_external : Bool
    explode : ExplodeSpec?
    }

    A child component snapped onto one of its parent's mates.

    BodyPart

    pub(all) struct BodyPart {
    name : String
    node :
    SceneNode

    density :
    Density

    inertial :
    Inertial

    collisions : Array[
    Collision
    ]
    part : PartMeta?
    part_group : String?
    print_cutters : Array[
    SceneNode
    ]
    }

    A physical solid inside a component.

    A BodyPart carries the exact CAD solid (node, millimeters/degrees) and the matching URDF mass properties (inertial, meters/radians) so the same geometry feeds both the STEP exporter and the robot simulator. Collisions are cheap analytical primitives in the same local frame.

    BodyPart::box_mm

    fn BodyPart::box_mm(name : String, sx_mm : Double, sy_mm : Double, sz_mm : Double, density? :
    Density
    , color? :
    Rgb
    , x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> BodyPart

    Builds a rectangular box body from millimeter dimensions and a millimeter/degree pose.

    BodyPart::custom

    fn BodyPart::custom(name : String, node :
    SceneNode
    , inertial :
    Inertial
    , collisions? : Array[
    Collision
    ], density? :
    Density
    , part? : PartMeta?, part_group? : String?) -> BodyPart

    Builds a body from a pre-existing scene node and inertia.

    BodyPart::cylinder_mm

    fn BodyPart::cylinder_mm(name : String, diameter_mm : Double, length_mm : Double, density? :
    Density
    , color? :
    Rgb
    , x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> BodyPart

    Builds a solid cylinder body, axis along Z, centered on its own frame.

    BodyPart::extruded_profile_mm

    fn BodyPart::extruded_profile_mm(name : String, outer : Array[(Double, Double)], height_mm : Double, holes? : Array[Array[(Double, Double)]], density? :
    Density
    , color? :
    Rgb
    , x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> BodyPart

    Builds an extruded-profile body. Its mass comes from the true net profile area; its inertia and collision use the profile's bounding box.

    BodyPart::extruded_sketch_mm

    fn BodyPart::extruded_sketch_mm(name : String, sketch :
    Sketch2D
    , plane :
    Plane
    , thickness_mm : Double, density? :
    Density
    , color? :
    Rgb
    , x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double, centered? : Bool) -> BodyPart

    Builds a body from a @step_cad.Sketch2D, extruded on plane.

    The sketch supplies the outer and hole loops; the STEP writer normalizes their winding. With centered=true the solid straddles the sketch plane.

    BodyPart::from_scene_node

    Builds one BodyPart from an already placed scene node.

    BodyPart::from_step_component

    fn BodyPart::from_step_component(step_comp :
    Component
    , density? :
    Density
    , part? : PartMeta?, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Array[BodyPart]

    Converts one STEP primitive component into CAD bodies.

    Each layer of the STEP component becomes a BodyPart in the local frame placed by the millimeter/degree offset. The first body receives part so a multi-layer primitive (a screw shank, head, and socket, or a bearing's rings and balls) counts once in the bill of materials.

    BodyPart::imported_step

    fn BodyPart::imported_step(name : String, step_text : String, source? : String, density? :
    Density
    , color? :
    Rgb
    , part? : PartMeta?, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> BodyPart

    Imports an exact vendor STEP file as a purchased body.

    The imported B-Rep is emitted verbatim (rigidly placed by the body's transform) in the flat STEP output. The URDF, collision checks, and glTF fallback use the imported solid's bounding box, so the body has a real mass, a conservative collision primitive, and a box visual without re-tessellating the vendor geometry.

    BodyPart::transform_by

    fn BodyPart::transform_by(self : BodyPart, urdf_xform :
    Transform
    ) -> BodyPart

    Rigidly transforms a body (CAD node, inertia, and collision frames).

    BodyPart::tube_mm

    fn BodyPart::tube_mm(name : String, outer_diam_mm : Double, inner_diam_mm : Double, length_mm : Double, density? :
    Density
    , color? :
    Rgb
    , x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> BodyPart

    Builds a hollow tube body, axis along Z, centered on its own frame.

    BodyPart::with_collisions

    fn BodyPart::with_collisions(self : BodyPart, collisions : Array[
    Collision
    ]) -> BodyPart

    Replaces a body's URDF/MJCF collision geometry while preserving its exact STEP visual geometry, mass, inertia, and part metadata.

    BodyPart::with_part

    fn BodyPart::with_part(self : BodyPart, part : PartMeta) -> BodyPart

    Attaches purchasing/manufacturing metadata to this body.

    BodyPart::with_part_group

    fn BodyPart::with_part_group(self : BodyPart, group : String) -> BodyPart

    Marks this body as one layer of an indivisible library component.

    Bom

    pub(all) struct Bom {
    lines : Array[BomLine]
    unassigned : Int
    }

    A bill of materials: aggregated part lines and a count of bodies without part metadata (explicit placeholders).

    Bom::add

    fn Bom::add(self : Bom, part : PartMeta, quantity : Int) -> Unit

    Adds quantity of part, aggregating by part number.

    Bom::add_unassigned

    fn Bom::add_unassigned(self : Bom, quantity : Int) -> Unit

    Counts a body or fastener that has no PartMeta.

    Bom::new

    fn Bom::new() -> Bom

    Creates an empty bill of materials.

    Bom::to_csv

    fn Bom::to_csv(self : Bom) -> String

    Renders the bill of materials as CSV with a header and a final newline.

    Bom::total_cost_usd

    fn Bom::total_cost_usd(self : Bom) -> Double

    Sum of total_cost_usd across all lines, in US dollars.

    BomLine

    pub(all) struct BomLine {
    part_number : String
    description : String
    quantity : Int
    supplier : String
    supplier_url : String
    material : String
    process : String
    finish : String
    unit_cost_usd : Double
    total_cost_usd : Double
    notes : String
    }

    One aggregated bill-of-materials line.

    BoundaryRegion

    pub(all) enum BoundaryRegion {
    CylinderBore(center_mm~ : (Double, Double, Double), axis~ : (Double, Double, Double), radius_mm~ : Double, z_min_mm~ : Double, z_max_mm~ : Double, tol_mm~ : Double)
    PlaneFace(axis~ : (Double, Double, Double), offset_mm~ : Double, tol_mm~ : Double)
    BoxRegion(min_mm~ : (Double, Double, Double), max_mm~ : (Double, Double, Double))
    BoltCircle(center_mm~ : (Double, Double, Double), bcd_mm~ : Double, hole_diam_mm~ : Double, count~ : Int, start_angle_deg~ : Double, z_min_mm~ : Double, z_max_mm~ : Double, tol_mm~ : Double)
    }

    A named subset of the mesh, in the print-bed coordinate frame of printable/<PART>.step (millimeters).

    BuildFile

    pub(all) struct BuildFile {
    path : String
    content : String
    }

    One file in a generated build package.

    BuildFile::new

    fn BuildFile::new(path : String, content : String) -> BuildFile

    Creates a build-package file entry with the given package-relative path and full text content.

    CableRoute

    pub(all) struct CableRoute {
    name : String
    points : Array[(Double, Double, Double)]
    jacket_diameter_mm : Double
    wire_names : Array[String]
    material : String
    from_component : String
    from_port : String
    to_component : String
    to_port : String
    }

    One routed cable bundle. Points are in the owning component's local frame, in millimeters.

    CableRoute::length_mm

    fn CableRoute::length_mm(self : CableRoute) -> Double

    Total routed length, in millimeters.

    CableRoute::new

    fn CableRoute::new(name : String, points? : Array[(Double, Double, Double)], jacket_diameter_mm? : Double, wire_names? : Array[String], material? : String, from_component? : String, from_port? : String, to_component? : String, to_port? : String) -> CableRoute

    Creates a cable route; omitted arguments default to an empty polyline, 0 mm jacket diameter, no wires, no material, and unmodeled endpoints.
    pub(all) struct CompiledLink {
    name : String
    bodies : Array[BodyPart]
    urdf_link :
    Link

    }

    A URDF link plus the CAD bodies that produced it.

    Component

    pub(all) struct Component {
    name : String
    description : String
    parameters : Map[String, String]
    bodies : Array[BodyPart]
    mates : Map[String,
    MateConnector
    ]
    attachments : Array[Attachment]
    robot_name : String?
    part : PartMeta?
    ports : Array[Port]
    fasteners : Array[Fastener]
    fits : Array[Fit]
    actuator : ActuatorSpec?
    sensor : SensorSpec?
    pcb : PcbSpec?
    wiring : Array[WireRun]
    control : Array[ControlBinding]
    cables : Array[CableRoute]
    loops : Array[
    LoopConstraint
    ]
    rl_task : RlTaskSpec?
    fea_load_cases : Array[FeaLoadCase]
    analysis_poses : Array[(String, Map[String, Double])]
    }

    A reusable, parameterized CAD + robotics building block.

    Bodies provide B-Rep geometry and mass properties; mates are named frames other components snap onto; attachments hold the child Component tree.

    Component::add_bodies

    fn Component::add_bodies(self : Component, bodies : Array[BodyPart]) -> Component

    Appends several bodies to this component.

    Component::add_body

    fn Component::add_body(self : Component, body : BodyPart) -> Component

    Appends a body to this component.

    Component::add_cable_route

    fn Component::add_cable_route(self : Component, route : CableRoute) -> Component

    Adds a routed cable bundle to this component.

    Component::add_control_binding

    fn Component::add_control_binding(self : Component, binding : ControlBinding) -> Component

    Adds a joint-to-actuator binding.

    Component::add_fastener

    fn Component::add_fastener(self : Component, fastener : Fastener) -> Component

    Adds a fastener schedule entry.

    Component::add_fea_load_case

    fn Component::add_fea_load_case(self : Component, load_case : FeaLoadCase) -> Component

    Attaches an opt-in structural FEA load case to this component. Returns a new component; the caller's arrays are never mutated.

    Component::add_fit

    fn Component::add_fit(self : Component, fit : Fit) -> Component

    Adds an explicit fit record.

    Component::add_loop_constraint

    fn Component::add_loop_constraint(self : Component, name~ : String, body1~ : String, anchor1~ : (Double, Double, Double), body2~ : String, anchor2~ : (Double, Double, Double)) -> Component

    Declares a closed-chain constraint between two links.

    Anchors are millimeters in each link's local frame and are converted to metres for the URDF/MJCF robot. Declare loop constraints on the root component; to_robot() carries them into the robot.

    Component::add_mate

    Registers a mate connector on this component.

    Component::add_mate_mm_deg

    fn Component::add_mate_mm_deg(self : Component, name : String, x? : Double, y? : Double, z? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double, axis? : (Double, Double, Double)) -> Component

    Registers a mate from millimeter/degree inputs.

    Component::add_port

    fn Component::add_port(self : Component, port : Port) -> Component

    Adds a typed interface port.

    Component::add_wire_run

    fn Component::add_wire_run(self : Component, run : WireRun) -> Component

    Adds a point-to-point cable run to this component's harness.

    Component::analysis_poses

    fn Component::analysis_poses(self : Component) -> Array[(String, Map[String, Double])]

    The poses used for statics and control constants: the poses declared with with_analysis_poses, or a single zero pose named "default" when none were declared.

    Component::assembly_checks

    fn Component::assembly_checks(self : Component, bed? : PrintBedSpec) -> Array[String]

    Checks the hardware data for problems that would make the assembly unbuildable: bad fastener lengths/engagement/torque, missing parts, invalid fits, and duplicate names. Returns one message per problem; an empty array means the data is consistent.

    Component::assembly_plan

    fn Component::assembly_plan(self : Component) -> Array[AssemblyStep]

    Builds the assembly plan by walking the tree depth first.

    A component's own (internal) fasteners are installed first, then each child is built and attached, so children are complete before they are installed. A fastener that references another component in the tree is installed with the attach step that joins those two components.

    Component::assembly_plan_text

    fn Component::assembly_plan_text(self : Component) -> String

    The assembly plan as one numbered line per step.

    Component::attach

    fn Component::attach(self : Component, joint_name : String, parent_mate~ : String, child : Component, child_mate? : String, spec? : JointSpec, bom_external? : Bool, explode? : ExplodeSpec?) -> Component

    Attaches a child component onto a parent mate.

    Component::attach_pattern

    fn Component::attach_pattern(self : Component, prefix : String, points : Array[(Double, Double)], make_child : (Int) -> Component, z_mm? : Double, axis? : (Double, Double, Double), child_mate? : String, spec? : JointSpec, bom_external? : Bool, explode? : ExplodeSpec) -> Component

    Attaches one child component (produced by make_child(index)) at every (x, y, z_mm) point in points, automatically registering a mate connector "\{prefix}_mate_\{i}" on self and attaching the child via joint "\{prefix}_\{i}".

    Eliminates the 20–30 lines of manual for loop + trig + mate boilerplate normally needed for bolt circles, heat-set insert rings, standoffs, or dowel pin sets.

    Component::attach_rect

    fn Component::attach_rect(self : Component, prefix : String, width_mm~ : Double, height_mm~ : Double, make_child : (Int) -> Component, center_x? : Double, center_y? : Double, z_mm? : Double, axis? : (Double, Double, Double), child_mate? : String, spec? : JointSpec, bom_external? : Bool, explode? : ExplodeSpec) -> Component

    Convenience wrapper over Component::attach_pattern for a 4-corner rectangular pattern (width_mm × height_mm, e.g. PCB standoffs).

    Component::attach_ring

    fn Component::attach_ring(self : Component, prefix : String, count~ : Int, diam_mm~ : Double, make_child : (Int) -> Component, phase_deg? : Double, center_x? : Double, center_y? : Double, z_mm? : Double, axis? : (Double, Double, Double), child_mate? : String, spec? : JointSpec, bom_external? : Bool, explode? : ExplodeSpec) -> Component

    Convenience wrapper over Component::attach_pattern for a circular ring of count identical hardware items on diameter diam_mm.

    Component::attach_to

    fn Component::attach_to(self : Component, target_name : String, joint_name : String, parent_mate~ : String, child : Component, child_mate? : String, spec? : JointSpec, bom_external? : Bool, explode? : ExplodeSpec?) -> Component

    Attaches a child to a named component anywhere in this component's tree.

    The tree's attachment arrays are shared, so this lets an assembly builder reach a nested link (for example a motor's rotor) without rebuilding the intermediate components.

    Component::bom

    fn Component::bom(self : Component) -> Bom

    Builds the bill of materials for this component tree.

    A component with part is treated as a purchased/assembled item: its own bodies are represented by that part, while attachments marked bom_external (the default) are still collected. Internal attachments such as a motor's rotor are marked non-external and are not counted separately.

    Component::build_manifest

    fn Component::build_manifest(self : Component, name? : String) -> String

    The package manifest: part counts, cost, step count, warnings, and files.

    Component::build_package_files

    fn Component::build_package_files(self : Component, name? : String, bed? : PrintBedSpec, joint_positions? : Map[String, Double]) -> Array[BuildFile]

    Every text file in the build package, ready to write into a directory.

    Component::build_procedure_text

    fn Component::build_procedure_text(self : Component) -> String

    Assembly, torque, electrical-checkout, and test procedure.

    Component::cable_routes

    fn Component::cable_routes(self : Component) -> Array[CableRoute]

    All cable routes declared anywhere in this component tree.

    Component::collision_checks

    One-line summaries of unintended positive-volume overlaps only.

    Component::collision_report_text

    fn Component::collision_report_text(self : Component, joint_positions? : Map[String, Double], tol? :
    TolerancePolicy
    , policy? :
    ContactPolicy
    ) -> String

    A text report of every contact, interference, and collision pair.

    Component::collision_reports

    Classifies every pair of distinct link instances in the posed tree.

    Compiles this component tree into links, joints, and transmissions.

    Component::control_bindings

    fn Component::control_bindings(self : Component) -> Array[ControlBinding]

    All control bindings declared anywhere in this component tree.

    Component::control_checks

    fn Component::control_checks(self : Component) -> Array[String]

    Checks the control map against the compiled robot: unknown joints or actuators, unbound commandable joints, bad directions/gear ratios/limits, and homing or limit inputs that are not declared ports.

    Returns no warnings when the tree declares no bindings, so examples without a control map are not forced to provide one.

    Component::control_constants

    fn Component::control_constants(self : Component, joint_positions? : Map[String, Double]) -> ControlConstants

    Builds the control constants from the current component tree: a static analysis at the zero pose plus the limits and binding of every commandable joint (the set exported in control.yaml and pins.csv).

    Component::control_params_header

    fn Component::control_params_header(self : Component, joint_positions? : Map[String, Double]) -> String

    A C/C++ header with the robot's mass, CoM, inertia, and joint constants.

    Component::display_name

    fn Component::display_name(self : Component) -> String

    Returns the name used for the exported robot and design: the explicit robot name when set, otherwise the root component name.

    Component::explode_diagnostics

    fn Component::explode_diagnostics(self : Component, joint_positions? : Map[String, Double], scale? : Double) -> ExplodeTreeDiagnostics

    Non-raising validation of the ExplodeSpec tree. Use is_ok() to gate a build and message() for the failure text.

    Component::explode_offsets

    fn Component::explode_offsets(self : Component, joint_positions? : Map[String, Double], scale? : Double) -> Array[(String, (Double, Double, Double))]

    Explicit per-node explode offsets — the canonical output contract shared by all three mechanisms. One entry per exploded design node, in node order. Node names match to_design (imported multi-body bodies collapse to their shared part_group), so the offsets line up with the products in the written STEP/GLB — collapsing bodies share a link, hence share an offset.

    Component::fastener_table_csv

    fn Component::fastener_table_csv(self : Component) -> String

    The fastener schedule with torque, one row per component entry.

    Component::fea_load_cases

    fn Component::fea_load_cases(self : Component) -> Array[FeaLoadCase]

    Collects this component's load cases and every descendant's, depth-first.

    Component::firmware_header

    fn Component::firmware_header(self : Component) -> String

    A C header for firmware: joint-to-actuator bindings and sensor interfaces.

    The tables are derived from ControlBindings and SensorSpecs in the tree.

    Component::format_documentation

    fn Component::format_documentation(self : Component) -> String

    Formats the component's name, description, and sorted parameters for STEP headers.

    Component::from_step_component

    fn Component::from_step_component(name : String, step_comp :
    Component
    , density? :
    Density
    , part? : PartMeta?, connector_prefix? : String, include_connectors? : Bool, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Component

    Converts a STEP primitive component into a CAD Component.

    The component inherits the primitive's description, its metadata as design parameters, and its modeled-feature list.

    Component::from_step_layer

    fn Component::from_step_layer(name : String, step_comp :
    Component
    , layer_name : String, density? :
    Density
    , part? : PartMeta?, connector_prefix? : String, include_connectors? : Bool, apply_placement? : Bool, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Component

    Converts one named layer of a multi-layer STEP component into a CAD Component.

    This splits a composite primitive (the sun, planet, and ring layers of a Tier-1 planetary gearbox, or the rolling elements of a bearing) into independent kinematic and printable links while preserving each layer's exact geometry. Semantic mate connectors whose names begin with the layer name are propagated; the implicit "origin" mate always exists.

    Component::from_step_layers

    fn Component::from_step_layers(name : String, step_comp :
    Component
    , layer_names : Array[String], label? : String, density? :
    Density
    , part? : PartMeta?, connector_prefix? : String, include_connectors? : Bool, apply_placement? : Bool, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Component

    Converts a selected subset of named layers from a multi-layer STEP component into a single CAD Component whose bodies move together as one rigid link.

    Component::get_mate

    Looks up a mate connector by name.

    Component::harness_checks

    fn Component::harness_checks(self : Component) -> Array[String]

    Checks cable routes: valid geometry, known wire names, and wire runs that are long enough for the route they follow.

    Returns no warnings when the tree declares no routes.

    Component::has_explode_spec

    fn Component::has_explode_spec(self : Component) -> Bool

    Returns true when any attachment in this component tree carries an ExplodeSpec.

    Component::inspect_json

    fn Component::inspect_json(self : Component, bed? : PrintBedSpec, joint_positions? : Map[String, Double]) -> String

    Whole-robot summary as a JSON document.

    Includes the mass, CoM, inertia, world bounding box, links, joints, static torque margins, printable parts (size, bed fit, estimated printed mass), the OBB interference pass, BOM totals, and the generated view names.

    Component::is_gearset_layer

    fn Component::is_gearset_layer(self : Component, part_number : String) -> Bool

    True when part_number is one of the layer parts that merge into a print-in-place cartridge declared via the print_in_place_gearset parameter (e.g. PGB-SUN when the set declares PGB-CARTRIDGE). Layers are not printed separately; the cartridge ships as a single STEP. Used by the printable-parts exporters so the files match print-list.csv.
    fn Component::link_design(self : Component, link_name : String) ->
    Design
    ?

    Returns a CAD design containing one link's bodies in its local frame.
    fn Component::link_parts_csv(self : Component) -> String

    Maps each exportable link (component) to the BOM part numbers of its bodies.

    Component::lqr_model_python

    fn Component::lqr_model_python(self : Component, joint_positions? : Map[String, Double]) -> String

    A ready-to-run Python module with the same constants and a linearized inverted-pendulum state-space helper.

    Component::lqr_poses

    fn Component::lqr_poses(self : Component, joint_positions? : Map[String, Double]) -> Array[LqrPose]

    Inverted-pendulum linearization and LQR gains for every pose in Component::analysis_poses (or for joint_positions when given). Used to embed a height-scheduled gain table in lqr_model.py and the pose table in control_params.h.

    Component::name_key_text

    fn Component::name_key_text(self : Component, name? : String) -> String

    Maps the CAD names used in the assembly steps to the part a builder picks up. Long names with a shared prefix are capped so the file stays readable.

    Component::new

    fn Component::new(name : String, description? : String) -> Component

    Creates an empty component with a default "origin" mate.

    Component::pcb_placements_csv

    fn Component::pcb_placements_csv(self : Component) -> String

    KiCad/PCB placement map: one row per imported connector placement.

    Component::placed_shapes

    fn Component::placed_shapes(self : Component, joint_positions? : Map[String, Double]) -> Array[
    PlacedShape
    ]

    Every body in the posed component tree as a placed oriented bounding box.

    Bodies inside one link are treated as one rigid instance; merged fasteners and bearings are therefore not reported against their host. The OBB uses the body's exact local bounding box, which is conservative for curved profiles.

    Component::power_budget

    fn Component::power_budget(self : Component) -> PowerBudget

    Walks the tree and collects actuator, sensor, port, and wire data.

    Component::print_list_csv

    fn Component::print_list_csv(self : Component, bed? : PrintBedSpec) -> String

    Manufactured (non-purchased) parts with print/cut settings, print-bed fit, and rough mass/time estimates.

    Component::print_settings_line

    fn Component::print_settings_line(self : Component, part_number : String, process : String) -> String?

    The one-line key=value print metadata embedded in the STEP header of printable parts: maker=<component>; layer_height_mm=...; infill_pct=...;support=...; nozzle_mm=0.4. Consumed by scripts/step_to_3mf.py and scripts/export_printable_meshes.py to embed the settings into 3MF metadata (CadLayerHeightMm et al. and print_settings in Metadata/provenance.json). None when process is not a print process.

    Component::printable_parts

    fn Component::printable_parts(self : Component) -> Array[PrintablePart]

    Collects standalone printable/fabricated designs from this component tree.

    A whole component marked fabricated is exported with all its bodies. A body-level part number collects every body sharing that number. Pre-order traversal and part-number de-duplication make each printable part appear once.

    Component::report_text

    fn Component::report_text(self : Component) -> String

    The full power/IO/wiring report for this component tree.

    Component::rl_task_checks

    fn Component::rl_task_checks(self : Component) -> Array[String]

    Validation for an attached RL spec. Empty means consistent.

    Component::rl_task_json

    fn Component::rl_task_json(self : Component, joint_positions? : Map[String, Double]) -> String

    The RL task contract as a JSON document. "null" when no task is attached.

    Component::sourcing_csv

    fn Component::sourcing_csv(self : Component) -> String

    Sourcing lines derived from the BOM, including supplier links and cost.

    Component::start_here_text

    fn Component::start_here_text(self : Component, name? : String, bed? : PrintBedSpec) -> String

    Renders the START-HERE.md onboarding document for the build package: ordered print/assemble/test steps, an interactive viewer embed, and per-part print settings. name overrides the package name (defaults to the component's display name); bed selects the reference print bed used for the fit check.

    Component::to_assembly_step

    fn Component::to_assembly_step(self : Component, joint_positions? : Map[String, Double], cap? :
    DetailLevel
    ?) -> String

    Exports the posed design as a hierarchical assembly STEP file.

    Component::to_blender_python

    fn Component::to_blender_python(self : Component, joint_positions? : Map[String, Double], segments? : Int, cap? :
    DetailLevel
    ?) -> String

    Exports the posed design as a Blender 5.0 Python script.

    Component::to_bom_csv

    fn Component::to_bom_csv(self : Component) -> String

    Convenience: the bill of materials as CSV.

    Component::to_design

    fn Component::to_design(self : Component, joint_positions? : Map[String, Double], cap? :
    DetailLevel
    ?) ->
    Design

    Produces a posed design with every link's bodies in world coordinates (millimeters and degrees) for the given joint positions.

    When cap is set, bodies whose PartMeta::detail exceeds the cap are omitted from the design (bodies without a tag are always included). Use this to keep assembly/exploded STEP free of expensive high-detail bodies such as helical threads; printable exports should call it with None.

    Component::to_exploded_design

    fn Component::to_exploded_design(self : Component, joint_positions? : Map[String, Double], scale? : Double, trace_lines? : Bool, cap? :
    DetailLevel
    ?) ->
    Design

    Produces an exploded, role-colored design for this component tree.

    Each ExplodeSpec on an attachment moves that child and every descendant cumulatively, so a leg that separates also carries its wheel. scale multiplies every separation (0 reproduces the assembled placement, 2 doubles it). trace_lines adds thin dashed coaxial guides between each parent mate origin and its exploded child mate origin.

    Bodies keep an explicit color; the builder's default gray is replaced by a deterministic role palette.

    Component::to_gltf

    fn Component::to_gltf(self : Component, joint_positions? : Map[String, Double], cap? :
    DetailLevel
    ?) -> String

    Exports the posed design as a Z-up glTF 2.0 JSON document.

    Component::to_pin_map_csv

    fn Component::to_pin_map_csv(self : Component) -> String

    Renders the firmware pin map as CSV: one row per binding.

    Component::to_robot

    fn Component::to_robot(self : Component, package_name? : String?) ->
    Robot

    Builds a complete URDF robot from the component tree.

    Component::to_ros2_control_yaml

    fn Component::to_ros2_control_yaml(self : Component, controller_name? : String, update_rate_hz? : Double) -> String

    Renders a ros2_control configuration mapping every declared binding.

    The controller manager exposes a joint-state broadcaster and a joint trajectory controller over the bound joints. The hardware section carries the actuator, channel, pins, direction, gear ratio, soft limits, homing and limit inputs for each joint, plus the sensor interfaces.

    Component::to_step_file

    fn Component::to_step_file(self : Component, joint_positions? : Map[String, Double], cap? :
    DetailLevel
    ?) -> String

    Exports the posed design as a flat STEP file.

    Component::to_urdf_bundle

    fn Component::to_urdf_bundle(self : Component, package_name? : String, include_step_parts? : Bool, joint_positions? : Map[String, Double]) ->
    UrdfBundle

    Builds a ROS 2 URDF bundle with per-link glTF meshes and printable STEP parts.

    Component::total_mass_kg

    fn Component::total_mass_kg(self : Component) -> Double

    Recursively sums the mass of every body in the component tree.

    Component::wiring_checks

    fn Component::wiring_checks(self : Component) -> Array[String]

    Connector mating checks: every wire and cable-route endpoint must resolve to a component and (when given) a port, and every wire carried by a route must actually connect that route's two components.

    Component::with_actuator

    fn Component::with_actuator(self : Component, actuator : ActuatorSpec) -> Component

    Sets the actuator ratings for this component.

    Component::with_analysis_poses

    fn Component::with_analysis_poses(self : Component, poses : Array[(String, Map[String, Double])]) -> Component

    Declares the named poses used for statics and control-constant generation. Each pose is joint positions in radians keyed by joint name, evaluated with the same FK used by --analyze. Overrides the default single zero pose.

    Component::with_cable_route

    fn Component::with_cable_route(self : Component, route : CableRoute) -> Component

    Sets the routed cable bundles for this component.

    Component::with_collision_cylinder_mm

    fn Component::with_collision_cylinder_mm(self : Component, radius_mm~ : Double, length_mm~ : Double, x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) -> Component

    Replaces the component's own collision primitives with one exact rolling cylinder (axis local Z, oriented by the millimeter/degree pose). Use for wheels and tires so simulators get a true cylinder instead of a bounding box; attached child bodies keep their own collisions.

    Component::with_description

    fn Component::with_description(self : Component, description : String) -> Component

    Replaces the component description.

    Component::with_param

    fn Component::with_param(self : Component, key : String, value : String) -> Component

    Records a design parameter for documentation and STEP headers.

    Component::with_part

    fn Component::with_part(self : Component, part : PartMeta) -> Component

    Sets purchasing/manufacturing metadata for the whole component.

    Component::with_pcb

    fn Component::with_pcb(self : Component, pcb : PcbSpec) -> Component

    Sets the PCB envelope metadata for this component.

    Component::with_print_bed_orient

    fn Component::with_print_bed_orient(self : Component, orient : PrintBedOrient) -> Component

    Sets the print-bed orientation on this component's part metadata and its bodies' part metadata.

    Component::with_rl_task

    fn Component::with_rl_task(self : Component, spec : RlTaskSpec) -> Component

    Attaches spec as this component's RL task, replacing any existing one; the spec is exported as rl_task.json next to the MJCF model by the RL export path.

    Component::with_robot_name

    fn Component::with_robot_name(self : Component, name : String) -> Component

    Sets the exported robot/design name independently of the root link name.

    Component::with_sensor

    fn Component::with_sensor(self : Component, sensor : SensorSpec) -> Component

    Sets the sensor characteristics for this component.
    fn Component::with_supplier_links(self : Component, links : Array[SupplierLink]) -> Component

    Applies purchasing-link overrides throughout this component tree. Existing values are kept when a link leaves a field empty.

    ConnectionKind

    pub(all) enum ConnectionKind {
    MergeRigid
    Fixed
    Revolute(
    JointLimit
    )
    Continuous(
    JointLimit
    ?)
    Prismatic(
    JointLimit
    )
    } derive(
    Debug
    )

    How an attached child component connects to its parent.

    ConnectionKind::to_repr

    automatically derived

    ContactAlignment

    pub(all) struct ContactAlignment {
    name : String
    min_z_m : Double
    } derive(Eq,
    Debug
    )

    Minimum world Z of one wheel or foot contact link.

    ControlBinding

    pub(all) struct ControlBinding {
    joint : String
    actuator : String
    channel : String
    mcu_pins : String
    direction : String
    gear_ratio : Double
    soft_lower : Double?
    soft_upper : Double?
    homing_input : String?
    limit_input : String?
    }

    Maps one commandable robot joint onto an actuator, bus channel, and physical pins, with direction, gear ratio, soft limits, and homing/limit inputs.

    ControlBinding::new

    fn ControlBinding::new(joint : String, actuator? : String, channel? : String, mcu_pins? : String, direction? : String, gear_ratio? : Double, soft_lower? : Double?, soft_upper? : Double?, homing_input? : String?, limit_input? : String?) -> ControlBinding

    Builds a binding with keyword overrides. Defaults: empty actuator/channel/pins, "normal" direction, 1:1 gear ratio, no soft limits, homing, or limit inputs.

    ControlConstants

    pub(all) struct ControlConstants {
    robot_name : String
    total_mass_kg : Double
    com_x_m : Double
    com_y_m : Double
    com_z_m : Double
    ixx_kgm2 : Double
    iyy_kgm2 : Double
    izz_kgm2 : Double
    ground_z_m : Double
    joints : Array[ControlJointConstants]
    } derive(Eq,
    Debug
    )

    Whole-robot constants for firmware and LQR/EKF models.

    ControlJointConstants

    pub(all) struct ControlJointConstants {
    joint : String
    actuator : String
    channel : String
    gear_ratio : Double
    lower : Double?
    upper : Double?
    effort : Double
    velocity : Double
    } derive(Eq,
    Debug
    )

    One joint's exported control constants.

    DomainRandSpec

    pub(all) struct DomainRandSpec {
    mass_scale_range : (Double, Double)
    friction_range : (Double, Double)
    kp_scale_range : (Double, Double)
    push_impulse_ns : Double
    obs_noise_std : Double
    } derive(Eq,
    Debug
    )

    Domain randomization ranges and disturbances applied on reset.

    DomainRandSpec::new

    fn DomainRandSpec::new(mass_scale_range? : (Double, Double), friction_range? : (Double, Double), kp_scale_range? : (Double, Double), push_impulse_ns? : Double, obs_noise_std? : Double) -> DomainRandSpec

    Builds a domain-randomization spec; omitted arguments keep the defaults (mass [0.9, 1.1], friction [0.7, 1.3], kp [0.9, 1.1], no pushes, no noise).

    ExplodeDiagnostics

    pub struct ExplodeDiagnostics {
    unmatched : Array[String]
    empty_layers : Array[(Int, String)]
    host_violations : Array[HostViolation]
    overlapped_layers : Array[(Int, Int, Double)]
    out_of_order : Array[(Int, Int)]
    slide_undeclared : Array[String]
    prefix_collisions : Array[(String, String, String)]
    }

    Everything the strict offsets() refuses to accept.

    ExplodeDiagnostics::is_ok

    fn ExplodeDiagnostics::is_ok(self : ExplodeDiagnostics) -> Bool

    True when no errors were found: no unmatched nodes, empty layers, host violations, overlapping or out-of-order layers, or undeclared slides. Prefix collisions are advisory and do not affect the result.

    ExplodeLayer

    pub struct ExplodeLayer {
    patterns : Array[String]
    gap_override_mm : Double?
    predicate : (
    SceneNode
    ) -> Bool?
    match_mode : MatchMode
    label : String
    reason : String
    slide_mm : (Double, Double, Double)
    color :
    Rgb
    ?
    host : String?
    side : ExplodeSide
    }

    One layer in an ExplodeStack: a fluent value built with new and with_*. Layers match any node whose name satisfies match_mode against at least one of patterns (and predicate when set).

    This is a domain value, not an options struct used to bundle function arguments: the same value is consumed by placements(), diagnostics() and plan_json(), so labels, reasons, hosts and colors live on the layer itself and are reported in the generated plan.

    ExplodeLayer::exact

    Matches node names exactly, so a short name cannot swallow a longer one.

    ExplodeLayer::glob

    Matches node names with a shell-style * glob.

    ExplodeLayer::new

    fn ExplodeLayer::new(label~ : String, patterns~ : Array[String]) -> ExplodeLayer

    Starts a layer: a short label and the patterns that select its nodes. Everything else defaults; declare options with the with_* methods.

    Example

    test {
    let l = @cad.ExplodeLayer::new(label="fan", patterns=["krc_cover_fan"])
    inspect(l.label, content="fan")
    }

    ExplodeLayer::with_color

    Applies a role color to every node in the layer via apply().

    ExplodeLayer::with_gap

    fn ExplodeLayer::with_gap(self : ExplodeLayer, gap_mm : Double) -> ExplodeLayer

    Overrides the stack's default inter-layer gap for this layer only.

    ExplodeLayer::with_host

    fn ExplodeLayer::with_host(self : ExplodeLayer, host : String) -> ExplodeLayer

    The part this fastener group clamps; diagnostics() validates it.

    ExplodeLayer::with_match_mode

    fn ExplodeLayer::with_match_mode(self : ExplodeLayer, mode : MatchMode) -> ExplodeLayer

    Compares node names with match_mode (see also exact/glob).

    ExplodeLayer::with_predicate

    fn ExplodeLayer::with_predicate(self : ExplodeLayer, predicate : (
    SceneNode
    ) -> Bool) -> ExplodeLayer

    Filters nodes that share a pattern (e.g. upper vs. lower inserts).

    ExplodeLayer::with_reason

    fn ExplodeLayer::with_reason(self : ExplodeLayer, reason : String) -> ExplodeLayer

    Why this layer sits where it does; emitted by describe().

    ExplodeLayer::with_side

    fn ExplodeLayer::with_side(self : ExplodeLayer, side : ExplodeSide) -> ExplodeLayer

    Puts the layer below the anchor (-Z) instead of above (+Z).

    ExplodeLayer::with_slide

    fn ExplodeLayer::with_slide(self : ExplodeLayer, slide_mm : (Double, Double, Double)) -> ExplodeLayer

    Slides the whole subassembly off the main axis, in millimeters.

    ExplodeOffsetNode

    pub struct ExplodeOffsetNode {
    name : String
    offset_mm : (Double, Double, Double)
    assembled_center_mm : (Double, Double, Double)?
    color :
    Rgb
    ?
    }

    One node in the canonical explode-offsets.json contract. All three explode mechanisms emit this value, so no plan is ever reconstructed from comparing an assembled STEP against an exploded STEP.

    ExplodeOffsetNode::new

    fn ExplodeOffsetNode::new(name~ : String, offset_mm~ : (Double, Double, Double), assembled_center_mm? : (Double, Double, Double), color? :
    Rgb
    ) -> ExplodeOffsetNode

    Builds one node entry. name is the fully qualified node name emitted by to_design(); offset_mm is its declared explode displacement. The assembled center and role color are optional.

    ExplodeOffsets

    pub struct ExplodeOffsets {
    layout : String
    source : String
    nodes : Array[ExplodeOffsetNode]
    layers : Array[LayerPlacement]
    }

    The single declared output of an explode: explicit per-node offsets plus the layout class that tells check_explode.py which geometric rules apply.

    ExplodeOffsets::coaxial

    A collision-free coaxial stack (mechanism 1).

    Example

    test {
    let o = @cad.ExplodeOffsets::coaxial([
    @cad.ExplodeOffsetNode::new(name="a", offset_mm=(0.0, 0.0, 10.0)),
    ])
    inspect(o.layout, content="coaxial")
    inspect(o.source, content="declared")
    inspect(o.nodes.length(), content="1")
    }

    ExplodeOffsets::freeform

    A hand-tuned radial or mate-axis explosion (mechanisms 2 and 3).

    Example

    test {
    let o = @cad.ExplodeOffsets::freeform([
    @cad.ExplodeOffsetNode::new(name="screw", offset_mm=(24.0, 0.0, 475.0)),
    ])
    inspect(o.layout, content="freeform")
    inspect(o.to_json().contains("explode-offsets@1"), content="true")
    }

    ExplodeOffsets::to_json

    fn ExplodeOffsets::to_json(self : ExplodeOffsets) -> String raise ExplodeError

    Serializes the canonical offsets document consumed by scripts/explode_offsets.py. Raises ExplodeError rather than emitting a document that the plan tooling would reject.

    ExplodeOffsets::validate

    fn ExplodeOffsets::validate(self : ExplodeOffsets) -> Array[String]

    Returns the problems that would make this offsets document invalid. Mirrors scripts/explode_offsets.py::validate so a malformed document is caught at the point of writing rather than downstream.

    ExplodeSide

    pub(all) enum ExplodeSide {
    Above
    Below
    }

    Which side of the anchor a layer explodes toward.

    ExplodeSpec

    pub(all) enum ExplodeSpec {
    AlongMate(Double, Int)
    AlongMateLocal(Double, Int)
    OffsetMm(Double, Double, Double, Int)
    } derive(Eq,
    Debug
    )

    How an attached child separates from its parent in an exploded view.

    order is a positive assembly stage; it multiplies the separation so later stages move further. An AlongMate distance may be negative to explode in the opposite direction of the parent mate's declared axis.

    ExplodeSpec::along_mate

    fn ExplodeSpec::along_mate(distance_mm~ : Double, order? : Int) -> ExplodeSpec

    Explodes a child along the parent mate's outward axis, which is expressed in the parent link frame. Use along_mate_local when the axis should follow the mate's placement rotation.

    ExplodeSpec::along_mate_local

    fn ExplodeSpec::along_mate_local(distance_mm~ : Double, order? : Int) -> ExplodeSpec

    Explodes a child along the parent mate's axis rotated into the mate's own frame by its placement rotation.

    ExplodeSpec::offset_mm

    fn ExplodeSpec::offset_mm(dx~ : Double, dy~ : Double, dz~ : Double, order? : Int) -> ExplodeSpec

    Explodes a child along an explicit vector in the parent's frame.

    ExplodeStack

    pub struct ExplodeStack {
    anchor_patterns : Array[String]
    above_layers : Array[ExplodeLayer]
    below_layers : Array[ExplodeLayer]
    default_gap_mm : Double
    allowed_unmatched : Array[String]
    }

    Declarative Z-axis explode layout anchored at one or more stationary parts, with ordered layers exploding in +Z (above) and -Z (below) directions.

    ExplodeStack::allow_unmatched

    fn ExplodeStack::allow_unmatched(self : ExplodeStack, patterns : Array[String]) -> ExplodeStack

    Marks node substrings that are intentionally left in the assembled position. diagnostics() no longer reports them, but they still receive a zero offset.

    ExplodeStack::apply

    Returns a new @step_cad.Design with every matched node translated by its collision-free coaxial explode offset, slide, and optional role color. Strict by default, like offsets(): raises ExplodeError on a malformed stack. Use allow_unmatched() for intentionally stationary nodes.

    ExplodeStack::describe

    fn ExplodeStack::describe(self : ExplodeStack, design :
    Design
    ) -> String

    Renders the layer plan as Markdown from placements(). Generated prose belongs in build/<n>/explode-plan.md, not in committed README files.

    ExplodeStack::diagnostics

    Verifies the stack against a design without raising. offsets() keeps its Historical silent behavior is gone; offsets() now fails loudly.

    ExplodeStack::group

    fn ExplodeStack::group(self : ExplodeStack, layer : ExplodeLayer) -> ExplodeStack

    Appends one declared layer — the single way to build an exploded stack. The layer value carries its own match mode, side, slide, color, host and reason, so group() needs exactly that one argument.

    Example

    test {
    let d = @step_cad.Design::new(name="es")
    .add(@step_cad.Cylinder::new(10.0, 5.0).with_name("base").translate(z=0.0))
    .add(
    @step_cad.Cylinder::new(8.0, 4.0).with_name("bearing").translate(z=7.0),
    )
    let s = @cad.ExplodeStack::z_axis(anchor="base", gap_mm=10.0).group(
    @cad.ExplodeLayer::new(label="bearing", patterns=["bearing"]),
    )
    inspect(s.diagnostics(d).is_ok(), content="true")
    }

    ExplodeStack::offsets

    fn ExplodeStack::offsets(self : ExplodeStack, design :
    Design
    ) -> Array[(String, (Double, Double, Double))] raise ExplodeError

    Computes collision-free (dx, dy, dz) explode offsets (mm) for every node in design (in the same order as design.nodes()).

    Strict by default: raises ExplodeError when diagnostics() finds unclassified nodes, empty layers, a broken host assertion, overlapping spans, or an undocumented slide. Use allow_unmatched() to declare intentionally stationary nodes, or placements() / plan_json() for introspection that must not raise.

    ExplodeStack::placements

    Every declared layer's computed placement, in stack order (below layers first, then above layers). Unlike offsets(), these are final world-space spans in millimeters, not deltas, so sorting them is meaningful.

    ExplodeStack::plan_json

    fn ExplodeStack::plan_json(self : ExplodeStack, design :
    Design
    , example? : String) -> String

    Machine-readable layer plan in millimeters, consumed by scripts/check_explode.py and scripts/explode_strip.py.

    ExplodeStack::to_offsets

    Canonical declared offsets for this stack. One entry per design node with its exact offset, role color and assembled center; coaxial because offsets() spaces layers collision-free along Z. Strict like offsets().

    ExplodeStack::with_anchor

    fn ExplodeStack::with_anchor(self : ExplodeStack, pattern : String) -> ExplodeStack

    Adds an additional stationary anchor substring to this stack.

    ExplodeStack::z_axis

    fn ExplodeStack::z_axis(anchor~ : String, gap_mm? : Double) -> ExplodeStack

    Starts a Z-axis coaxial ExplodeStack anchored on parts whose name contains anchor, with default inter-layer clearance gap_mm.

    ExplodeTreeDiagnostics

    pub struct ExplodeTreeDiagnostics {
    ineffective_specs : Array[String]
    non_finite : Array[String]
    duplicate_links : Array[String]
    order_regressions : Array[(String, Int, Int)]
    }

    Non-raising diagnostics for a first-class ExplodeSpec explosion. Mirrors ExplodeDiagnostics so the joint-tree mechanism gets the same loud-failure checks as a declared @cad.ExplodeStack.

    ExplodeTreeDiagnostics::is_ok

    Only definite errors fail a build. A decreasing order can be intentional (it scales separation), and a spec on a rigidly merged child is ignored by design, so those two fields are advisory and never make is_ok() false.

    ExplodeTreeDiagnostics::message

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

    Multi-line, human-readable summary of the diagnostics; prefixes every entry with its category (ineffective spec, non-finite offset, duplicate link, or order regression).

    ExplodeTreeDiagnostics::to_json

    fn ExplodeTreeDiagnostics::to_json(self : ExplodeTreeDiagnostics) -> String

    Serializes diagnostics into explode-diagnostics.json for a build package. Advisory findings (ineffective specs, order regressions) are included even when is_ok() is true, so they are discoverable without calling the API.

    Fastener

    pub(all) struct Fastener {
    name : String
    kind : FastenerKind
    thread : String
    length_mm : Double
    engagement_mm : Double
    quantity : Int
    torque_nm : Double
    references : Array[String]
    part : PartMeta?
    host : String
    }

    A fastener schedule entry: thread, length, quantity, torque, and the parts or mates it joins. host is the part the fastener clamps; it defaults so every existing call site stays source compatible.

    Fastener::new

    fn Fastener::new(name : String, kind : FastenerKind, thread? : String, length_mm? : Double, engagement_mm? : Double, quantity? : Int, torque_nm? : Double, references? : Array[String], part? : PartMeta?, host? : String) -> Fastener

    Creates a fastener schedule entry; defaults model one unspecified item: empty thread, zero length and torque, unit quantity.

    Fastener::with_part

    fn Fastener::with_part(self : Fastener, part : PartMeta) -> Fastener

    Returns a copy with the purchasing metadata attached.

    FastenerKind

    pub(all) enum FastenerKind {
    Bolt
    Screw
    Nut
    Washer
    Insert
    }

    The kind of hardware a fastener record describes.

    FeaLoad

    pub(all) enum FeaLoad {
    Force(region~ : BoundaryRegion, force_n~ : (Double, Double, Double))
    Torque(region~ : BoundaryRegion, origin_mm~ : (Double, Double, Double), axis~ : (Double, Double, Double), torque_nm~ : Double)
    Pressure(region~ : BoundaryRegion, pressure_mpa~ : Double)
    }

    A structural load applied to a boundary region.

    FeaLoadCase

    pub(all) struct FeaLoadCase {
    name : String
    part_number : String
    material : MaterialProperties
    constraints : Array[BoundaryRegion]
    loads : Array[FeaLoad]
    mesh_size_mm : Double
    print_z_axis : (Double, Double, Double)
    safety_factor_target : Double
    }

    One linear-elastic static load case: material, fixed regions, loads, and meshing/acceptance settings.

    FeaLoadCase::new

    fn FeaLoadCase::new(name : String, part_number~ : String) -> FeaLoadCase

    Creates a load case with PLA, a 3 mm mesh, a +Z print axis, and a safety factor target of 2.0.

    FeaLoadCase::to_json

    fn FeaLoadCase::to_json(self : FeaLoadCase) -> String

    One load case as a standalone JSON object.

    FeaLoadCase::with_fixed

    fn FeaLoadCase::with_fixed(self : FeaLoadCase, region : BoundaryRegion) -> FeaLoadCase

    Returns a copy with region appended to the fixed-constraint set.

    FeaLoadCase::with_force

    fn FeaLoadCase::with_force(self : FeaLoadCase, region : BoundaryRegion, force_n : (Double, Double, Double)) -> FeaLoadCase

    Returns a copy with a concentrated force added, in newtons, distributed over region.

    FeaLoadCase::with_material

    fn FeaLoadCase::with_material(self : FeaLoadCase, material : MaterialProperties) -> FeaLoadCase

    Returns a copy of this load case with material replaced.

    FeaLoadCase::with_mesh_size_mm

    fn FeaLoadCase::with_mesh_size_mm(self : FeaLoadCase, mesh_size_mm : Double) -> FeaLoadCase

    Returns a copy with the target mesh element size set to mesh_size_mm (millimeters).

    FeaLoadCase::with_pressure

    fn FeaLoadCase::with_pressure(self : FeaLoadCase, region : BoundaryRegion, pressure_mpa : Double) -> FeaLoadCase

    Returns a copy with an inward surface pressure added, in MPa, over region.

    FeaLoadCase::with_print_z_axis

    fn FeaLoadCase::with_print_z_axis(self : FeaLoadCase, print_z_axis : (Double, Double, Double)) -> FeaLoadCase

    Returns a copy with the print build direction set; used to evaluate interlayer (Z) strength.

    FeaLoadCase::with_safety_factor_target

    fn FeaLoadCase::with_safety_factor_target(self : FeaLoadCase, safety_factor_target : Double) -> FeaLoadCase

    Returns a copy with the required factor of safety changed; must be > 0 to be meaningful.

    FeaLoadCase::with_torque

    fn FeaLoadCase::with_torque(self : FeaLoadCase, region : BoundaryRegion, origin_mm~ : (Double, Double, Double), axis~ : (Double, Double, Double), torque_nm~ : Double) -> FeaLoadCase

    Returns a copy with a concentrated torque added, in N·m about axis through origin_mm.

    Fit

    pub(all) struct Fit {
    name : String
    fit_class : FitClass
    nominal_mm : Double
    min_mm : Double
    max_mm : Double
    }

    A named fit with a nominal size and the allowed tolerance range.

    Fit::new

    fn Fit::new(name : String, fit_class : FitClass, nominal_mm? : Double, min_mm? : Double, max_mm? : Double) -> Fit

    Creates a fit record; unspecified limits default to 0.

    FitClass

    pub(all) enum FitClass {
    Nominal
    Clearance
    Transition
    Interference
    }

    A fit record: nominal size plus the allowed range.

    HostViolation

    pub struct HostViolation {
    layer_index : Int
    label : String
    host : String
    message : String
    }

    A failed host assertion.

    JointSpec

    The kinematic parameters of an attachment plus the shared geometric mate pair.

    The pair owns the parent connector name, child connector name, offset, twist, flip, and fit. JointSpec keeps only what is kinematic: the joint kind, limits, dynamics, mimic, and transmission reduction.

    JointSpec::continuous

    fn JointSpec::continuous(limit? :
    JointLimit
    ?, offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? :
    JointDynamics
    ?, mimic? :
    JointMimic
    ?, transmission_reduction? : Double?) -> JointSpec

    Creates a continuous joint with an optional limit.

    JointSpec::continuous_limit

    fn JointSpec::continuous_limit(effort~ : Double, velocity~ : Double) -> JointSpec

    Creates a continuous joint limited only by effort and velocity (no angular bounds).

    JointSpec::fixed

    fn JointSpec::fixed(offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool) -> JointSpec

    Creates a fixed kinematic joint.

    JointSpec::merge_rigid

    fn JointSpec::merge_rigid(offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool) -> JointSpec

    Folds the child's bodies directly into the parent link: no joint is emitted.

    JointSpec::prismatic

    fn JointSpec::prismatic(limit :
    JointLimit
    , offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? :
    JointDynamics
    ?, mimic? :
    JointMimic
    ?, transmission_reduction? : Double?) -> JointSpec

    Creates a prismatic joint with the given limit.

    JointSpec::revolute

    fn JointSpec::revolute(limit :
    JointLimit
    , offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? :
    JointDynamics
    ?, mimic? :
    JointMimic
    ?, transmission_reduction? : Double?) -> JointSpec

    Creates a revolute joint with the given limit.

    JointSpec::revolute_deg

    fn JointSpec::revolute_deg(lower_deg~ : Double, upper_deg~ : Double, effort~ : Double, velocity~ : Double) -> JointSpec

    Creates a revolute joint from degree-based limits, converting each bound to radians for the URDF joint limit.

    JointSpec::to_repr

    automatically derived

    JointTorque

    pub(all) struct JointTorque {
    joint : String
    tau_static_nm : Double
    tau_rated_nm : Double
    safety_factor : Double
    passive : Bool
    ok : Bool
    } derive(Eq,
    Debug
    )

    Static gravity torque and actuator margin at one joint.

    LayerPlacement

    pub struct LayerPlacement {
    index : Int
    side : Int
    label : String
    reason : String
    matched_names : Array[String]
    assembled_span_mm : (Double, Double)
    final_span_mm : (Double, Double)
    offset_mm : (Double, Double, Double)
    declared_gap_mm : Double
    host : String?
    slide_mm : (Double, Double, Double)
    color :
    Rgb
    ?
    }

    One declared layer's final placement, in millimeters.

    LqrPose

    pub(all) struct LqrPose {
    name : String
    com_height_m : Double
    a_theta : Double
    b_torque : Double
    k_theta : Double
    k_theta_dot : Double
    } derive(Eq,
    Debug
    )

    One LQR operating point derived from a statics pose: the combined center of mass height above the lowest ground contact, plus the gains of the linearized inverted-pendulum model for that pose.

    MatchMode

    pub(all) enum MatchMode {
    Contains
    Exact
    Glob
    }

    How a layer's patterns are compared against a SceneNode name.

    MaterialProperties

    pub(all) struct MaterialProperties {
    e_mpa : Double
    nu : Double
    yield_xy_mpa : Double
    interlayer_z_mpa : Double
    density_kg_m3 : Double
    }

    Orthotropic-homogenized elastic and strength data for a printed or metallic material. Stresses are in MPa, density in kg/m³, and lengths in millimeters (matching printable/<PART>.step).

    MaterialProperties::aluminum_6061

    fn MaterialProperties::aluminum_6061() -> MaterialProperties

    6061-T6 aluminum (isotropic).

    MaterialProperties::from_name

    fn MaterialProperties::from_name(name : String) -> MaterialProperties

    Resolves a printable material name (case-insensitive substring match) to its property set. Unknown names fall back to PLA.

    MaterialProperties::new

    fn MaterialProperties::new(e_mpa~ : Double, nu~ : Double, yield_xy_mpa~ : Double, interlayer_z_mpa~ : Double, density_kg_m3~ : Double) -> MaterialProperties

    Builds a property set explicitly; prefer the pla/petg/pa_cf/aluminum_6061/steel_mild presets.

    MaterialProperties::pa_cf

    Carbon-fiber-filled nylon (PA-CF), the default high-torque printed part.

    MaterialProperties::petg

    PETG.

    MaterialProperties::pla

    Generic PLA.

    MaterialProperties::steel_mild

    Mild steel (isotropic).

    PartMeta

    pub(all) struct PartMeta {
    part_number : String
    description : String
    supplier : String
    supplier_url : String
    material : String
    process : String
    finish : String
    unit_cost_usd : Double
    notes : String
    print_bed_orient : PrintBedOrient
    single_body_print : Bool
    bom_quantity : Int
    detail :
    DetailLevel
    ?
    }

    Purchasing and manufacturing metadata for one part.

    PartMeta::new

    fn PartMeta::new(part_number : String, description? : String, supplier? : String, supplier_url? : String, material? : String, process? : String, finish? : String, unit_cost_usd? : Double, notes? : String, print_bed_orient? : PrintBedOrient, single_body_print? : Bool, bom_quantity? : Int, detail? :
    DetailLevel
    ?) -> PartMeta

    Creates part metadata; unspecified fields default to empty strings, zero cost, automatic print-bed orientation, a single exported body, and BOM quantity 1.

    PartMeta::with_bom_quantity

    fn PartMeta::with_bom_quantity(self : PartMeta, quantity : Int) -> PartMeta

    Sets how many purchased pieces this body represents in the BOM.

    PartMeta::with_detail

    Returns a copy tagged with the detail level the geometry was built at, so assembly exports capped below this level can drop the body.

    PartMeta::with_notes

    fn PartMeta::with_notes(self : PartMeta, notes : String) -> PartMeta

    Returns a copy with the notes field replaced.

    PartMeta::with_print_bed_orient

    fn PartMeta::with_print_bed_orient(self : PartMeta, orient : PrintBedOrient) -> PartMeta

    Returns a copy with the print-bed orientation replaced.

    PartMeta::with_single_body_print

    fn PartMeta::with_single_body_print(self : PartMeta, single_body_print : Bool) -> PartMeta

    Export only one body for this part; the BOM quantity records the copies.

    PartMeta::with_supplier_url

    fn PartMeta::with_supplier_url(self : PartMeta, supplier_url : String) -> PartMeta

    Returns a copy with the supplier URL replaced.

    PcbPlacement

    pub(all) struct PcbPlacement {
    reference : String
    value : String
    footprint : String
    x_mm : Double
    y_mm : Double
    rotation_deg : Double
    side : String
    }

    One component placement from a KiCad position file or equivalent.

    PcbPlacement::new

    fn PcbPlacement::new(reference? : String, value? : String, footprint? : String, x_mm? : Double, y_mm? : Double, rotation_deg? : Double, side? : String) -> PcbPlacement

    Creates a placement entry; defaults are an empty reference at the origin on an unspecified side.

    PcbSpec

    pub(all) struct PcbSpec {
    model : String
    length_mm : Double
    width_mm : Double
    thickness_mm : Double
    mounting_holes : Int
    mounting_hole_diam_mm : Double
    max_component_height_mm : Double
    connectors : Array[String]
    placements : Array[PcbPlacement]
    }

    A PCB envelope: outline, thickness, mounting holes, height limit, and the connectors that must be reachable.

    PcbSpec::new

    fn PcbSpec::new(model? : String, length_mm? : Double, width_mm? : Double, thickness_mm? : Double, mounting_holes? : Int, mounting_hole_diam_mm? : Double, max_component_height_mm? : Double, connectors? : Array[String], placements? : Array[PcbPlacement]) -> PcbSpec

    Creates a PCB envelope; defaults model a 1.6 mm board with four 2.7 mm mounting holes and no height limit or placements.

    Port

    pub(all) struct Port {
    name : String
    kind : PortKind
    spec : String
    }

    A named interface point on a component; spec carries the free-form details.

    Port::new

    fn Port::new(name : String, kind : PortKind, spec? : String) -> Port

    Creates a port; spec defaults to empty.

    PortKind

    pub(all) enum PortKind {
    Mechanical
    Power
    Signal
    Bus
    Fluid
    Sensor
    Ground
    }

    A typed interface exposed by a component.

    PortLine

    pub(all) struct PortLine {
    path : String
    name : String
    kind : String
    spec : String
    }

    One port line in the IO map.

    PoseAnalysis

    pub(all) struct PoseAnalysis {
    name : String
    total_mass_kg : Double
    com_m : (Double, Double, Double)
    inertia :
    Inertia

    joints : Array[JointTorque]
    contacts : Array[ContactAlignment]
    contact_misalignment_m : Double
    } derive(Eq,
    Debug
    )

    Whole-robot statics at one pose.

    PowerBudget

    pub(all) struct PowerBudget {
    actuators : Array[ActuatorLine]
    sensors : Array[SensorLine]
    ports : Array[PortLine]
    wires : Array[WireLine]
    routes : Array[RouteLine]
    }

    The electrical budget for a component tree.

    PowerBudget::new

    Creates an empty power budget.

    PowerBudget::to_text

    fn PowerBudget::to_text(self : PowerBudget) -> String

    Renders the power, IO, and wiring report.

    PrintBedOrient

    pub(all) enum PrintBedOrient {
    KeepAsIs
    AutoFlatLargestFace
    RotateDeg(Double, Double, Double)
    } derive(Eq,
    Debug
    )

    How a printable part is oriented on the print bed.

    PrintBedSpec

    pub(all) struct PrintBedSpec {
    width_mm : Double
    depth_mm : Double
    height_mm : Double
    } derive(Eq,
    Debug
    )

    The printer's usable build volume in millimeters.

    PrintBedSpec::default

    fn PrintBedSpec::default() -> PrintBedSpec

    The common 220 x 220 x 250 mm desktop-printer bed.

    PrintBedSpec::describe

    fn PrintBedSpec::describe(self : PrintBedSpec) -> String

    Renders the bed as WxDxH in whole millimeters for messages and logs, e.g. 220x220x250.

    PrintBedSpec::fits

    fn PrintBedSpec::fits(self : PrintBedSpec, width_mm : Double, depth_mm : Double, height_mm : Double) -> Bool

    Returns true when the given box (millimeters) fits the bed on every axis; no rotation of the part is considered.

    PrintBedSpec::new

    fn PrintBedSpec::new(width_mm? : Double, depth_mm? : Double, height_mm? : Double) -> PrintBedSpec

    Creates a print bed spec; defaults to the common 220 x 220 x 250 mm desktop bed. Pass all three dimensions for a different printer.

    PrintBedSpec::parse

    fn PrintBedSpec::parse(text : String) -> PrintBedSpec?

    Parses WxDxH in millimeters, returning None for malformed or non-positive dimensions.

    PrintablePart

    pub(all) struct PrintablePart {
    part_number : String
    component_name : String
    meta : PartMeta
    design :
    Design

    volume_mm3 : Double
    mass_kg : Double
    }

    A standalone fabricated/3D-printable part: its own design in its local datum frame, without purchased motors, fasteners, bearings, or PCBs.

    PrintablePart::bbox_label

    fn PrintablePart::bbox_label(self : PrintablePart) -> String

    WxDxH millimeter label with one decimal, or "" when the part has no bounding box.

    PrintablePart::bbox_mm

    fn PrintablePart::bbox_mm(self : PrintablePart) -> (Double, Double, Double)?

    Bounding-box dimensions (width, depth, height) in millimeters of the printable design, or None when it has no bodies.

    PrintablePart::est_mass_g

    fn PrintablePart::est_mass_g(self : PrintablePart, line : BomLine) -> Double

    Estimated printed mass in grams: solid mass scaled by the line's infill.

    PrintablePart::est_print_min

    fn PrintablePart::est_print_min(self : PrintablePart, line : BomLine) -> Double

    Rough print time in minutes; zero for non-print processes.

    PrintablePart::fits_bed

    fn PrintablePart::fits_bed(self : PrintablePart, bed : PrintBedSpec) -> Bool

    True when the part's bounding box fits within bed's usable width, depth, and height (no reorientation).

    RewardWeights

    pub(all) struct RewardWeights {
    forward_vel : Double
    target_height : Double
    upright : Double
    energy : Double
    smoothness : Double
    alive : Double
    } derive(Eq,
    Debug
    )

    Weighted reward terms. Negative weights penalize their quantity.

    RewardWeights::new

    fn RewardWeights::new(forward_vel? : Double, target_height? : Double, upright? : Double, energy? : Double, smoothness? : Double, alive? : Double) -> RewardWeights

    Builds reward weights; defaults are forward_vel/target_height/upright = 1.0, energy/smoothness = -0.01, and alive = 0.5.

    RlTaskKind

    pub(all) enum RlTaskKind {
    Balance
    WheeledLocomotion
    QuadrupedWalk
    JumpAndLevel
    Custom(String)
    } derive(Eq,
    Debug
    )

    The training objective a task targets.

    RlTaskKind::to_string

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

    Returns the identifier exported as kind in rl_task.json; a Custom payload is passed through unchanged.

    RlTaskSpec

    pub(all) struct RlTaskSpec {
    kind : RlTaskKind
    control_dt_s : Double
    episode_len_s : Double
    target_base_height_m : Double
    target_vel_x_mps : Double
    termination_tilt_deg : Double
    termination_min_z_m : Double
    imu_link : String
    wheel_links : Array[String]
    hip_joints : Array[String]
    wheel_joints : Array[String]
    action_scales : Map[String, Double]
    rewards : RewardWeights
    domain_rand : DomainRandSpec
    } derive(Eq,
    Debug
    )

    One robot's RL contract.

    RlTaskSpec::new

    fn RlTaskSpec::new(kind? : RlTaskKind, control_dt_s? : Double, episode_len_s? : Double, target_base_height_m? : Double, target_vel_x_mps? : Double, termination_tilt_deg? : Double, termination_min_z_m? : Double, imu_link? : String, wheel_links? : Array[String], hip_joints? : Array[String], wheel_joints? : Array[String], action_scales? : Map[String, Double], rewards? : RewardWeights, domain_rand? : DomainRandSpec) -> RlTaskSpec

    Builds an RL task spec with per-field keyword overrides. Defaults target a wheeled-locomotion task at 100 Hz with 10 s episodes and 0.30 m / 0.5 m/s targets; attach with with_rl_task before exporting.

    RobotAnalysis

    pub(all) struct RobotAnalysis {
    total_mass_kg : Double
    poses : Array[PoseAnalysis]
    warnings : Array[String]
    } derive(Eq,
    Debug
    )

    Statics across every requested pose.

    RouteLine

    pub(all) struct RouteLine {
    path : String
    route : CableRoute
    }

    One routed cable bundle in the harness report.

    SensorKind

    pub(all) enum SensorKind {
    LimitSwitch
    Encoder
    Imu
    Camera
    Force
    }

    The kind of sensor a component represents.

    SensorLine

    pub(all) struct SensorLine {
    path : String
    spec : SensorSpec
    }

    One sensor line in the power budget.

    SensorSpec

    pub(all) struct SensorSpec {
    kind : SensorKind
    model : String
    interface : String
    voltage_v : Double
    current_ma : Double
    range : String
    resolution : String
    }

    Electrical and measuring characteristics for one sensor.

    SensorSpec::new

    fn SensorSpec::new(kind : SensorKind, model? : String, interface? : String, voltage_v? : Double, current_ma? : Double, range? : String, resolution? : String) -> SensorSpec

    Creates a sensor spec; unspecified fields default to 0 / empty strings.
    pub(all) struct SupplierLink {
    part_number : String
    supplier : String
    supplier_url : String
    notes : String
    unit_cost_usd : Double?
    }

    A per-part purchasing override, typically loaded from an example's supplier-links.txt. Empty fields keep the component's existing value.

    SupplierLink::new

    fn SupplierLink::new(part_number~ : String, supplier? : String, supplier_url? : String, notes? : String, unit_cost_usd? : Double) -> SupplierLink

    Creates a supplier-link override; empty fields and missing costs are ignored when applied via Component::with_supplier_links.

    VisualMode

    pub(all) enum VisualMode {
    Primitives
    MeshPackage(String)
    }

    How a compiled link's visuals are represented.

    WireLine

    pub(all) struct WireLine {
    path : String
    run : WireRun
    }

    One wire line in the harness report.

    WireRun

    pub(all) struct WireRun {
    name : String
    from_component : String
    from_port : String
    to_component : String
    to_port : String
    gauge_awg : Int
    length_mm : Double
    notes : String
    }

    One point-to-point cable run.

    WireRun::new

    fn WireRun::new(name : String, from_component~ : String, from_port~ : String, to_component~ : String, to_port~ : String, gauge_awg? : Int, length_mm? : Double, notes? : String) -> WireRun

    Creates a point-to-point wire run; gauge_awg defaults to 24 and length_mm to 0.

    DEFAULT_ELEPHANT_FOOT_CHAMFER_MM

    let DEFAULT_ELEPHANT_FOOT_CHAMFER_MM : Double

    Default 45-degree bottom-face (z = 0) elephant-foot chamfer applied to printable STEP exports so FDM parts release cleanly without bottom-layer fusion.

    analyze_robot

    fn analyze_robot(component : Component, poses : Array[(String, Map[String, Double])]) -> RobotAnalysis

    Analyzes whole-robot statics at every requested pose: composite mass and CoM, static gravity torque at each revolute/continuous joint versus the URDF effort limit, safety margins, and wheel/foot ground-contact alignment.

    An empty poses array analyzes the poses declared with Component::with_analysis_poses, or the zero pose under the name "default" when none were declared.

    centered_cuboid_node

    fn centered_cuboid_node(sx_mm : Double, sy_mm : Double, sz_mm : Double, name? : String, color? :
    Rgb
    ) ->
    SceneNode

    Builds a cuboid whose geometric center is at the origin.

    centered_cylinder_node

    fn centered_cylinder_node(diameter_mm : Double, length_mm : Double, name? : String, color? :
    Rgb
    ) ->
    SceneNode

    Builds a cylinder whose geometric center is at the origin, axis along Z.

    centered_extruded_profile_node

    fn centered_extruded_profile_node(outer : Array[(Double, Double)], height_mm : Double, holes? : Array[Array[(Double, Double)]], name? : String, color? :
    Rgb
    ) ->
    SceneNode

    Builds an extruded profile whose geometric center is at the origin along Z.

    centered_tube_node

    fn centered_tube_node(outer_diam_mm : Double, inner_diam_mm : Double, length_mm : Double, name? : String, color? :
    Rgb
    ) ->
    SceneNode

    Builds a hollow tube whose geometric center is at the origin, axis along Z.

    The walls are exact cylindrical surfaces (four-quarter-arc loops), not a faceted polygon.

    detail_level_name

    fn detail_level_name(level :
    DetailLevel
    ) -> String

    The canonical CLI name of a detail level.

    detail_level_with_threads

    The detail level implied by a thread override, if any.

    A Helical thread request implies FullyModeled; the other modes keep the caller's detail level.

    explode_role_color

    fn explode_role_color(link_name : String, body_name : String) ->
    Rgb

    Deterministic role-based color for an exploded-view body.

    fea_load_cases_to_json

    fn fea_load_cases_to_json(cases : Array[FeaLoadCase]) -> String

    The complete fea/load-cases.json document: a schema tag and an ordered array of load cases.

    get_version

    fn get_version() -> String

    Returns the package version string (synced from moon.mod by the release tooling); used to stamp generated STEP/3MF files.

    gltf_safe_design

    Makes every node in a design safe for glTF tessellation.

    gltf_safe_node

    Makes a scene node safe for the glTF tessellator.

    Revolved profiles (bearing rings and balls, button and countersunk heads, chamfered shafts, socketed screws) become coaxial bounding cylinders or tubes, swept profiles (herringbone gears) become coaxial tubes or cylinders, imported STEP solids become coaxial cylinders or centered bounding boxes, and booleans are rebuilt from their converted children. Shapes that compile to planes, cylinders, and linear extrusions pass through unchanged, so the STEP output always keeps its exact analytic B-Rep.

    is_fabricated_part

    fn is_fabricated_part(meta : PartMeta) -> Bool

    Returns true when a part is fabricated in-house rather than purchased.

    makerpipe_accessory

    fn makerpipe_accessory(part : String, trade : String) -> Result[Component, String]

    makerpipe_accessory imports one Maker Pipe accessory.

    makerpipe_connector

    fn makerpipe_connector(part : String, size : String) -> Result[Component, String]

    makerpipe_connector imports one structural Maker Pipe connector.
    fn merge_supplier_links(defaults : Array[SupplierLink], overrides : Array[SupplierLink]) -> Array[SupplierLink]

    Merges shared supplier-link defaults with per-example overrides.

    An override wins for every non-empty field (and for a present cost); an empty field keeps the default. Overrides for part numbers missing from the defaults are appended, so examples can introduce example-specific parts.

    orient_print_design

    Orients a printable design on the print bed: apply the requested rotation, then translate so min_z == 0 and the XY bounding-box center is (0, 0).

    parse_detail_level

    fn parse_detail_level(text : String) ->
    DetailLevel
    ?

    Parses a detail-level option.

    Accepts "simplified", "detailed", "fully-modeled", "fully_modeled", and "full"; returns None for anything else.

    parse_double_list

    fn parse_double_list(text : String, count : Int, label : String) -> Result[Array[Double], String]

    Parses a comma-separated double list and extends it to count entries by repeating the last value.

    Returns Err for an empty list or a malformed number. label is the CLI option name without the leading -- (for example "module").

    parse_int_list

    fn parse_int_list(text : String, count : Int, label : String) -> Result[Array[Int], String]

    Parses a comma-separated integer list and extends it to count entries by repeating the last value.

    parse_string_list

    fn parse_string_list(text : String, count : Int, label : String) -> Result[Array[String], String]

    Parses a comma-separated string list and extends it to count entries by repeating the last value.
    fn parse_supplier_links(text : String) -> Array[SupplierLink]

    Parses a pipe-separated supplier-link file.

    Format: part_number | supplier | supplier_url | notes | unit_cost_usd. Blank lines and lines starting with # are ignored, as are lines with fewer than three fields. An unparsable cost becomes None.

    parse_thread_rep

    Parses a thread-representation option.

    Accepts "none", "cosmetic", and "helical"; returns None for anything else.

    pattern_grid_mm

    fn pattern_grid_mm(cols : Int, rows : Int, pitch_x_mm : Double, pitch_y_mm : Double, center_x? : Double, center_y? : Double) -> Array[(Double, Double)]

    Generates a cols × rows rectangular grid spaced by pitch_x_mm and pitch_y_mm, centered at (center_x, center_y).

    pattern_line_mm

    fn pattern_line_mm(count : Int, pitch_mm : Double, angle_deg? : Double, center_x? : Double, center_y? : Double) -> Array[(Double, Double)]

    Generates count evenly spaced (x, y) points along a line at angle_deg, spaced by pitch_mm and centered at (center_x, center_y).

    pattern_rect_mm

    fn pattern_rect_mm(width_mm : Double, height_mm : Double, center_x? : Double, center_y? : Double) -> Array[(Double, Double)]

    Generates a 4-corner rectangular pattern (width_mm × height_mm) centered at (center_x, center_y).

    pattern_ring_mm

    fn pattern_ring_mm(count : Int, diam_mm~ : Double, phase_deg? : Double, center_x? : Double, center_y? : Double) -> Array[(Double, Double)]

    Generates count evenly spaced (x, y) points on a circle of diameter diam_mm centered at (center_x, center_y) starting at phase_deg.

    rgb_to_rgba

    fn rgb_to_rgba(c :
    Rgb
    , a? : Double) ->
    Rgba

    Converts a CAD RGB color to a URDF RGBA color with an optional alpha.

    rgba_to_rgb

    Converts a URDF RGBA color to a CAD RGB color, dropping alpha.

    sanitize_part_number

    fn sanitize_part_number(part_number : String) -> String

    Makes a part number safe for use as a file name.

    step_component_layer_names

    fn step_component_layer_names(step_comp :
    Component
    ) -> Array[String]

    The names of a multi-layer STEP component's layers, in model order.

    step_to_urdf_matrix

    Converts a CAD rotation matrix to a URDF rotation matrix.

    step_to_urdf_transform

    Converts a CAD transform (millimeters) to a URDF transform (meters).

    thread_rep_name

    The canonical CLI name of a thread representation.

    transform_scene_node

    Applies a CAD transform (millimeters, degrees) to a scene node by composing it with the node's own placement and re-deriving translation and extrinsic Euler angles.

    transform_scene_node_urdf

    Applies a URDF transform (meters) to a scene node.

    urdf_to_step_matrix

    Converts a URDF rotation matrix (radians) to a CAD rotation matrix (degrees are only applied when a transform is converted; the matrix itself is identical).

    urdf_to_step_transform

    Converts a URDF transform (meters) to a CAD transform (millimeters).

    urdf_transform_from_mm_deg

    fn urdf_transform_from_mm_deg(x_mm? : Double, y_mm? : Double, z_mm? : Double, rx_deg? : Double, ry_deg? : Double, rz_deg? : Double) ->
    Transform

    Builds a URDF transform from a millimeter/degree origin.