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

Classes

class  ControllerInitRequest
class  MeasurementRequest
class  NavStateRequest
class  CommandRequest
class  ControllerStepRequest
class  ControllerSimulateRequest
class  Layer2ControllerSimulateRequest
class  Layer2ConfigSimulateRequest

Functions

tuple _engine_config_roots (UserSession session)
Path _confined_yaml (str path, *Path roots, Path base=_PROJECT_ROOT)
RobustDDPController _fresh_controller (UserSession session, cfg, engine_config)
 safe_float (val)
 convert_numpy (obj)
 init_controller (ControllerInitRequest request, UserSession session=Depends(get_session))
 _init_controller (ControllerInitRequest request, UserSession session)
 controller_step (ControllerStepRequest request, UserSession session=Depends(get_session))
 _controller_step (ControllerStepRequest request, UserSession session)
 simulate_controller (ControllerSimulateRequest request, UserSession session=Depends(get_session))
 _simulate_controller (ControllerSimulateRequest request, UserSession session)
 reset_controller (UserSession session=Depends(get_session))
 simulate_layer2_controller (Layer2ControllerSimulateRequest request, UserSession session=Depends(get_session))
 _simulate_layer2_controller (Layer2ControllerSimulateRequest request, UserSession session)
 simulate_layer2_controller_stream (Layer2ControllerSimulateRequest request, UserSession session=Depends(get_session))
 simulate_from_layer2_config (Layer2ConfigSimulateRequest request, UserSession session=Depends(get_session))
 _simulate_from_layer2_config (Layer2ConfigSimulateRequest request, UserSession session)
 simulate_from_layer2_config_stream (Layer2ConfigSimulateRequest request, UserSession session=Depends(get_session))
 upload_config_and_simulate (UploadFile file=File(...), float dt=0.01, UserSession session=Depends(get_session))
 get_controller_status (UserSession session=Depends(get_session))

Variables

 router = APIRouter(prefix="/api/control", tags=["control"])
 _log = logging.getLogger(__name__)
 _PROJECT_ROOT = Path(__file__).resolve().parents[2]
str _CONFIGS_DIR = _PROJECT_ROOT / "configs"

Detailed Description

Controller endpoints for robust DDP thrust control.

Function Documentation

◆ _confined_yaml()

Path backend.routers.control._confined_yaml ( str path,
*Path roots,
Path base = _PROJECT_ROOT )
protected
``path`` (relative to ``base``) resolved, if it is a .yaml file under one of ``roots``; else 400/404.

Definition at line 48 of file control.py.

Referenced by _init_controller(), _simulate_from_layer2_config(), and simulate_from_layer2_config_stream().

◆ _controller_step()

backend.routers.control._controller_step ( ControllerStepRequest request,
UserSession session )
protected

Definition at line 321 of file control.py.

◆ _engine_config_roots()

tuple backend.routers.control._engine_config_roots ( UserSession session)
protected

Definition at line 44 of file control.py.

Referenced by _simulate_from_layer2_config(), and simulate_from_layer2_config_stream().

◆ _fresh_controller()

RobustDDPController backend.routers.control._fresh_controller ( UserSession session,
cfg,
engine_config )
protected
A new controller for this session, reset; called through run_compute (under the lock).

Definition at line 73 of file control.py.

◆ _init_controller()

backend.routers.control._init_controller ( ControllerInitRequest request,
UserSession session )
protected

Definition at line 279 of file control.py.

References _confined_yaml(), and convert_numpy().

◆ _simulate_controller()

backend.routers.control._simulate_controller ( ControllerSimulateRequest request,
UserSession session )
protected

Definition at line 433 of file control.py.

References convert_numpy(), and max.

◆ _simulate_from_layer2_config()

backend.routers.control._simulate_from_layer2_config ( Layer2ConfigSimulateRequest request,
UserSession session )
protected

◆ _simulate_layer2_controller()

backend.routers.control._simulate_layer2_controller ( Layer2ControllerSimulateRequest request,
UserSession session )
protected

Definition at line 706 of file control.py.

References convert_numpy(), and max.

Referenced by _simulate_from_layer2_config().

◆ controller_step()

