newton.actuators.Delay#

class newton.actuators.Delay(delay_steps, max_delay)[source]#

Bases: object

Per-DOF command input delay for actuators.

Delays command inputs (control targets and feedforward terms) using a circular buffer of depth max_delay. Each DOF has its own lag stored in delay_steps (shape (N,)). The buffer is sized for the maximum lag across all DOFs so that DOFs with different delay steps can share the same actuator group.

The delay always produces output. When the buffer is empty (e.g. right after reset) or a DOF has delay_steps == 0, the current command inputs are used directly. When underfilled, the lag is clamped to the available history so the oldest available entry is returned.

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]

__init__(delay_steps, max_delay)#

Initialize delay.

Parameters:
  • delay_steps (wp.array(dtype=wp.int32, ndim=1)) – Per-DOF delay values [actuator timesteps], shape (N,).

  • max_delay (int) – Maximum delay across all DOFs. Determines the circular-buffer depth.

Raises:

ValueError – If max_delay < 1.

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.

get_delayed_targets(target_pos, target_vel, feedforward, pos_indices, vel_indices, current_state)#

Read per-DOF delayed command inputs from the circular buffer.

Each DOF reads from its own lag offset stored in delay_steps, clamped to available history (per-DOF num_pushes). When the buffer is empty, falls back to the current command inputs; when underfilled, the lag is clamped to the oldest available entry.

Parameters:
  • target_pos (wp.array[float]) – Current target positions [m or rad].

  • target_vel (wp.array[float]) – Current target velocities [m/s or rad/s].

  • feedforward (wp.array[float] | None) – Feedforward control input [N or N·m] (may be None).

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

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

  • current_state (Delay.State) – Delay state to read from.

Returns:

(delayed_pos, delayed_vel, delayed_feedforward). When feedforward is None, delayed_feedforward is all zeros.

Return type:

tuple[wp.array[float], wp.array[float], wp.array[float]]

state(num_actuators, device)#

Create a new delay state with zeroed circular buffers.

Parameters:
  • num_actuators (int) – Number of actuators (buffer width N).

  • device (Device) – Warp device for buffer allocation.

Returns:

Freshly allocated Delay.State.

Return type:

State

update_state(target_pos, target_vel, feedforward, pos_indices, vel_indices, current_state, next_state)#

Write current command inputs into the buffer and advance the write pointer.

Parameters:
  • target_pos (wp.array[float]) – Current target positions [m or rad].

  • target_vel (wp.array[float]) – Current target velocities [m/s or rad/s].

  • feedforward (wp.array[float] | None) – Current feedforward input [N or N·m] (may be None).

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

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

  • current_state (Delay.State) – Delay state to read from.

  • next_state (Delay.State) – Delay state to write into.

buf_depth#

Circular-buffer depth (equals max_delay).

delay_steps#

Per-DOF delay values [actuator timesteps], shape (N,).