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
Controller Class Reference

Runs the control loop on the device: the clock, the HUD inbox, NVS, logging and the published status around the pure control::ControlLogic. More...

#include <controller.h>

Inheritance diagram for Controller:
BaseStatusProvider remote::BaseRemoteSink control::ControlPorts

Public Member Functions

Lifecycle Management
 Controller (BaseTurret &turret, BaseDetectionModule &detection_module, Joystick &joystick)
 Construct a new Controller object.
 
 ~Controller () override
 Destroy the Controller object.
 
void begin ()
 Loads a saved calibration from NVS, if any. Call from setup() after the turret has started.
 
Core Execution
void run ()
 One pass of the control loop; call from the primary loop().
 
void submit (const remote::Command &cmd) override
 Receives a HUD command. Safe to call from the httpd task while run() executes on another core.
 
ControlStatus control_status () const override
 Latest published status. Safe to call from any task.
 
- Public Member Functions inherited from BaseStatusProvider
- Public Member Functions inherited from remote::BaseRemoteSink

Detailed Description

Runs the control loop on the device: the clock, the HUD inbox, NVS, logging and the published status around the pure control::ControlLogic.

Every decision (modes, button gestures, HUD requests, calibration, jog arbitration) is made by control::ControlLogic, which documents the rules and is natively tested. The Controller implements its control::ControlPorts over the BaseTurret, the BaseDetectionModule and the Joystick, turns its log events into ESP_LOG lines and saves a fresh calibration with cal_store.

Threads: submit() runs on the httpd task and only stores into the inbox under its spinlock; run() and every port call run on the loop task. The status is published under its own spinlock for any task to read.

The camera is fixed on the base and the turret aims absolutely, so a calibration is a fixed two-point mapping from image pixels to pan/tilt angles, saved in NVS.

Constructor & Destructor Documentation

◆ Controller()

Controller::Controller ( BaseTurret & turret,
BaseDetectionModule & detection_module,
Joystick & joystick )
inline

Construct a new Controller object.

Parameters
turretReference to the turret implementation.
detection_moduleReference to the detection implementation.
joystickReference to the Joystick input handler.
Note
Defaults to Ai mode with the default (uncalibrated) aim map.

Member Function Documentation

◆ control_status()

ControlStatus Controller::control_status ( ) const
overridevirtual

Latest published status. Safe to call from any task.

Implements BaseStatusProvider.

◆ run()

void Controller::run ( )

One pass of the control loop; call from the primary loop().

Reads the clock and the button, runs one control::ControlLogic pass and publishes the status.

Warning
Not paced by the camera: returns immediately when there is nothing to do, so the caller's loop must yield.

◆ submit()

void Controller::submit ( const remote::Command & cmd)
overridevirtual

Receives a HUD command. Safe to call from the httpd task while run() executes on another core.

Only stores the command in the inbox under a spinlock; run() applies it. Moves expire after remote::kJogTimeoutMs without a refresh (dead man).

Implements remote::BaseRemoteSink.


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