Valor 6800 1.0
Loading...
Searching...
No Matches
PIDF.h
1
2#pragma once
3
4#include <optional>
5#include <numbers>
6
7#include <units/acceleration.h>
8#include <units/angle.h>
9#include <units/angular_acceleration.h>
10#include <units/angular_jerk.h>
11#include <units/angular_velocity.h>
12#include <units/base.h>
13#include <units/velocity.h>
14
15namespace valor {
16
17enum FeedForwardType { LINEAR, CIRCULAR };
18
22struct PIDF {
23 void setMaxVelocity(units::turns_per_second_t _maxVelocity) { maxVelocity = _maxVelocity; }
24
25 void setMaxVelocity(units::meters_per_second_t _maxVelocityMPS, units::meter_t wheelDiameter) {
26 units::turns_per_second_t _maxVelocity = _maxVelocityMPS * 1_tr / (std::numbers::pi * wheelDiameter);
27 maxVelocity = _maxVelocity;
28 }
29
30 void setMaxAcceleration(units::turns_per_second_squared_t _maxAcceleration) { maxAcceleration = _maxAcceleration; }
31
32 void setMaxAcceleration(units::meters_per_second_squared_t _maxAccelerationMPS, units::meter_t wheelDiameter) {
33 units::turns_per_second_squared_t _maxAcceleration = _maxAccelerationMPS * 1_tr / (std::numbers::pi * wheelDiameter);
34 maxAcceleration = _maxAcceleration;
35 }
36
37 void setMaxJerk(units::turns_per_second_cubed_t _maxJerk) { maxJerk = _maxJerk; }
38
40 double P = 0.0;
42 double I = 0.0;
44 double D = 0.0;
45
46 std::optional<double> kV = std::nullopt;
48 units::turns_per_second_t maxVelocity = 0_tps;
50 units::turns_per_second_squared_t maxAcceleration = 0_tr_per_s_sq;
52 units::turns_per_second_cubed_t maxJerk = 0_tr_per_s_cu;
54 units::turn_t error = 0_tr;
55
56 double S = 0.19;
57
58 double aFF = 0;
59 units::turn_t aFFTarget = 0_deg;
60 FeedForwardType aFFType = FeedForwardType::LINEAR;
61};
62} // namespace valor
Container to hold PID and feed forward values for the motor controller.
Definition PIDF.h:22
double I
Integral control of the feedback term.
Definition PIDF.h:42
units::turn_t error
Minimum error threshold.
Definition PIDF.h:54
double D
Derivative control of the feedback term.
Definition PIDF.h:44
double P
Proportion control of the feedback term.
Definition PIDF.h:40
units::turns_per_second_cubed_t maxJerk
Max jerk: revolutions per 1s^3.
Definition PIDF.h:52
units::turns_per_second_squared_t maxAcceleration
Max acceleration: revolutions per 1s^2.
Definition PIDF.h:50
units::turns_per_second_t maxVelocity
Max velocity: revolutions per 1s.
Definition PIDF.h:48