newton.actuators.InputProcessorEncoder#

class newton.actuators.InputProcessorEncoder(output_joint_indices, *, output_joint_pos_indices=None)[source]#

Bases: InputProcessorBase

Position encoder of the actuator.

Models the sensor that provides the position the drive reads, including effects of how the encoder is mounted and how it measures. Supported effects:

  • Output-side mounting (output_joint): the encoder measures after a passive joint between the actuated joint and the link, e.g. to model gearbox backlash, so it reads

    \[q = q_{\text{actuated}} + q_{\text{output}}\]

    This captures gearbox backlash when the output joint has a small motion range: the solver handles the dead zone, where the actuator effort does not reach the link.

The encoder does not change the velocity: it stays that of the actuated joint, which is motor physics, e.g. the back-EMF of MotorDC.

The measured position is written into one entry per actuator slot, and pos_indices is replaced by the slot indices. Both buffers are allocated in finalize(), so the processor can be captured in a CUDA graph.

classmethod resolve_arguments(args)#

Resolve user-provided arguments.

Parameters:

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

Returns:

{"output_joint": ...}.

Return type:

dict[str, Any]

__init__(output_joint_indices, *, output_joint_pos_indices=None)#

Initialize the encoder.

Parameters:
  • output_joint_indices (wp.array[wp.uint32]) – Per-actuator index of the output joint into joint_qd-shaped arrays, shape (N,).

  • output_joint_pos_indices (wp.array[wp.uint32] | None) – Per-actuator index of the output joint into joint_q-shaped arrays, shape (N,). Defaults to output_joint_indices.

finalize(device, num_actuators, requires_grad=False)#
process(inputs, state, dt)#
JOINT_PARAMS: ClassVar[set[str]] = {'output_joint'}#

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.

output_joint_indices#

Output joint indices into joint_qd-shaped arrays, shape (N,).

output_joint_pos_indices#

Output joint indices into joint_q-shaped arrays, shape (N,).