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
aim_map.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <cstdint>
13#include <optional>
14
15namespace aiming
16{
17constexpr int32_t kStepsPerRev = 2048;
18constexpr float kPanMinDeg = -90.0f;
19constexpr float kPanMaxDeg = 90.0f;
20constexpr float kTiltMinDeg = 20.0f;
21constexpr float kTiltMaxDeg = 160.0f;
22constexpr float kTiltHomeDeg = 90.0f;
23constexpr int kFrameW = 320;
24constexpr int kFrameH = 240;
25constexpr float kLimitMarginDeg = 0.5f;
26constexpr float kMinCalDx = 80.0f;
27constexpr float kMinCalDy = 60.0f;
28
30struct Angles {
31 float pan = 0.0f;
32 float tilt = kTiltHomeDeg;
33};
34
36struct CalPoint {
37 float x = 0.0f;
38 float y = 0.0f;
39 float pan = 0.0f;
40 float tilt = kTiltHomeDeg;
41};
42
44struct Pixel {
45 float x = 0.0f;
46 float y = 0.0f;
47};
48
50struct AimMap {
51 float pan_a = 0.0f;
52 float pan_b = 0.0f;
53 float tilt_a = 0.0f;
54 float tilt_b = kTiltHomeDeg;
55
57 Angles aim(float x, float y) const;
58
64 Pixel to_pixel(Angles a) const;
65};
66
68struct ReachBox {
69 int16_t x0 = 0;
70 int16_t y0 = 0;
71 int16_t x1 = kFrameW - 1;
72 int16_t y1 = kFrameH - 1;
73};
74
77
79std::optional<AimMap> fit(const CalPoint& p1, const CalPoint& p2);
80
87ReachBox reach_box(const AimMap& m);
88
93uint8_t limit_bits(Angles a);
94
99
104int32_t pan_deg_to_steps(float deg);
106float pan_steps_to_deg(int32_t steps);
107} // namespace aiming
std::optional< AimMap > fit(const CalPoint &p1, const CalPoint &p2)
Per-axis line through two calibration points; empty if they are too close or not finite.
Definition aim_map.cpp:105
uint8_t limit_bits(Angles a)
Soft-limit proximity bits for the HUD: 1 pan within kLimitMarginDeg of kPanMinDeg,...
Definition aim_map.cpp:73
constexpr int kFrameW
QVGA.
Definition aim_map.h:23
ReachBox reach_box(const AimMap &m)
The image region whose aim lies inside the soft limits: the pixels where kPanMinDeg <= pan <= kPanMax...
Definition aim_map.cpp:65
int32_t pan_deg_to_steps(float deg)
Converts pan degrees to 28BYJ-48 full steps (rounded). Non-finite input gives 0; the degrees are clam...
Definition aim_map.cpp:133
constexpr float kMinCalDx
closer calibration points amplify aiming error
Definition aim_map.h:26
AimMap default_map()
Camera next to the turret, 66 x 50 degree field of view, image centre = home.
Definition aim_map.cpp:95
float pan_steps_to_deg(int32_t steps)
Converts a pan step count (28BYJ-48 full steps from home) to degrees; the inverse of pan_deg_to_steps...
Definition aim_map.cpp:143
Angles clamp_angles(Angles a)
Clamps angles to the soft limits; non-finite pan becomes 0 and non-finite tilt becomes kTiltHomeDeg f...
Definition aim_map.cpp:43
constexpr float kLimitMarginDeg
limit_bits() reports an axis this close to a soft limit
Definition aim_map.h:25
constexpr int32_t kStepsPerRev
28BYJ-48 full steps per revolution
Definition aim_map.h:17
pan = pan_a * x + pan_b, tilt = tilt_a * y + tilt_b.
Definition aim_map.h:50
Angles aim(float x, float y) const
Angles for an image position, clamped to the soft limits.
Definition aim_map.cpp:58
Pixel to_pixel(Angles a) const
Image position that aim() maps to these angles: the exact inverse before clamping,...
Definition aim_map.cpp:60
Turret pose: pan degrees from home (positive = right), tilt servo degrees (larger = up).
Definition aim_map.h:30
One calibration sample: the target's pixel and the turret angles that pointed at it.
Definition aim_map.h:36
An image position in pixels; not clamped, so it can lie outside the frame.
Definition aim_map.h:44
Rectangle of frame pixels (inclusive corners) with x0 <= x1 and y0 <= y1.
Definition aim_map.h:68