Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
control::ControlLogic Class Reference

The control loop's decisions, one pass per run() call: button gestures, HUD requests, the three modes and the status counters. More...

#include <control_logic.h>

Public Member Functions

 ControlLogic (ControlPorts &io)
 
void load_calibration (const aiming::AimMap &map)
 Makes a saved calibration active (Controller::begin, after loading it from NVS).
 
void run (uint32_t now_ms, bool held)
 One pass: classifies the button, services a pending HUD record, applies the HUD's mode, calibration and aim requests, then runs the per-mode behaviour (jog arbitration, or the aim policy in Ai).
 
ControlStatus status (uint32_t now_ms, const aiming::Angles &pose, remote::JogSpeed speed) const
 The status to publish after a pass.
 
ControlMode mode () const
 The active operating mode.
 

Detailed Description

The control loop's decisions, one pass per run() call: button gestures, HUD requests, the three modes and the status counters.

Owns the button classifier, the aim policy, the calibration session, the mode and the counters published in ControlStatus. Starts in Ai mode with the default (uncalibrated) aim map.

Modes (ControlMode):

  • Ai: every pass reads the track snapshot that the detection task publishes and feeds it to the aiming::AimPolicy, which yields absolute pan/tilt targets (or Home after the target is lost).
  • User: no frames needed; the jog (a deflected stick, else an active HUD jog) goes to the turret at most once per kJogPeriodMs. A HUD aim point moves the turret to an absolute pose.
  • Calibrate: jogs and aims as in User mode (the jog is zeroed while the button is held or a HUD record is pending); detection keeps running in its own task so the HUD box shows. A short press (or cal:point) records a calibration point: the turret's resting angles paired with the visible target's pixel position. A successful fit is saved through ControlPorts::save_calibration, made active, and switches to Ai.

Button gestures: short press toggles Ai/User (or records a point in Calibrate); a long press enters Calibrate, or cancels it and restores the previous mode.

HUD requests (taken from the inbox once per pass, so a request that does not apply is dropped, never deferred): mode:* outside Calibrate only, and not on a pass that started in Calibrate; cal:start / cal:cancel act like a long press when not calibrating / while calibrating (ignored otherwise); cal:point acts like a short press in Calibrate (ignored otherwise): the jog is zeroed and the pose is recorded on the first later pass where the pan is at rest, or after kHudRecordTimeoutMs with the current pose. Any cal:* is dropped on a pass where the button produced an event, and a knob record clears a pending HUD one. aim:x,y in User and Calibrate only, and not while a calibration record is in progress: the pixel goes through the active aim map to an absolute target, and the aim holds (the idle (0,0) jog is not sent) until a jog source becomes active.

Constructor & Destructor Documentation

◆ ControlLogic()

control::ControlLogic::ControlLogic ( ControlPorts & io)
inlineexplicit
Parameters
ioThe device ports; must outlive this object.

Member Function Documentation

◆ run()

void control::ControlLogic::run ( uint32_t now_ms,
bool held )

One pass: classifies the button, services a pending HUD record, applies the HUD's mode, calibration and aim requests, then runs the per-mode behaviour (jog arbitration, or the aim policy in Ai).

Parameters
now_msmillis() at the start of the pass.
heldRaw joystick button level read at the start of the pass.

◆ status()

ControlStatus control::ControlLogic::status ( uint32_t now_ms,
const aiming::Angles & pose,
remote::JogSpeed speed ) const

The status to publish after a pass.

Parameters
now_msThe pass's millis() (for the AI home countdown).
poseCurrent turret pose.
speedThe HUD jog speed setting from the inbox.

The documentation for this class was generated from the following files: