Pluggable parametric CAD and URDF robotics component library in MoonBit
./build-part.sh 02./view-md.sh README.md| Field | Purpose |
|---|---|
| parameters : Map[String, String] | Self-documenting design parameters ("module": "3.0"). |
| bodies : Array[BodyPart] | Rigid solids with CAD geometry, density, exact inertia, and collision primitives. |
| mates : Map[String, @urdf.MateConnector] | Named attachment frames other components snap onto. |
| attachments : Array[Attachment] | Child components plus the joint that connects them. |
| part : PartMeta? | Purchasing/manufacturing data (part number, supplier and URL, material, process, cost). |
| ports : Array[Port] | Typed electrical/mechanical interfaces (power, signal, bus, sensor). |
| fasteners : Array[Fastener] | Fastener schedule: thread, length, engagement, quantity, torque, references. |
| fits : Array[Fit] | Named fits with a nominal size and allowed min/max range. |
| actuator : ActuatorSpec? | Voltage, current, torque, driver, control interface, and encoder for a motor. |
| sensor : SensorSpec? | Kind, interface, supply, current draw, range, and resolution for a sensor. |
| pcb : PcbSpec? | Board outline, thickness, mounting holes, height limit, and connectors. |
| wiring : Array[WireRun] | Point-to-point cable runs with gauge, length, and endpoints. |
| control : Array[ControlBinding] | Joint → actuator/channel/pins, direction, gear ratio, soft limits, homing/limit inputs. |
| cables : Array[CableRoute] | Routed cable bundles: polyline, jacket diameter, carried wire runs, material. |
| Method | Result |
|---|---|
| comp.compile_links() | CompiledLinks, @urdf.Joints, and @urdf.Transmissions. |
| comp.to_robot() | Complete @urdf.Robot with combined inertials and diagnostics. |
| comp.to_urdf_bundle() | ROS 2 bundle: urdf/<robot>.urdf, package.xml, per-link .gltf meshes, and printable .step parts. |
| comp.to_design(joint_positions~) | Posed @step_cad.Design solved through forward_kinematics. |
| comp.to_step_file(), to_assembly_step(), to_gltf(), to_blender_python() | Posed exports in the requested format. |
./run-example.sh 01 --numStages 2 --headless
./run-example.sh 05-galileo-quadruped --bundle /tmp/galileo_bundle
./run-example.sh 06 --out scooter.step --urdf scooter.urdf| Example | Description |
|---|---|
| 01_motorized_wheel | Compact multi-stage planetary gearbox whose ring gears are the outer casing, with a 1/2" flanged-bearing planet set, a printed three-hole tire_mount, and a 40 mm output bolt circle, driving a purchased budrash 72-107 7-inch wheel. Stage parameters are comma-separated lists (--numStages 3 --numElbows 0,1,2). |
| 02-planetary-actuator | Measured Tier-1 BLDC outrunner (@step_motors.brushless_motor) driving a print-in-place, four-elbow, four-planet Tier-1 planetary gearbox — housed with a twin-bearing output cartridge and the moteus C1 on-axis AS5047P sensor, or exposed as a bench/viewing stage. |
| 05-galileo-quadruped | Wheeled quadruped with a V-slot chassis and four 4-DOF legs; every leg joint is a real low-KV BLDC planetary actuator driving the next printed link from its carrier output shaft. STEP, glTF, URDF, or full ROS 2 bundle. |
| 06-assistive-scooter | Motorized wheelchair with two-stage planetary rear drives whose wheels bolt to the actuator output shafts, a V-slot frame, seat, armrests, a reusable joystick pod, and front casters (or a steerable fork). Rear and caster tyre bottoms share the z = 0 ground plane. |
./run-example.sh 05 -- --bundle /tmp/galileo_bundle
python3 scripts/validate_urdf.py --check-meshes \
/tmp/galileo_bundle/urdf/galileo_quadruped.urdf./run-example.sh 05 --bom 05-bom.csv --plan 05-plan.txt./run-example.sh 05 --report 05-report.txt./run-example.sh 05 --control 05-control.yaml --pins 05-pins.csv| File | Contents |
|---|---|
| README.md | Manifest: part counts, cost, assembly steps, warnings, file list, validation commands. |
| bom.csv | Aggregated bill of materials. |
| sourcing.csv | Suppliers, supplier links, quantities, and cost roll-up. |
| print-list.csv | Fabricated parts with orientation, layer height, infill, supports, and process notes. |
| fasteners.csv | Fastener schedule and torque table. |
| assembly.txt | Ordered steps, torque table, electrical checkout, and test sequence. |
| report.txt | Power, IO, and wiring budget. |
| control.yaml, pins.csv | ros2_control configuration and firmware pin map. |
| pcb-connectors.csv | Imported PCB connector placements (reference, value, footprint, position, side). |
| link-parts.csv | Link-to-part map used by the drawing generator. |
| firmware.h | C header: joint bindings, gear ratios, limits, pins, and sensors. |
| assembly.step | Posed assembly STEP. |
| bundle/ | URDF, package.xml, glTF meshes, and per-link STEP parts. |
./run-example.sh 05 --package build/05 --check
python3 scripts/validate_step.py --no-mesh build/05/assembly.step
python3 scripts/validate_urdf.py --check-meshes build/05/bundle/urdf/*.urdfpython3 scripts/make_drawings.py build/05
# drawings/index.md, <link>.svg, <link>.pdf,
# drawings/dxf/<link>-{front,top,right,iso}.dxf./test-all.sh./run-example.sh 05 --headless --validate # STEP + URDF checks
./run-example.sh 05 --headless --bundle build/05 --validate --validate-meshes
python3 scripts/validate_step.py --no-mesh model.step
python3 scripts/validate_urdf.py --check-meshes model.urdf
python3 scripts/check_interferences.py --parts-dir posed/ # exact OCCT link interference
./run-example.sh 05 --headless --detail detailed --posed-parts posed/05
python3 scripts/render_step.py model.step preview.png # OCCT + Inkscape
python3 scripts/render_solidcraft.py model.step preview-shaded.png # SolidCraft + Inkscape
python3 scripts/make_drawings.py build/05 # SolidCraft (+ Inkscape for PDF)
python3 scripts/validate_control.py control.yaml robot.urdf --pins pins.csv # PyYAMLpub(all) enum ActuatorKind {
Stepper
Bldc
Servo
Hub
}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
}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) -> ActuatorSpecfn AssemblyStep::new(sequence : Int, title : String, component~ : String, joint? : String?, fasteners? : Array[String], tools? : Array[String], notes? : String) -> AssemblySteppub(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
}pub(all) struct BuildFile {
path : String
content : String
}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) -> CableRoutepub(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]
}fn Component::collision_checks(self : Component, joint_positions? : Map[String, Double], tol? : TolerancePolicy, policy? : ContactPolicy) -> Array[String]fn Component::collision_report_text(self : Component, joint_positions? : Map[String, Double], tol? : TolerancePolicy, policy? : ContactPolicy) -> Stringfn Component::collision_reports(self : Component, joint_positions? : Map[String, Double], tol? : TolerancePolicy, policy? : ContactPolicy) -> Array[CollisionReport]fn Component::compile_links(self : Component, package_name? : String?) -> (Array[CompiledLink], Array[Joint], Array[Transmission])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) -> Componentfn Component::placed_shapes(self : Component, joint_positions? : Map[String, Double]) -> Array[PlacedShape]fn Component::to_urdf_bundle(self : Component, package_name? : String, include_step_parts? : Bool) -> UrdfBundlepub(all) enum ConnectionKind {
MergeRigid
Fixed
Revolute(JointLimit)
Continuous(JointLimit?)
Prismatic(JointLimit)
} derive(Debug)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?
}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?) -> ControlBindingpub(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?
}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?) -> Fastenerpub(all) enum FastenerKind {
Bolt
Screw
Nut
Washer
Insert
}pub(all) struct Fit {
name : String
fit_class : FitClass
nominal_mm : Double
min_mm : Double
max_mm : Double
}pub(all) enum FitClass {
Nominal
Clearance
Transition
Interference
}pub(all) struct JointSpec {
kind : ConnectionKind
pair : MatePair
dynamics : JointDynamics?
mimic : JointMimic?
transmission_reduction : Double?
} derive(Debug)fn JointSpec::continuous(limit? : JointLimit?, offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? : JointDynamics?, mimic? : JointMimic?, transmission_reduction? : Double?) -> JointSpecfn JointSpec::prismatic(limit : JointLimit, offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? : JointDynamics?, mimic? : JointMimic?, transmission_reduction? : Double?) -> JointSpecfn JointSpec::revolute(limit : JointLimit, offset_mm? : Double, angle_deg? : Double, flip_axis? : Bool, dynamics? : JointDynamics?, mimic? : JointMimic?, transmission_reduction? : Double?) -> JointSpecpub(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
}pub(all) struct PcbPlacement {
reference : String
value : String
footprint : String
x_mm : Double
y_mm : Double
rotation_deg : Double
side : String
}fn PcbPlacement::new(reference? : String, value? : String, footprint? : String, x_mm? : Double, y_mm? : Double, rotation_deg? : Double, side? : String) -> PcbPlacementpub(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]
}pub(all) enum PortKind {
Mechanical
Power
Signal
Bus
Fluid
Sensor
Ground
}pub(all) struct PortLine {
path : String
name : String
kind : String
spec : String
}pub(all) struct PowerBudget {
actuators : Array[ActuatorLine]
sensors : Array[SensorLine]
ports : Array[PortLine]
wires : Array[WireLine]
routes : Array[RouteLine]
}pub(all) enum SensorKind {
LimitSwitch
Encoder
Imu
Camera
Force
}pub(all) struct SensorSpec {
kind : SensorKind
model : String
interface : String
voltage_v : Double
current_ma : Double
range : String
resolution : String
}fn SensorSpec::new(kind : SensorKind, model? : String, interface? : String, voltage_v? : Double, current_ma? : Double, range? : String, resolution? : String) -> SensorSpecpub(all) struct SupplierLink {
part_number : String
supplier : String
supplier_url : String
notes : String
unit_cost_usd : Double?
}fn SupplierLink::new(part_number~ : String, supplier? : String, supplier_url? : String, notes? : String, unit_cost_usd? : Double) -> SupplierLinkpub(all) enum VisualMode {
Primitives
MeshPackage(String)
}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
}fn sanitize_part_number(part_number : String) -> StringInstall
Download zipPluggable parametric CAD and URDF robotics component library in MoonBit