Skip to main content

Crate phyz

Crate phyz 

Source
Expand description

phyz — Multi-physics differentiable simulation engine.

This crate is a thin umbrella over the rigid-body stack: every type and function below lives in one of the focused phyz-* crates and is re-exported here, so cargo add phyz gives you that stack behind a single dependency. The re-exported modules are aliases, not copies, so a fix in phyz-collision is a fix for phyz::collision by construction. sim is the one module with code of its own: the time loop, which none of the focused crates own.

It does not cover the whole workspace. phyz-gpu, phyz-particle, phyz-lbm, phyz-em, phyz-md and the rest are separate crates you add explicitly.

§Features

  • collision (default) — GJK/EPA narrow phase and broad-phase spatial hashing.
  • contact (default) — soft/penalty contact dynamics; implies collision.
  • diff (default) — per-step Jacobians and the trajectory adjoint. Only the adjoint (diff::adjoint_rollout_gradient) and the symbolic path are derivative-exact; see phyz_diff for which is which.

math, model, and rigid are always present.

Re-exports§

pub use sim::Rk4Solver;
pub use sim::SemiImplicitEulerSolver;
pub use sim::Simulator;
pub use sim::Solver;
pub use phyz_math;
pub use phyz_model;
pub use phyz_rigid;
pub use phyz_math as math;
pub use phyz_model as model;
pub use phyz_rigid as rigid;
pub use phyz_collision;
pub use phyz_collision as collision;
pub use phyz_contact;
pub use phyz_contact as contact;
pub use phyz_diff;

Modules§

aba
Articulated Body Algorithm (ABA) – O(n) forward dynamics.
crba
Composite Rigid Body Algorithm (CRBA) – mass matrix computation.
determinism
Tools for checking that a rollout reproduces, and for telling chaos from bugs when it does not.
diff
Differentiation: Jacobians of the dynamics and the trajectory adjoint.
rnea
Recursive Newton-Euler Algorithm (RNEA) — inverse dynamics.
sim
Integrated time stepping: the Simulator driver and its solvers.

Structs§

AABB
Axis-aligned bounding box.
Actuator
An actuator attached to a joint.
Body
A rigid body in the kinematic tree.
BodyKinematics
Body transforms, velocities, and accelerations from a full kinematics pass.
Collision
Result of a collision query between two geometries.
ContactMaterial
Material properties for contact interactions.
ContactProblem
The assembled convex contact problem.
ContactSolverConfig
Tuning for the contact solve.
GeomInstance
A geometry placed at an offset within a body frame.
IkConfig
Solver settings. IkConfig::default is tuned for robot-arm-sized problems: metres and radians, goals within reach, a seed that is not exactly at a singularity.
IkGoal
A single kinematic goal.
IkSolution
What solve_ik found.
Joint
A joint connecting two bodies.
Model
Static model describing the topology and parameters of a physical system.
ModelBuilder
Builder for constructing models.
Ray
A ray with a normalized direction.
RayHit
A ray/shape intersection.
State
Mutable simulation state.

Enums§

Geometry
Collision geometry types (mirrors phyz-collision’s shapes for convenience).
IkGoalKind
The two things a goal can ask for.
JointType
Joint type enumeration.

Constants§

GRAVITY

Functions§

aba
Run the Articulated Body Algorithm.
aba_with_external_forces
Run ABA with optional external spatial forces applied to each body.
body_wrenches
Net spatial wrench transmitted through each body’s joint.
crba
Compute the joint-space mass matrix M(q) using CRBA.
epa_penetration
Compute penetration depth and contact normal using EPA.
epa_penetration_rot
EPA with rotation matrices. Runs GJK to obtain a valid seed simplex.
find_contacts
Find all body-body contacts in the current state.
find_ground_contacts
Find contacts against a horizontal ground plane at z = ground_height.
forward_kinematics
Compute forward kinematics: body transforms and spatial velocities.
forward_kinematics_acc
Forward kinematics extended with accelerations, for a given qdd.
gjk_distance
Compute signed distance between two geometries.
gjk_distance_rot
Signed distance with rotation matrices: +separation when disjoint, -depth when overlapping.
ray_cast
Cast a ray against many placed geometries, returning the nearest hit within max_distance along with the index of the geometry that was hit.
ray_intersect
Intersect a ray with a geometry placed at pos with orientation rot.
rnea
Run RNEA: compute inverse dynamics torques.
skew
Cross-product matrix [v]× such that [v]× w = v × w
solve_contacts
Solve the convex contact problem from a cold start (zero impulses).
solve_ik
Solve for a configuration satisfying goals, starting from seed.
sweep_and_prune
Sweep-and-prune broad phase collision detection.

Type Aliases§

DMat
Dynamic matrix.
DVec
Dynamic vector.
Mat3
3x3 matrix alias.
Mat4
4x4 matrix alias.
Quat
Unit quaternion for 3D rotations (scalar w, vector v).
SpatialInertia
Spatial inertia of a rigid body about its center of mass.
SpatialMat
6x6 spatial matrix stored as four 3x3 blocks.
SpatialTransform
Plucker transform: rigid body transformation acting on spatial vectors.
SpatialVec
6D spatial vector – either a motion vector (twist) or force vector (wrench).
Vec3
3D vector alias.