newton.actuators.ClampingBase#

class newton.actuators.ClampingBase[source]#

Bases: object

Base class for actuator output effort clamping.

Clamping stages are stacked on top of a drive 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]

bind_params(block)#

Fill block with this clamp’s parameters and wire attributes to it.

block is this clamp’s (N, param_width()) slice of the effort mode’s packed array. Re-pointing the user-facing arrays (e.g. clamp.max_effort) at its columns keeps later writes visible to the solve kernel.

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 drive 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.

param_width()#

Columns this clamp occupies in the packed parameter array.

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