|
RIT VEXU Core API
|
#include <feedforward.h>
Public Member Functions | |
| FeedForward (const double &kS, const double &kV, const double &kA, const double &kG) | |
| double | calculate (double v, double a, double pid_ref=0.0) |
| Perform the feedforward calculation. | |
Public Attributes | |
| double | kS |
| double | kV |
| double | kA |
| double | kG |
Stores the feedfoward constants, and allows for quick computation. Feedfoward should be used in systems that require smooth precise movements and have high inertia, such as drivetrains and lifts.
This is best used alongside a PID loop, with the form: output = pid.get() + feedforward.calculate(v, a);
In this case, the feedforward does the majority of the heavy lifting, and the pid loop only corrects for inconsistencies
For information about tuning feedforward, I reccommend looking at this post: https://www.chiefdelphi.com/t/paper-frc-drivetrain-characterization/160915 (yes I know it's for FRC but trust me, it's useful)
| FeedForward::FeedForward | ( | const double & | kS, |
| const double & | kV, | ||
| const double & | kA, | ||
| const double & | kG ) |
Creates a FeedForward object.
| Ks | Coefficient to overcome static friction: the point at which the motor starts to move. |
| Kv | Veclocity coefficient: the power required to keep the mechanism in motion. |
| Ka | kA - Acceleration coefficient: the power required to change the mechanism's speed. |
| Kg | kG - Gravity coefficient: only needed for lifts. The power required to overcome gravity and stay |
| double FeedForward::calculate | ( | double | v, |
| double | a, | ||
| double | pid_ref = 0.0 ) |
Perform the feedforward calculation.
This calculation is the equation: F = kG + kS*sgn(v) + kV*v + kA*a
| v | Requested velocity of system |
| a | Requested acceleration of system |
| double FeedForward::kA |
kA - Acceleration coefficient: the power required to change the mechanism's speed. Multiplied by the requested acceleration.
| double FeedForward::kG |
kG - Gravity coefficient: only needed for lifts. The power required to overcome gravity and stay at steady state.
| double FeedForward::kS |
Coefficient to overcome static friction: the point at which the motor starts to move.
| double FeedForward::kV |
Veclocity coefficient: the power required to keep the mechanism in motion. Multiplied by the requested velocity.