Brick
Loading...
Searching...
No Matches
LinearPlantInversionFeedforward< STATES, INPUTS > Class Template Reference

#include <linear_plant_inversion_ff.h>

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

Inheritance diagram for LinearPlantInversionFeedforward< STATES, INPUTS >:

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) override
EVec< INPUTS > calculate (const EVec< STATES > &r, const EVec< STATES > &next_r, const units::Time &dt)
EVec< INPUTS > calculate (const EVec< STATES > &next_r, const units::Time &dt)
void reset (const EVec< STATES > &initial_state)
void reset () override
 Resets the reference to all zeros, and the feedforward to zero.
Public Member Functions inherited from FeedForward< EVec< STATES >, EVec< INPUTS > >
EVec< INPUTS > get_output ()
 Gets the last saved output value.
EVec< STATES > get_reference ()
 Gets the currently stored reference state.

Additional Inherited Members

Public Attributes inherited from FeedForward< EVec< STATES >, EVec< INPUTS > >
EVec< INPUTS > output_min_
EVec< INPUTS > output_max_
Protected Attributes inherited from FeedForward< EVec< STATES >, EVec< INPUTS > >
EVec< STATES > reference_
EVec< INPUTS > output_

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)
inlineoverridevirtual

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.

Implements FeedForward< EVec< STATES >, EVec< INPUTS > >.

◆ calculate() [2/4]

template<int STATES, int INPUTS>
EVec< INPUTS > LinearPlantInversionFeedforward< STATES, INPUTS >::calculate ( const EVec< STATES > & next_r,
const units::Time & 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 units::Time & 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 ( )
inlineoverridevirtual

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

Implements FeedForward< EVec< STATES >, EVec< INPUTS > >.

◆ 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.

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