newton.actuators.InputProcessorBase#

class newton.actuators.InputProcessorBase[source]#

Bases: object

Base class for actuator input processors.

An input processor transforms the inputs of an actuator before they reach the drive. The inputs are the simulation state the drive reads (positions, velocities) and the commands (target positions, target velocities, feedforward). An Actuator runs its processors in list order; each processor receives the inputs returned by the previous one.

Subclasses must override resolve_arguments() and process(). Stateful subclasses also override is_stateful(), state() and update_state().

class Inputs(positions, velocities, target_pos, target_vel, feedforward, pos_indices, vel_indices, target_pos_indices, target_vel_indices, sim_positions, sim_velocities)#

Bases: object

Actuator inputs passed through the processor chain.

Each actuator slot i reads positions[pos_indices[i]], velocities[vel_indices[i]], target_pos[target_pos_indices[i]], target_vel[target_vel_indices[i]] and feedforward[target_vel_indices[i]]. A processor that replaces a target array with one entry per slot also replaces its index array. A processor keeps vel_indices and the shape of velocities: drives also use those indices for joint_qd-shaped custom inputs. Actuator.step raises ValueError otherwise.

__init__(positions, velocities, target_pos, target_vel, feedforward, pos_indices, vel_indices, target_pos_indices, target_vel_indices, sim_positions, sim_velocities)#
feedforward: wp.array[wp.float32] | None#

Feedforward effort [N or N·m], or None.

pos_indices: wp.array[wp.uint32]#

Index of each slot into positions.

positions: wp.array[wp.float32]#

Positions read by the drive [m or rad].

sim_positions: wp.array[wp.float32]#

Unprocessed joint_q-shaped simulation positions [m or rad]. Index with joint_q indices to read another joint.

sim_velocities: wp.array[wp.float32]#

Unprocessed joint_qd-shaped simulation velocities [m/s or rad/s]. Index with joint_qd indices to read another joint.

target_pos: wp.array[wp.float32]#

Target positions [m or rad].

target_pos_indices: wp.array[wp.uint32]#

Index of each slot into target_pos.

target_vel: wp.array[wp.float32]#

Target velocities [m/s or rad/s].

target_vel_indices: wp.array[wp.uint32]#

Index of each slot into target_vel and feedforward.

vel_indices: wp.array[wp.uint32]#

Index of each slot into velocities.

velocities: wp.array[wp.float32]#

Velocities read by the drive [m/s or rad/s].

classmethod resolve_arguments(args)#

Resolve user-provided arguments with defaults.

Parameters:

args (dict[str, Any]) – User-provided arguments.

Returns:

Complete arguments with defaults filled in. Return integer parameters as int and real parameters as float: finalize() stores a parameter as an int32 array only when all its values are int.

Return type:

dict[str, Any]

finalize(device, num_actuators, requires_grad=False)#

Called by Actuator after construction.

Parameters:
  • device (Device) – Warp device to use.

  • num_actuators (int) – Number of actuators (DOFs).

  • requires_grad (bool) – Allocate output arrays with gradient support.

is_graphable()#

Return True if process() and update_state() can be captured in a CUDA graph.

is_stateful()#

Return True if this processor maintains internal state.

process(inputs, state, dt)#

Return the transformed actuator inputs.

Return a copy of inputs made with dataclasses.replace(); do not modify inputs in place. To read a joint other than the actuated one, index Inputs.sim_positions and Inputs.sim_velocities: earlier processors may have replaced Inputs.positions and Inputs.velocities.

Parameters:
  • inputs (Inputs) – Actuator inputs.

  • state (State | None) – Processor state (None if stateless).

  • dt (float | None) – Timestep [s].

Returns:

Transformed actuator inputs.

Return type:

Inputs

state(num_actuators, device)#

Create and return a new state object, or None if stateless.

update_state(inputs, current_state, next_state)#

Advance internal state after the actuator step.

Parameters:
  • inputs (Inputs) – The inputs this processor received in process().

  • current_state (State | None) – Current processor state.

  • next_state (State | None) – Next processor state to write.

JOINT_PARAMS: ClassVar[set[str]] = {}#

Names of parameters that reference a joint.

add_actuator() accepts a joint index or a joint label for each of these parameters, or None for the actuated joint. The joint must be a single-DOF joint of the same type as the actuated joint. It passes the joint to the constructor as two index arrays: <name>_indices into joint_qd-shaped arrays and <name>_pos_indices into joint_q-shaped arrays.

SHARED_PARAMS: ClassVar[set[str]] = {}#