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 array Body pose: position (3) + quaternion [qx, qy, qz, qw]; CPU is a view, CUDA is a host snapshot.
body_qd (num_bodies, 6) NumPy array Body velocity [vx, vy, vz, wx, wy, wz]; CPU is a view, CUDA is a host snapshot.
body_f (num_bodies, 6) NumPy array Body external wrench [fx, fy, fz, tx, ty, tz]; CPU is a view, CUDA is a host snapshot.
joint_q DeviceArray[float] Flat generalized joint coordinates.
joint_qd DeviceArray[float] Flat generalized joint velocities.
particle_q (num_particles, 3) NumPy array Particle positions; CPU is a view, CUDA is a host snapshot.
particle_qd (num_particles, 3) NumPy array Particle velocities; CPU is a view, CUDA is a host snapshot.
particle_f (num_particles, 3) NumPy array Particle force buffer; CPU is a view, CUDA is a host snapshot.
fluid_state ParticleState Fluid solver work state used by PBF-style paths.
transforms list[Transform] CPU states return writable references; CUDA states return a host snapshot. Editing this list does not synchronize body_q.
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 use [linear; angular] / [force; torque]. novaphy::SpatialVector and the public spatial-algebra helpers use the same linear-first component order. SimState::apply_articulation_force is an internal C++ helper and is not a Python method.

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.
set_transforms_numpy(positions, quaternions) Replace every pose while synchronizing transforms, body_q, and body_q_prev.
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