RIT VEXU Core API
Loading...
Searching...
No Matches
FeedForward Class Reference

#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

Detailed Description

FeedForward

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)

Author
Ryan McGee
Date
6/13/2022

Constructor & Destructor Documentation

◆ FeedForward()

FeedForward::FeedForward ( const double & kS,
const double & kV,
const double & kA,
const double & kG )

Creates a FeedForward object.

Parameters
KsCoefficient to overcome static friction: the point at which the motor starts to move.
KvVeclocity coefficient: the power required to keep the mechanism in motion.
KakA - Acceleration coefficient: the power required to change the mechanism's speed.
KgkG - Gravity coefficient: only needed for lifts. The power required to overcome gravity and stay

Member Function Documentation

◆ calculate()

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

Parameters
vRequested velocity of system
aRequested acceleration of system
Returns
A feedforward that should closely represent the system if tuned correctly

Member Data Documentation

◆ kA

double FeedForward::kA

kA - Acceleration coefficient: the power required to change the mechanism's speed. Multiplied by the requested acceleration.

◆ kG

double FeedForward::kG

kG - Gravity coefficient: only needed for lifts. The power required to overcome gravity and stay at steady state.

◆ kS

double FeedForward::kS

Coefficient to overcome static friction: the point at which the motor starts to move.

◆ kV

double FeedForward::kV

Veclocity coefficient: the power required to keep the mechanism in motion. Multiplied by the requested velocity.


The documentation for this class was generated from the following files: