newton.actuators.Delay#
- class newton.actuators.Delay(delay_steps, max_delay)[source]#
Bases:
objectPer-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 indelay_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.
- __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.
- 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-DOFnum_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 isNone, delayed_feedforward is all zeros.- Return type:
- state(num_actuators, device)#
Create a new delay state with zeroed circular buffers.
- 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,).