RIT VEXU Core API
Loading...
Searching...
No Matches
LinearPlantInversionFeedforward< STATES, INPUTS > Class Template Reference

#include <linear_plant_inversion_feedforward.h>

Public Member Functions

template<int OUTPUTS>
 LinearPlantInversionFeedforward (LinearSystem< STATES, INPUTS, OUTPUTS > &plant, const double &dt)
 
 LinearPlantInversionFeedforward (const EMat< STATES, STATES > &A, const EMat< STATES, INPUTS > &B, const double &dt)
 
EVec< INPUTS > calculate (const EVec< STATES > &r, const EVec< STATES > &next_r)
 
EVec< INPUTS > calculate (const EVec< STATES > &next_r)
 
EVec< INPUTS > calculate (const EVec< STATES > &r, const EVec< STATES > &next_r, const double &dt)
 
EVec< INPUTS > calculate (const EVec< STATES > &next_r, const double &dt)
 
void reset (const EVec< STATES > &initial_state)
 
void reset ()
 
void set_r (const EVec< STATES > &r)
 

Detailed Description

template<int STATES, int INPUTS>
class LinearPlantInversionFeedforward< STATES, INPUTS >

This class computes a feedforward control input by inverting the discrete plant dynamics. A continuous linear system is provided, it is then discretized on some timestep, then the feedforward control input is computed to satisfy:

B_d * u_ff = next_state - A_d * current_state

Constructor & Destructor Documentation

◆ LinearPlantInversionFeedforward() [1/2]

template<int STATES, int INPUTS>
template<int OUTPUTS>
LinearPlantInversionFeedforward< STATES, INPUTS >::LinearPlantInversionFeedforward ( LinearSystem< STATES, INPUTS, OUTPUTS > & plant,
const double & dt )
inline

Constructs a feedforward given a plant and the nominal timestep.

Template Parameters
OUTPUTSThe number of outputs of the plant.
Parameters
plantThe linear system.
dtThe nominal timestep in seconds.

◆ LinearPlantInversionFeedforward() [2/2]

template<int STATES, int INPUTS>
LinearPlantInversionFeedforward< STATES, INPUTS >::LinearPlantInversionFeedforward ( const EMat< STATES, STATES > & A,
const EMat< STATES, INPUTS > & B,
const double & dt )
inline

Construts a feedforward given the state and input matrices from a plant.

Parameters
AThe state matrix of the linear system.
BThe input matrix of the linear system.
dtThe nominal timestep in seconds.

Member Function Documentation

◆ calculate() [1/4]

template<int STATES, int INPUTS>
EVec< INPUTS > LinearPlantInversionFeedforward< STATES, INPUTS >::calculate ( const EVec< STATES > & next_r)
inline

Computes the feedforward control input given only the next reference state. This assumes that the previous reference is already set.

Parameters
next_rThe next reference state.

◆ calculate() [2/4]

template<int STATES, int INPUTS>
EVec< INPUTS > LinearPlantInversionFeedforward< STATES, INPUTS >::calculate ( const EVec< STATES > & next_r,
const double & dt )
inline

Computes the feedforward control input given only the next reference state. This assumes that the previous reference is already set.

This is slower because it discretizes A and B on each run, requiring computing a matrix exponential. Don't use this unless you have to.

Parameters
next_rThe next reference state.
dtThe timestep for this run.

◆ calculate() [3/4]

template<int STATES, int INPUTS>
EVec< INPUTS > LinearPlantInversionFeedforward< STATES, INPUTS >::calculate ( const EVec< STATES > & r,
const EVec< STATES > & next_r )
inline

Computes the feedforward control input given the current reference state and the next reference state. This also sets the current reference state to the next reference state for you.

Parameters
rThe current reference state.
next_rThe next reference state.

◆ calculate() [4/4]

template<int STATES, int INPUTS>
EVec< INPUTS > LinearPlantInversionFeedforward< STATES, INPUTS >::calculate ( const EVec< STATES > & r,
const EVec< STATES > & next_r,
const double & dt )
inline

Computes the feedforward control input given the current reference state and the next reference state. This also sets the current reference state to the next reference state for you. Use this function if your timestep is not the same between each run.

This is slower because it discretizes A and B on each run, requiring computing a matrix exponential. Don't use this unless you have to.

Parameters
rThe current reference state.
next_rThe next reference state.
dtThe timestep for this run.

◆ reset() [1/2]

template<int STATES, int INPUTS>
void LinearPlantInversionFeedforward< STATES, INPUTS >::reset ( )
inline

Resets the reference to all zeros, and the feedforward to zero.

◆ reset() [2/2]

template<int STATES, int INPUTS>
void LinearPlantInversionFeedforward< STATES, INPUTS >::reset ( const EVec< STATES > & initial_state)
inline

Resets the reference to the given state, and the feedforward to zero.

Parameters
initial_stateThe state to set the current reference to.

◆ set_r()

template<int STATES, int INPUTS>
void LinearPlantInversionFeedforward< STATES, INPUTS >::set_r ( const EVec< STATES > & r)
inline

Sets the current reference to a given state.

Parameters
rThe state to set the current reference to.

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