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

Non-blocking turret: callers post commands, a 1 kHz motor task executes them. More...

#include <turret.h>

Inheritance diagram for Turret:
BaseTurret

Public Member Functions

 Turret (Servo &servo)
 
bool begin ()
 Configure pins (coils LOW), attach the servo at home tilt and start the motor task.
 
void set_target_deg (const aiming::Angles &target) override
 Move to absolute angles (clamped to the soft limits).
 
void jog (float pan, float tilt) override
 Manual velocity, each axis -1..1 of its max speed; 0,0 stops (with deceleration).
 
void home () override
 Same as set_target_deg({0, home tilt}).
 
aiming::Angles position_deg () const override
 Current angles (pan from the step counter, tilt as last written to the servo).
 
float pan_speed () const override
 Current stepper speed, steps/s (signed).
 
uint32_t late_ticks () const
 Count of late wake-ups (lag of more than 1 tick) where missed 1 ms ticks were dropped.
 
uint32_t stack_free () const
 Minimum free stack of the motor task seen so far, in bytes (high-water mark, sampled every 1000 ticks; 0 until the first sample).
 
- Public Member Functions inherited from BaseTurret

Detailed Description

Non-blocking turret: callers post commands, a 1 kHz motor task executes them.

Why a task: the Arduino stepper library blocks for the whole move (about 15 ms per command), which stalled frame detection in loop(). Here loop() only writes a small command mailbox; the motor task (core 0, priority 7) ticks an aiming::StepPlanner every millisecond, drives the four ULN2003 coil pins itself and moves the servo at 50 Hz with a rate limit. Why the coils are released: a 28BYJ-48 held energized at standstill draws current continuously and heats up, so all four pins go LOW 500 ms after the last step. Its gear train holds the position unpowered. Thread safety: the mailbox and the published state each sit in a vsync::SpinGuarded (own portMUX spinlock); critical sections only copy a few words.

Constructor & Destructor Documentation

◆ Turret()

Turret::Turret ( Servo & servo)
explicit
Parameters
servoServo object used for tilt (attached by begin()).

Member Function Documentation

◆ begin()

bool Turret::begin ( )

Configure pins (coils LOW), attach the servo at home tilt and start the motor task.

Returns
false if the task could not be created. Idempotent: returns true if already running.

◆ home()

void Turret::home ( )
overridevirtual

Same as set_target_deg({0, home tilt}).

Implements BaseTurret.

◆ jog()

void Turret::jog ( float pan,
float tilt )
overridevirtual

Manual velocity, each axis -1..1 of its max speed; 0,0 stops (with deceleration).

Implements BaseTurret.

◆ pan_speed()

float Turret::pan_speed ( ) const
overridevirtual

Current stepper speed, steps/s (signed).

Implements BaseTurret.

◆ position_deg()

aiming::Angles Turret::position_deg ( ) const
overridevirtual

Current angles (pan from the step counter, tilt as last written to the servo).

Implements BaseTurret.

◆ set_target_deg()

void Turret::set_target_deg ( const aiming::Angles & target)
overridevirtual

Move to absolute angles (clamped to the soft limits).

Implements BaseTurret.


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