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.h
1
11#pragma once
12
14#include "base_turret.h"
15#include "control_logic.h"
16#include "control_status.h"
17#include "joystick.h"
18#include "remote_inbox.h"
19#include "sync.h"
21#include <cstdint>
22#include <stdlib.h>
23
40{
41private:
43 BaseTurret& _turret;
44
46 BaseDetectionModule& _detection_module;
47
49 Joystick& _joystick;
50
53
56
60
62 void publish_status(uint32_t now);
63
67 control::StickDeflection read_stick() noexcept override;
69 remote::Jog read_hud_jog() noexcept override;
70 control::HudRequests take_hud_requests() noexcept override;
71 TrackSnapshot read_track() noexcept override;
72 aiming::Angles turret_pose() noexcept override;
73 float turret_pan_speed() noexcept override;
74 void turret_jog(float pan, float tilt) noexcept override;
75 void turret_set_target(const aiming::Angles& target) noexcept override;
76 void turret_home() noexcept override;
77 void reset_detection() noexcept override;
78 bool save_calibration(const aiming::AimMap& map) noexcept override;
79 void log(const control::LogRecord& record) noexcept override;
82public:
95 Controller(BaseTurret& turret, BaseDetectionModule& detection_module, Joystick& joystick)
96 : _turret(turret), _detection_module(detection_module), _joystick(joystick), _logic(*this)
97 {
98 }
99
103 ~Controller() override {}
104
108 void begin();
122 void run();
123
129 void submit(const remote::Command& cmd) override;
130
132 ControlStatus control_status() const override;
134};
Abstract interface for object detection logic on ESP32-CAM.
What the controller can ask of the pan/tilt turret. Thread-safe: called from loop(),...
An abstract base class (Interface) that defines the contract for detection algorithms....
Definition base_detection_module.h:22
Interface for anything that can report a ControlStatus (the Controller). Lets the network layer read ...
Definition control_status.h:46
Definition base_turret.h:11
Runs the control loop on the device: the clock, the HUD inbox, NVS, logging and the published status ...
Definition controller.h:40
void begin()
Loads a saved calibration from NVS, if any. Call from setup() after the turret has started.
Definition controller.cpp:9
void run()
One pass of the control loop; call from the primary loop().
Definition controller.cpp:38
~Controller() override
Destroy the Controller object.
Definition controller.h:103
ControlStatus control_status() const override
Latest published status. Safe to call from any task.
Definition controller.cpp:36
Controller(BaseTurret &turret, BaseDetectionModule &detection_module, Joystick &joystick)
Construct a new Controller object.
Definition controller.h:95
void submit(const remote::Command &cmd) override
Receives a HUD command. Safe to call from the httpd task while run() executes on another core.
Definition controller.cpp:23
High-level interface for 12-bit analog joystick input.
Definition joystick.h:27
The control loop's decisions, one pass per run() call: button gestures, HUD requests,...
Definition control_logic.h:148
Everything ControlLogic reads from or commands on the device, called from the loop task.
Definition control_logic.h:77
Receives parsed commands; implemented by the controller (device) and fakes (tests).
Definition remote_command.h:54
A value of type T that owns its own spinlock; every access is one short critical section.
Definition sync.h:54
The controller's decisions: button gestures, HUD requests, modes, calibration and jog arbitration (pu...
Read-only view of the controller state for the HUD and stats line.
Holds the latest remote command state with a dead-man jog timeout (pure C++20, natively tested).
Snapshot of the controller, published once per control pass.
Definition control_status.h:17
Definition track_snapshot.h:14
pan = pan_a * x + pan_b, tilt = tilt_a * y + tilt_b.
Definition aim_map.h:50
Turret pose: pan degrees from home (positive = right), tilt servo degrees (larger = up).
Definition aim_map.h:30
The HUD's one-shot requests, taken from the inbox together once per pass.
Definition control_logic.h:41
One log event and its arguments; fields other than the event's own are left at their defaults.
Definition control_logic.h:63
Joystick deflection per axis, -255..255 (Joystick::get_speed_x / get_speed_y); y positive = up.
Definition control_logic.h:35
One parsed message. Only the fields matching kind are meaningful.
Definition remote_command.h:31
Jog request in the same units as Joystick/Turret::jog.
Definition remote_inbox.h:22
Small RAII wrappers for the two locking patterns the firmware uses (device only).
Operating modes of the turret system.