newton.sim.State#

class newton.sim.State[source]#

Bases: object

Time-varying state data for a Model.

Time-varying state data includes particle positions, velocities, rigid body states, and anything that is output from the solver as derived data, e.g.: forces.

The exact attributes depend on the contents of the model. State objects should generally be created using the newton.Model.state() function.

__init__()#
clear_forces()#

Clear all forces (for particles and bodies) in the state object.

property body_count: int#

The number of bodies represented in the state.

body_f: array | None#

Array of body forces in maximal coordinates (first three entries represent torque, last three entries represent linear force) with shape (body_count,) and type spatial_vector.

Note

body_f represents external wrenches in world frame and denotes wrenches measured w.r.t. to the body’s center of mass for all solvers except FeatherstoneSolver, which assumes the wrenches are measured w.r.t. world origin.

body_q: array | None#

Array of body coordinates (7-dof transforms) in maximal coordinates with shape (body_count,) and type transform.

body_qd: array | None#

Array of body velocities in maximal coordinates (first three entries represent angular velocity, last three entries represent linear velocity) with shape (body_count,) and type spatial_vector.

property joint_coord_count: int#

The number of generalized joint position coordinates represented in the state.

property joint_dof_count: int#

The number of generalized joint velocity coordinates represented in the state.

joint_q: array | None#

Array of generalized joint coordinates with shape (joint_coord_count,) and type float.

joint_qd: array | None#

Array of generalized joint velocities with shape (joint_dof_count,) and type float.

property particle_count: int#

The number of particles represented in the state.

particle_f: array | None#

Array of 3D particle forces with shape (particle_count,) and type vec3.

particle_q: array | None#

Array of 3D particle positions with shape (particle_count,) and type vec3.

particle_qd: array | None#

Array of 3D particle velocities with shape (particle_count,) and type vec3.

property requires_grad: bool#

Indicates whether the state arrays have gradient computation enabled.