newton.actuators.InputProcessorBase#
- class newton.actuators.InputProcessorBase[source]#
Bases:
objectBase 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
Actuatorruns its processors in list order; each processor receives the inputs returned by the previous one.Subclasses must override
resolve_arguments()andprocess(). Stateful subclasses also overrideis_stateful(),state()andupdate_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:
objectActuator inputs passed through the processor chain.
Each actuator slot
ireadspositions[pos_indices[i]],velocities[vel_indices[i]],target_pos[target_pos_indices[i]],target_vel[target_vel_indices[i]]andfeedforward[target_vel_indices[i]]. A processor that replaces a target array with one entry per slot also replaces its index array. A processor keepsvel_indicesand the shape ofvelocities: drives also use those indices forjoint_qd-shaped custom inputs.Actuator.stepraisesValueErrorotherwise.- __init__(positions, velocities, target_pos, target_vel, feedforward, pos_indices, vel_indices, target_pos_indices, target_vel_indices, sim_positions, sim_velocities)#
- 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 withjoint_qindices to read another joint.
- sim_velocities: wp.array[wp.float32]#
Unprocessed
joint_qd-shaped simulation velocities [m/s or rad/s]. Index withjoint_qdindices 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_velandfeedforward.
- 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.
- is_graphable()#
Return True if
process()andupdate_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, indexInputs.sim_positionsandInputs.sim_velocities: earlier processors may have replacedInputs.positionsandInputs.velocities.
- 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.
- 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, orNonefor 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>_indicesintojoint_qd-shaped arrays and<name>_pos_indicesintojoint_q-shaped arrays.