Skip to content

novaphy.SimState

Caller-owned runtime state buffer. Allocate via model.state() and pass to solver.step(state_in, state_out, control, contacts, dt).

state = model.state()
state_a = model.state()
state_b = model.state()

Channels

Channel Type Description
body_q (num_bodies, 7) NumPy view Body pose: position (3) + quaternion [qx, qy, qz, qw].
body_qd (num_bodies, 6) NumPy view Body velocity in Python flat order [vx, vy, vz, wx, wy, wz].
body_f (num_bodies, 6) NumPy view Body external wrench in Python flat order [fx, fy, fz, tx, ty, tz].
joint_q DeviceArray[float] Flat generalized joint coordinates.
joint_qd DeviceArray[float] Flat generalized joint velocities.
particle_q (num_particles, 3) NumPy view Particle positions.
particle_qd (num_particles, 3) NumPy view Particle velocities.
particle_f (num_particles, 3) NumPy view Particle force buffer.
fluid_state ParticleState Fluid solver work state used by PBF-style paths.
transforms list[Transform] CPU-only writable references to body transforms.
linear_velocities, angular_velocities DeviceArray[Vec3] Component velocity arrays kept in sync by state helpers and solvers.
forces, torques DeviceArray[Vec3] Component external force / torque arrays.
body_parent_f, body_qdd optional DeviceArray Optional Newton-style state attributes; None unless requested on the model.

body_qd and body_f intentionally use [linear; angular] / [force; torque] Python order. Featherstone spatial algebra helpers use [angular; linear]; apply_articulation_force converts that convention into body_f.

Methods

Method Purpose
clear_forces() Zero body and particle force buffers.
assign(other) Copy all array attributes from another compatible state.
clone() -> SimState Deep copy.
from_model(model, device=None) -> SimState (static) Allocate a state matching a Model.
set_linear_velocity(body_index, vec) Set a body's linear velocity.
set_angular_velocity(body_index, vec) Set a body's angular velocity.
apply_force(body_index, vec) Add a world-space force at a body center of mass.
apply_torque(body_index, vec) Add a world-space torque on a body.
sync_particle_flat_from_fluid_state() Copy the fluid work state into particle_q / particle_qd.
sync_fluid_state_from_particle_flat() Copy particle_q / particle_qd into the fluid work state.
get_transforms_numpy() Return (positions, quaternions) arrays.
get_transforms_into(out_positions, out_quats) Fill preallocated transform arrays in-place.

Aliasing in solver.step

state_in and state_out may alias for in-place stepping:

solver.step(state, state, control, contacts, dt)

solver.step(state_a, state_b, control, contacts, dt)
state_a, state_b = state_b, state_a

See Also