backend.routers.control.controller_step ( ControllerStepRequest request,
UserSession session = Depends(get_session) )
Execute one controller step.

Off the event loop, one at a time per session: see "Off the loop" at the top.

Definition at line 313 of file control.py.

◆ convert_numpy()

backend.routers.control.convert_numpy ( obj)
Recursively convert numpy types to Python native types, handling NaN and Inf.

Definition at line 99 of file control.py.

References convert_numpy().

Referenced by _init_controller(), _simulate_controller(), _simulate_layer2_controller(), convert_numpy(), get_controller_status(), simulate_from_layer2_config_stream(), simulate_layer2_controller_stream(), and upload_config_and_simulate().

◆ get_controller_status()

backend.routers.control.get_controller_status ( UserSession session = Depends(get_session))
Get current controller status.

Definition at line 1790 of file control.py.

References convert_numpy().

◆ init_controller()

backend.routers.control.init_controller ( ControllerInitRequest request,
UserSession session = Depends(get_session) )
Initialize the robust DDP controller.

Off the event loop, one at a time per session: see "Off the loop" at the top.

Definition at line 271 of file control.py.

◆ reset_controller()

backend.routers.control.reset_controller ( UserSession session = Depends(get_session))
Reset controller state.

Definition at line 688 of file control.py.

◆ safe_float()

backend.routers.control.safe_float ( val)
Convert value to float, replacing NaN/Inf with None.

Definition at line 86 of file control.py.

Referenced by simulate_from_layer2_config_stream(), simulate_layer2_controller_stream(), and upload_config_and_simulate().

◆ simulate_controller()

backend.routers.control.simulate_controller ( ControllerSimulateRequest request,
UserSession session = Depends(get_session) )
Simulate controller over a time series.

Off the event loop, one at a time per session: see "Off the loop" at the top.

Definition at line 425 of file control.py.

◆ simulate_from_layer2_config()

backend.routers.control.simulate_from_layer2_config ( Layer2ConfigSimulateRequest request,
UserSession session = Depends(get_session) )
Run controller simulation from a Layer 2 config file by extracting thrust curve.

Off the event loop, one at a time per session: see "Off the loop" at the top.

Definition at line 1164 of file control.py.

◆ simulate_from_layer2_config_stream()

backend.routers.control.simulate_from_layer2_config_stream ( Layer2ConfigSimulateRequest request,
UserSession session = Depends(get_session) )
Stream controller simulation from a Layer 2 config file in real-time.

Definition at line 1272 of file control.py.

References _confined_yaml(), _engine_config_roots(), convert_numpy(), max, and safe_float().

◆ simulate_layer2_controller()

backend.routers.control.simulate_layer2_controller ( Layer2ControllerSimulateRequest request,
UserSession session = Depends(get_session) )
Run controller simulation using Layer 2 optimized thrust curve as reference.

Off the event loop, one at a time per session: see "Off the loop" at the top.

Definition at line 698 of file control.py.

◆ simulate_layer2_controller_stream()

backend.routers.control.simulate_layer2_controller_stream ( Layer2ControllerSimulateRequest request,
UserSession session = Depends(get_session) )
Stream controller simulation in real-time using Layer 2 optimized thrust curve.

Definition at line 947 of file control.py.

References convert_numpy(), max, and safe_float().

◆ upload_config_and_simulate()

backend.routers.control.upload_config_and_simulate ( UploadFile file = File(...),
float dt = 0.01,
UserSession session = Depends(get_session) )
Upload a Layer 2 config file and immediately run controller simulation.

Definition at line 1552 of file control.py.

References convert_numpy(), max, and safe_float().

Variable Documentation

◆ _CONFIGS_DIR

str backend.routers.control._CONFIGS_DIR = _PROJECT_ROOT / "configs"
protected

Definition at line 41 of file control.py.

◆ _log

backend.routers.control._log = logging.getLogger(__name__)
protected

Definition at line 32 of file control.py.

◆ _PROJECT_ROOT

backend.routers.control._PROJECT_ROOT = Path(__file__).resolve().parents[2]
protected

Definition at line 40 of file control.py.

◆ router

backend.routers.control.router = APIRouter(prefix="/api/control", tags=["control"])

Definition at line 31 of file control.py.