WPILibC++ 2023.4.3-108-ge5452e3
|
Constructs a plant inversion model-based feedforward from a LinearSystem. More...
#include <frc/controller/LinearPlantInversionFeedforward.h>
Public Types | |
using | StateVector = Vectord< States > |
using | InputVector = Vectord< Inputs > |
Public Member Functions | |
template<int Outputs> | |
LinearPlantInversionFeedforward (const LinearSystem< States, Inputs, Outputs > &plant, units::second_t dt) | |
Constructs a feedforward with the given plant. More... | |
LinearPlantInversionFeedforward (const Matrixd< States, States > &A, const Matrixd< States, Inputs > &B, units::second_t dt) | |
Constructs a feedforward with the given coefficients. More... | |
const InputVector & | Uff () const |
Returns the previously calculated feedforward as an input vector. More... | |
double | Uff (int i) const |
Returns an element of the previously calculated feedforward. More... | |
const StateVector & | R () const |
Returns the current reference vector r. More... | |
double | R (int i) const |
Returns an element of the reference vector r. More... | |
void | Reset (const StateVector &initialState) |
Resets the feedforward with a specified initial state vector. More... | |
void | Reset () |
Resets the feedforward with a zero initial state vector. More... | |
InputVector | Calculate (const StateVector &nextR) |
Calculate the feedforward with only the desired future reference. More... | |
InputVector | Calculate (const StateVector &r, const StateVector &nextR) |
Calculate the feedforward with current and future reference vectors. More... | |
Constructs a plant inversion model-based feedforward from a LinearSystem.
The feedforward is calculated as u_ff = B+ (r_k+1 - A r_k) , where B+ is the pseudoinverse of B.
For more on the underlying math, read https://file.tavsys.net/control/controls-engineering-in-frc.pdf.
States | The number of states. |
Inputs | The number of inputs. |
using frc::LinearPlantInversionFeedforward< States, Inputs >::InputVector = Vectord<Inputs> |
using frc::LinearPlantInversionFeedforward< States, Inputs >::StateVector = Vectord<States> |
|
inline |
Constructs a feedforward with the given plant.
Outputs | The number of outputs. |
plant | The plant being controlled. |
dt | Discretization timestep. |
|
inline |
Constructs a feedforward with the given coefficients.
A | Continuous system matrix of the plant being controlled. |
B | Continuous input matrix of the plant being controlled. |
dt | Discretization timestep. |
|
inline |
Calculate the feedforward with only the desired future reference.
This uses the internally stored "current" reference.
If this method is used the initial state of the system is the one set using Reset(const StateVector&). If the initial state is not set it defaults to a zero vector.
nextR | The reference state of the future timestep (k + dt). |
|
inline |
Calculate the feedforward with current and future reference vectors.
r | The reference state of the current timestep (k). |
nextR | The reference state of the future timestep (k + dt). |
|
inline |
Returns the current reference vector r.
|
inline |
Returns an element of the reference vector r.
i | Row of r. |
|
inline |
Resets the feedforward with a zero initial state vector.
|
inline |
Resets the feedforward with a specified initial state vector.
initialState | The initial state vector. |
|
inline |
Returns the previously calculated feedforward as an input vector.
|
inline |
Returns an element of the previously calculated feedforward.
i | Row of uff. |