STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.control.robust_ddp.actuation Namespace Reference

Classes

class  ExecutionBackend
class  ActuationCommand

Functions

ActuationCommand compute_actuation (np.ndarray u_relaxed, ControllerState state, ControllerConfig cfg, Optional[float] dt=None, ExecutionBackend backend=ExecutionBackend.PWM, Optional[np.ndarray] u_prev_relaxed=None, Optional[dict[str, float]] sigma_delta_state=None)
float quantize_duty (float u, float duty_quantization)
tuple[float, float] enforce_dwell (float u_new, float u_prev, float dwell_timer, float dwell_time, float dt)
tuple[float, bool] binary_actuation (float duty_desired, float dt, ControllerConfig cfg, Optional[float] sigma_delta_state=None)
None update_state_dwell_timers (ControllerState state, ActuationCommand cmd)
np.ndarray create_duty_grid (float duty_quantization)

Detailed Description

Actuation command generation for robust DDP controller.

Converts relaxed controls u~ in [0,1] to actual actuation commands:
- Quantized duty levels
- Dwell time enforcement
- PWM or binary execution backends

Function Documentation

◆ binary_actuation()

tuple[float, bool] engine.control.robust_ddp.actuation.binary_actuation ( float duty_desired,
float dt,
ControllerConfig cfg,
Optional[float] sigma_delta_state = None )
Generate binary actuation command using sigma-delta modulation.

Sigma-delta modulation provides average duty matching without high-frequency chatter.

Parameters:
-----------
duty_desired : float
    Desired duty cycle [0, 1]
dt : float
    Time step [s]
cfg : ControllerConfig
    Controller configuration
sigma_delta_state : float, optional
    Internal sigma-delta state (accumulator)
    If None, uses threshold method instead

Returns:
--------
duty_output : float
    Output duty (0 or 1 for binary)
onoff : bool
    Binary on/off command

Definition at line 228 of file actuation.py.

Referenced by compute_actuation().

◆ compute_actuation()

ActuationCommand engine.control.robust_ddp.actuation.compute_actuation ( np.ndarray u_relaxed,
ControllerState state,
ControllerConfig cfg,
Optional[float] dt = None,
ExecutionBackend backend = ExecutionBackend.PWM,
Optional[np.ndarray] u_prev_relaxed = None,
Optional[dict[str, float]] sigma_delta_state = None )
Convert relaxed controls to actuation commands.

Parameters:
-----------
u_relaxed : np.ndarray, shape (N_CONTROL,)
    Relaxed control vector [u_F, u_O] in [0, 1]
state : ControllerState
    Controller state (for dwell timers)
cfg : ControllerConfig
    Controller configuration
dt : float, optional
    Time step [s] (defaults to cfg.dt)
backend : ExecutionBackend
    Execution backend (PWM or BINARY)
u_prev_relaxed : np.ndarray, optional, shape (N_CONTROL,)
    Previous relaxed control (for dwell enforcement)
    If None, uses state.u_prev

Returns:
--------
cmd : ActuationCommand
    Actuation command with duty cycles and on/off states

Definition at line 49 of file actuation.py.

References binary_actuation(), enforce_dwell(), and quantize_duty().

◆ create_duty_grid()

np.ndarray engine.control.robust_ddp.actuation.create_duty_grid ( float duty_quantization)
Create duty cycle grid.

Parameters:
-----------
duty_quantization : float
    Duty quantization step

Returns:
--------
grid : np.ndarray
    Duty grid: [0, step, 2*step, ..., 1.0]

Definition at line 308 of file actuation.py.

◆ enforce_dwell()

tuple[float, float] engine.control.robust_ddp.actuation.enforce_dwell ( float u_new,
float u_prev,
float dwell_timer,
float dwell_time,
float dt )
Enforce minimum dwell time between control changes.

If control changed, reset timer. If timer < dwell_time, keep previous control.

Parameters:
-----------
u_new : float
    New control value
u_prev : float
    Previous control value
dwell_timer : float
    Current dwell timer [s]
dwell_time : float
    Minimum dwell time [s]
dt : float
    Time step [s]

Returns:
--------
u_output : float
    Output control (may be u_prev if dwell not satisfied)
dwell_timer_new : float
    Updated dwell timer [s]

Definition at line 178 of file actuation.py.

Referenced by compute_actuation().

◆ quantize_duty()

float engine.control.robust_ddp.actuation.quantize_duty ( float u,
float duty_quantization )
Quantize control to duty grid.

Parameters:
-----------
u : float
    Control value in [0, 1]
duty_quantization : float
    Duty quantization step (e.g., 0.01 for 1% steps)

Returns:
--------
u_quantized : float
    Quantized control value

Definition at line 149 of file actuation.py.

Referenced by compute_actuation().

◆ update_state_dwell_timers()

None engine.control.robust_ddp.actuation.update_state_dwell_timers ( ControllerState state,
ActuationCommand cmd )
Update dwell timers in controller state.

Parameters:
-----------
state : ControllerState
    Controller state to update (mutated)
cmd : ActuationCommand
    Actuation command with updated dwell timers

Definition at line 286 of file actuation.py.