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_logic.h File Reference

The controller's decisions: button gestures, HUD requests, modes, calibration and jog arbitration (pure C++20, natively tested). More...

#include "aim_policy.h"
#include "button_classifier.h"
#include "calibration_session.h"
#include "control_status.h"
#include "remote_inbox.h"
#include "system_control_types.h"
#include "track_snapshot.h"
#include <cstdint>
#include <optional>

Go to the source code of this file.

Classes

struct  control::StickDeflection
 Joystick deflection per axis, -255..255 (Joystick::get_speed_x / get_speed_y); y positive = up. More...
 
struct  control::HudRequests
 The HUD's one-shot requests, taken from the inbox together once per pass. More...
 
struct  control::LogRecord
 One log event and its arguments; fields other than the event's own are left at their defaults. More...
 
class  control::ControlPorts
 Everything ControlLogic reads from or commands on the device, called from the loop task. More...
 
class  control::ControlLogic
 The control loop's decisions, one pass per run() call: button gestures, HUD requests, the three modes and the status counters. More...
 

Enumerations

enum class  control::LogEvent : uint8_t {
  ModeChanged , CalStarted , CalCancelled , CalSaveFailed ,
  CalComplete , CalFailed , CalRestarted , CalMiss ,
  CalPointRecorded , HudPoseTimeout , PressPoseFallback
}
 Something worth a log line; the glue picks the level and the text. More...
 

Variables

constexpr uint32_t control::kJogPeriodMs = 40
 Minimum time between jog passes in User and Calibrate (25 Hz).
 
constexpr uint32_t control::kHudRecordTimeoutMs = 1000
 Longest wait for the pan to stop before a HUD cal:point records the current pose anyway.
 

Detailed Description

The controller's decisions: button gestures, HUD requests, modes, calibration and jog arbitration (pure C++20, natively tested).

Controller (lib/controller) is the device glue around this class: it owns the clock, the HUD inbox and its spinlock, NVS, logging and the published status, and implements control::ControlPorts over the turret, the detection module and the joystick. ControlLogic makes every read and command through the ports at the point where the decision needs it, so the joystick ADC is read only on a jog pass, the HUD jog's clock is read inside the inbox lock, and the turret's latest-wins mailbox receives its writes in decision order. Single-threaded: run() belongs to the loop task.

Enumeration Type Documentation

◆ LogEvent

enum class control::LogEvent : uint8_t
strong

Something worth a log line; the glue picks the level and the text.

Enumerator
ModeChanged 

info; LogRecord::mode is the new mode

CalStarted 

info; LogRecord::mode is the mode calibration was started from

CalCancelled 

info; LogRecord::mode is the restored mode

CalSaveFailed 

error: the NVS write failed, the fit stays active until reboot

CalComplete 

info: the fit is active, back to Ai

CalFailed 

warning; LogRecord::failure is the session's reason (may be null)

CalRestarted 

info: a record after a failed fit restarted at point 1

CalMiss 

warning: record ignored, no target visible

CalPointRecorded 

info; LogRecord::points is the number of points now recorded

HudPoseTimeout 

warning: the pan still moved kHudRecordTimeoutMs after cal:point, current pose used

PressPoseFallback 

warning: no stationary pose was captured during the press, current pose used