Skip to main content

Crate mjcf_rs

Crate mjcf_rs 

Source
Expand description

§MJCF parser

Pure-Rust parser for the MuJoCo XML (MJCF) format.

§Disclaimer

Most of this crate — source, tests, and documentation — was produced by an AI coding assistant working iteratively from MJCF reference scenes (primarily the MuJoCo Menagerie), under human direction and review.

§Quick start

use mjcf_rs::Model;
let model = Model::from_file("robot.xml").unwrap();
println!("{} bodies", model.bodies_iter().count());

§What this crate does

  • Reads MJCF XML and produces a typed AST.
  • Resolves <include file="…"/> recursively (with cycle detection).
  • Resolves <default> class inheritance — every concrete element has its final attributes baked in.
  • Normalizes angle units to radians (<compiler angle="degree"> is the MJCF default).
  • Records <compiler eulerseq> so the conversion side can apply Euler triples in the correct order.

§What this crate does not do

  • Simulate anything. Pair this with rapier3d-mjcf for that.
  • Cover MJCF features that are out of scope for rapier3d-mjcf. See the rapier3d-mjcf README for the complete list.

Re-exports§

pub use glamx::glam;
pub use model::*;
pub use types::*;

Modules§

assets
<asset> library: meshes, hfields, textures, materials.
body
<worldbody>, <body>, <inertial>, <joint>, <freejoint>, <geom>, <site> AST types.
compiler
<compiler> and <option> representations.
contact
<contact> element AST.
equality
<equality> element AST.
extras
Pass-through types: <actuator>, <sensor>, <keyframe>.
model
Top-level Model AST.
normals
Smooth, crease-aware per-vertex normal generation for visual meshes.
tendon
<tendon> element AST. Only fixed tendons are represented — a fixed tendon is a linear combination of joint coordinates, L = Σ coefᵢ·qᵢ, used for actuator transmission and (via <equality><tendon>) length coupling. Spatial tendons (site-routed cables with wrapping) are out of scope.
types
Common AST types shared across modules.

Structs§

Pose
A pose: a 3D rigid-body transform (rotation + translation), backed by glamx::DPose3. MJCF’s several rotation specifications (quat, axisangle, euler, xyaxes, zaxis) are all collapsed into the quaternion stored here by the loader. A 3D pose (rotation + translation), representing a rigid body transformation (f64 precision).

Enums§

ParseError
Errors that can be returned while parsing an MJCF document.