RIT VEXU Core API
Loading...
Searching...
No Matches
motion_controller.h
1#pragma once
2#include "core/screen/legacy.h"
3#include "core/subsystems/tank_drive.h"
4#include "core/utils/controls/feedback_base.h"
5#include "core/utils/controls/feedforward.h"
6#include "core/utils/controls/pid.h"
7#include "core/utils/controls/trapezoid_profile.h"
8
25class MotionController : public Feedback {
26 public:
33 typedef struct {
34 double max_v;
35 double accel;
36 PID pid;
39
50
55 void init(double start_pt, double end_pt) override;
56
63 double update(double sensor_val) override;
64
66 double get() override;
67
75 void set_limits(double lower, double upper) override;
76
81 bool is_on_target() override;
82
84 motion_t get_motion() const;
85
86 LegacyScreen::Page *Page();
87
106 static FeedForward
107 tune_feedforward(TankDrive &drive, OdometryTank &odometry, double pct = 0.6, double duration = 2);
108
109 private:
110 m_profile_cfg_t config;
111
112 PID pid;
113 FeedForward ff;
114 TrapezoidProfile profile;
115
116 double current_pos;
117 double end_pt;
118
119 double lower_limit = 0, upper_limit = 0;
120 double out = 0;
121 motion_t cur_motion;
122
123 vex::timer tmr;
124 friend class MotionControllerPage;
125};
Definition feedforward.h:29
Definition feedback_base.h:10
Page describes one part of the screen slideshow.
Definition legacy.h:149
MotionController(m_profile_cfg_t &config)
Construct a new Motion Controller object.
Definition motion_controller.cpp:14
static FeedForward tune_feedforward(TankDrive &drive, OdometryTank &odometry, double pct=0.6, double duration=2)
Definition motion_controller.cpp:93
double get() override
Definition motion_controller.cpp:50
motion_t get_motion() const
Definition motion_controller.cpp:72
double update(double sensor_val) override
Update the motion profile with a new sensor value.
Definition motion_controller.cpp:36
void set_limits(double lower, double upper) override
Definition motion_controller.cpp:58
bool is_on_target() override
Definition motion_controller.cpp:67
void init(double start_pt, double end_pt) override
Initialize the motion profile for a new movement This will also reset the PID and profile timers.
Definition motion_controller.cpp:24
Definition odometry_tank.h:15
Definition pid.h:21
Definition tank_drive.h:23
Definition trapezoid_profile.h:25
Definition motion_controller.h:33
double max_v
the maximum velocity the robot can drive
Definition motion_controller.h:34
FeedForward ff
configuration parameters for the internal
Definition motion_controller.h:37
double accel
the most acceleration the robot can do
Definition motion_controller.h:35