newton.actuators.Clamping#

class newton.actuators.Clamping[source]#

Bases: object

Base class for actuator output effort clamping.

Clamping objects are stacked on top of a controller to constrain actuator output effort — symmetric limits, velocity-dependent saturation, position-dependent curves, etc. They read from a source effort buffer and write bounded values to a destination buffer.

Validation contract: resolve_arguments() validates scalar parameter values before they are batched into Warp arrays. __init__ receives pre-built arrays and validates shapes only — reading back array contents would force a synchronous device-to-host copy on every construction.

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 type:

dict[str, Any]

finalize(device, num_actuators)#

Called by Actuator after construction to set up device-specific resources.

Override in subclasses that need to move arrays to a specific device.

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

  • num_actuators (int) – Number of actuators (DOFs) this clamping manages.

modify_forces(src_forces, dst_forces, positions, velocities, pos_indices, vel_indices, device=None)#

Read effort from src, apply clamping, write to dst.

When src and dst are the same array, this is an in-place update. The Actuator uses different arrays for the first clamping (to preserve the raw controller output) and the same array for subsequent clampings.

Parameters:
  • src_forces (wp.array[wp.float32]) – Input effort buffer [N or N·m] to read. Shape (N,).

  • dst_forces (wp.array[wp.float32]) – Output effort buffer [N or N·m] to write. Shape (N,).

  • positions (wp.array[wp.float32]) – Joint positions [m or rad].

  • velocities (wp.array[wp.float32]) – Joint velocities [m/s or rad/s].

  • pos_indices (wp.array[wp.uint32]) – Indices into positions for each DOF.

  • vel_indices (wp.array[wp.uint32]) – Indices into velocities for each DOF.

  • device (Device | None) – Warp device for kernel launches.

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