newton.State#

class newton.State#

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.

Methods

__init__()

clear_forces()

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

Attributes

body_count

The number of bodies represented in the state.

joint_coord_count

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

joint_dof_count

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

particle_count

The number of particles represented in the state.

requires_grad

Indicates whether the state arrays have gradient computation enabled.

particle_q

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

particle_qd

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

particle_f

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

body_q

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

body_qd

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.

body_f

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.

joint_q

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

joint_qd

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

__init__()#
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.

particle_f: array | None#

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

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.

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.

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.

clear_forces()#

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

property requires_grad: bool#

Indicates whether the state arrays have gradient computation enabled.

property body_count: int#

The number of bodies represented in the state.

property particle_count: int#

The number of particles represented in the state.

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.