phyz-rigid 0.4.0

Featherstone articulated rigid body dynamics for phyz
Documentation
  • Coverage
  • 100%
    69 out of 69 items documented1 out of 36 items with examples
  • Size
  • Source code size: 117.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 930.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 29s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ecto/phyz
    27 3 6
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ecto

phyz-rigid

Featherstone articulated rigid-body dynamics for phyz.

The classical O(n) algorithms, operating on phyz-model's Model and State.

Function Computes Cost
aba forward dynamics qdd = f(q, v, τ) O(n)
aba_with_external_forces forward dynamics with per-body wrenches O(n)
rnea inverse dynamics τ = f(q, v, qdd) O(n)
crba joint-space mass matrix M(q) O(n²)
forward_kinematics body transforms into state.body_xform O(n)
kinetic_energy, potential_energy, total_energy conserved quantities O(n)

Example

use phyz_math::{GRAVITY, Mat3, SpatialInertia, SpatialTransform, Vec3};
use phyz_model::ModelBuilder;
use phyz_rigid::{aba, total_energy};

let model = ModelBuilder::new()
    .gravity(Vec3::new(0.0, -GRAVITY, 0.0))
    .dt(0.002)
    .add_revolute_body(
        "pendulum",
        -1,
        SpatialTransform::identity(),
        SpatialInertia::new(
            1.0,
            Vec3::new(0.0, -0.5, 0.0),
            Mat3::from_diagonal(&Vec3::new(0.083, 0.0, 0.083)),
        ),
    )
    .build();

let mut state = model.default_state();
state.q[0] = 0.3;

// Semi-implicit Euler: this crate provides the dynamics, you write the loop.
for _ in 0..500 {
    let qdd = aba(&model, &state);
    for k in 0..model.nv {
        state.v[k] += model.dt * qdd[k];
    }
    for k in 0..model.nq {
        state.q[k] += model.dt * state.v[k];
    }
}

let e = total_energy(&model, &state);

This crate provides the dynamics, not the time loop — the example above writes its own integrator. If you want a ready-made stepper, phyz::sim has Simulator with semi-implicit Euler and RK4 solvers, and phyz-guardian adds adaptive time-stepping and conservation monitoring on top of these primitives.

Part of phyz

phyz is an open-source differentiable multi-physics simulation workspace in pure Rust. Each crate is independent — adding this one does not pull in the rest.

Licensed under MIT.