RIT VEXU Core API
Loading...
Searching...
No Matches
motion_controller.h
1#pragma once
2#include "../core/include/subsystems/screen.h"
3#include "../core/include/subsystems/tank_drive.h"
4#include "../core/include/utils/controls/feedback_base.h"
5#include "../core/include/utils/controls/feedforward.h"
6#include "../core/include/utils/controls/pid.h"
7#include "../core/include/utils/controls/trapezoid_profile.h"
8#include "vex.h"
9
26class MotionController : public Feedback {
27public:
40
51
56 void init(double start_pt, double end_pt) override;
57
64 double update(double sensor_val) override;
65
69 double get() override;
70
78 void set_limits(double lower, double upper) override;
79
84 bool is_on_target() override;
85
89 motion_t get_motion() const;
90
91 screen::Page *Page();
92
111 static FeedForward::ff_config_t tune_feedforward(TankDrive &drive, OdometryTank &odometry, double pct = 0.6,
112 double duration = 2);
113
114private:
115 m_profile_cfg_t config;
116
117 PID pid;
118 FeedForward ff;
119 TrapezoidProfile profile;
120
121 double current_pos;
122 double end_pt;
123
124 double lower_limit = 0, upper_limit = 0;
125 double out = 0;
126 motion_t cur_motion;
127
128 vex::timer tmr;
129 friend class MotionControllerPage;
130};
Definition feedforward.h:29
Definition feedback_base.h:10
Definition motion_controller.h:26
MotionController(m_profile_cfg_t &config)
Construct a new Motion Controller object.
Definition motion_controller.cpp:14
static FeedForward::ff_config_t tune_feedforward(TankDrive &drive, OdometryTank &odometry, double pct=0.6, double duration=2)
Definition motion_controller.cpp:95
double get() override
Definition motion_controller.cpp:51
motion_t get_motion() const
Definition motion_controller.cpp:75
double update(double sensor_val) override
Update the motion profile with a new sensor value.
Definition motion_controller.cpp:35
void set_limits(double lower, double upper) override
Definition motion_controller.cpp:59
bool is_on_target() override
Definition motion_controller.cpp:68
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:23
Definition odometry_tank.h:19
Definition pid.h:23
Definition tank_drive.h:23
Definition trapezoid_profile.h:34
Page describes one part of the screen slideshow.
Definition screen.h:125
Definition feedforward.h:39
Definition motion_controller.h:34
PID::pid_config_t pid_cfg
configuration parameters for the internal PID controller
Definition motion_controller.h:37
double max_v
the maximum velocity the robot can drive
Definition motion_controller.h:35
double accel
the most acceleration the robot can do
Definition motion_controller.h:36
FeedForward::ff_config_t ff_cfg
configuration parameters for the internal
Definition motion_controller.h:38
Definition pid.h:43
Definition trapezoid_profile.h:6