WPILibC++ 2023.4.3-108-ge5452e3
|
Constructs a control-affine plant inversion model-based feedforward from given model dynamics. More...
#include <frc/controller/ControlAffinePlantInversionFeedforward.h>
Public Types | |
using | StateVector = Vectord< States > |
using | InputVector = Vectord< Inputs > |
Public Member Functions | |
ControlAffinePlantInversionFeedforward (std::function< StateVector(const StateVector &, const InputVector &)> f, units::second_t dt) | |
Constructs a feedforward with given model dynamics as a function of state and input. More... | |
ControlAffinePlantInversionFeedforward (std::function< StateVector(const StateVector &)> f, const Matrixd< States, Inputs > &B, units::second_t dt) | |
Constructs a feedforward with given model dynamics as a function of state, and the plant's B matrix(continuous input matrix). More... | |
ControlAffinePlantInversionFeedforward (ControlAffinePlantInversionFeedforward &&)=default | |
ControlAffinePlantInversionFeedforward & | operator= (ControlAffinePlantInversionFeedforward &&)=default |
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 control-affine plant inversion model-based feedforward from given model dynamics.
If given the vector valued function as f(x, u) where x is the state vector and u is the input vector, the B matrix(continuous input matrix) is calculated through a NumericalJacobian. In this case f has to be control-affine (of the form f(x) + Bu).
The feedforward is calculated as u_ff = B+ (rDot - f(x)) , where B+ is the pseudoinverse of B.
This feedforward does not account for a dynamic B matrix, B is either determined or supplied when the feedforward is created and remains constant.
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::ControlAffinePlantInversionFeedforward< States, Inputs >::InputVector = Vectord<Inputs> |
using frc::ControlAffinePlantInversionFeedforward< States, Inputs >::StateVector = Vectord<States> |
|
inline |
Constructs a feedforward with given model dynamics as a function of state and input.
f | A vector-valued function of x, the state, and u, the input, that returns the derivative of the state vector. HAS to be control-affine (of the form f(x) + Bu). |
dt | The timestep between calls of calculate(). |
|
inline |
Constructs a feedforward with given model dynamics as a function of state, and the plant's B matrix(continuous input matrix).
f | A vector-valued function of x, the state, that returns the derivative of the state vector. |
B | Continuous input matrix of the plant being controlled. |
dt | The timestep between calls of calculate(). |
|
default |
|
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). |
|
default |
|
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. |