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
step_planner.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cstdint>
14
15namespace aiming
16{
18 float max_speed = 400.0f;
19 float accel = 800.0f;
20 float min_speed = 20.0f;
21 int32_t min_pos = -512;
22 int32_t max_pos = 512;
23 float tick_s = 0.001f;
24};
25
27{
28public:
29 explicit StepPlanner(const PlannerConfig& config = PlannerConfig{});
30
31 void set_target(int32_t steps);
32 void set_velocity(float steps_per_s);
33 int tick();
34
35 int32_t position() const { return position_; }
36 int32_t target() const { return target_; }
37 float speed() const { return speed_; }
38 bool is_idle() const;
39 void reset_position(int32_t steps = 0);
40 const PlannerConfig& config() const { return config_; }
41
42private:
43 enum class Mode : uint8_t { Target, Jog };
44
45 float goal_speed();
46
47 PlannerConfig config_;
48 Mode mode_ = Mode::Target;
49 int32_t position_ = 0;
50 int32_t target_ = 0;
51 float jog_speed_ = 0.0f;
52 float speed_ = 0.0f;
53 float frac_ = 0.0f;
54};
55} // namespace aiming
Definition step_planner.h:27
void set_velocity(float steps_per_s)
jog; clamped to +-max_speed; switches to jog mode
Definition step_planner.cpp:21
void set_target(int32_t steps)
absolute, clamped to the soft limits; switches to target mode
Definition step_planner.cpp:15
void reset_position(int32_t steps=0)
redefine the current position (zero_here); stops motion
Definition step_planner.cpp:36
Definition step_planner.h:17
float min_speed
creep speed: start/finish at this without ramping
Definition step_planner.h:20
float max_speed
steps/s
Definition step_planner.h:18
int32_t min_pos
soft limits (+-90 deg at 2048 steps/rev)
Definition step_planner.h:21
float accel
steps/s^2
Definition step_planner.h:19