WPILibC++ 2024.3.2
frc::LinearSystem< States, Inputs, Outputs > Class Template Reference

A plant defined using state-space notation. More...

#include <frc/system/LinearSystem.h>

Public Types

using StateVector = Vectord< States >
 
using InputVector = Vectord< Inputs >
 
using OutputVector = Vectord< Outputs >
 

Public Member Functions

 LinearSystem (const Matrixd< States, States > &A, const Matrixd< States, Inputs > &B, const Matrixd< Outputs, States > &C, const Matrixd< Outputs, Inputs > &D)
 Constructs a discrete plant with the given continuous system coefficients. More...
 
 LinearSystem (const LinearSystem &)=default
 
LinearSystemoperator= (const LinearSystem &)=default
 
 LinearSystem (LinearSystem &&)=default
 
LinearSystemoperator= (LinearSystem &&)=default
 
const Matrixd< States, States > & A () const
 Returns the system matrix A. More...
 
double A (int i, int j) const
 Returns an element of the system matrix A. More...
 
const Matrixd< States, Inputs > & B () const
 Returns the input matrix B. More...
 
double B (int i, int j) const
 Returns an element of the input matrix B. More...
 
const Matrixd< Outputs, States > & C () const
 Returns the output matrix C. More...
 
double C (int i, int j) const
 Returns an element of the output matrix C. More...
 
const Matrixd< Outputs, Inputs > & D () const
 Returns the feedthrough matrix D. More...
 
double D (int i, int j) const
 Returns an element of the feedthrough matrix D. More...
 
StateVector CalculateX (const StateVector &x, const InputVector &clampedU, units::second_t dt) const
 Computes the new x given the old x and the control input. More...
 
OutputVector CalculateY (const StateVector &x, const InputVector &clampedU) const
 Computes the new y given the control input. More...
 

Detailed Description

template<int States, int Inputs, int Outputs>
class frc::LinearSystem< States, Inputs, Outputs >

A plant defined using state-space notation.

A plant is a mathematical model of a system's dynamics.

For more on the underlying math, read https://file.tavsys.net/control/controls-engineering-in-frc.pdf.

Template Parameters
StatesNumber of states.
InputsNumber of inputs.
OutputsNumber of outputs.

Member Typedef Documentation

◆ InputVector

template<int States, int Inputs, int Outputs>
using frc::LinearSystem< States, Inputs, Outputs >::InputVector = Vectord<Inputs>

◆ OutputVector

template<int States, int Inputs, int Outputs>
using frc::LinearSystem< States, Inputs, Outputs >::OutputVector = Vectord<Outputs>

◆ StateVector

template<int States, int Inputs, int Outputs>
using frc::LinearSystem< States, Inputs, Outputs >::StateVector = Vectord<States>

Constructor & Destructor Documentation

◆ LinearSystem() [1/3]

template<int States, int Inputs, int Outputs>
frc::LinearSystem< States, Inputs, Outputs >::LinearSystem ( const Matrixd< States, States > &  A,
const Matrixd< States, Inputs > &  B,
const Matrixd< Outputs, States > &  C,
const Matrixd< Outputs, Inputs > &  D 
)
inline

Constructs a discrete plant with the given continuous system coefficients.

Parameters
ASystem matrix.
BInput matrix.
COutput matrix.
DFeedthrough matrix.
Exceptions
std::domain_errorif any matrix element isn't finite.

◆ LinearSystem() [2/3]

template<int States, int Inputs, int Outputs>
frc::LinearSystem< States, Inputs, Outputs >::LinearSystem ( const LinearSystem< States, Inputs, Outputs > &  )
default

◆ LinearSystem() [3/3]

template<int States, int Inputs, int Outputs>
frc::LinearSystem< States, Inputs, Outputs >::LinearSystem ( LinearSystem< States, Inputs, Outputs > &&  )
default

Member Function Documentation

◆ A() [1/2]

template<int States, int Inputs, int Outputs>
const Matrixd< States, States > & frc::LinearSystem< States, Inputs, Outputs >::A ( ) const
inline

Returns the system matrix A.

◆ A() [2/2]

template<int States, int Inputs, int Outputs>
double frc::LinearSystem< States, Inputs, Outputs >::A ( int  i,
int  j 
) const
inline

Returns an element of the system matrix A.

Parameters
iRow of A.
jColumn of A.

◆ B() [1/2]

template<int States, int Inputs, int Outputs>
const Matrixd< States, Inputs > & frc::LinearSystem< States, Inputs, Outputs >::B ( ) const
inline

Returns the input matrix B.

◆ B() [2/2]

template<int States, int Inputs, int Outputs>
double frc::LinearSystem< States, Inputs, Outputs >::B ( int  i,
int  j 
) const
inline

Returns an element of the input matrix B.

Parameters
iRow of B.
jColumn of B.

◆ C() [1/2]

template<int States, int Inputs, int Outputs>
const Matrixd< Outputs, States > & frc::LinearSystem< States, Inputs, Outputs >::C ( ) const
inline

Returns the output matrix C.

◆ C() [2/2]

template<int States, int Inputs, int Outputs>
double frc::LinearSystem< States, Inputs, Outputs >::C ( int  i,
int  j 
) const
inline

Returns an element of the output matrix C.

Parameters
iRow of C.
jColumn of C.

◆ CalculateX()

template<int States, int Inputs, int Outputs>
StateVector frc::LinearSystem< States, Inputs, Outputs >::CalculateX ( const StateVector x,
const InputVector clampedU,
units::second_t  dt 
) const
inline

Computes the new x given the old x and the control input.

This is used by state observers directly to run updates based on state estimate.

Parameters
xThe current state.
clampedUThe control input.
dtTimestep for model update.

◆ CalculateY()

template<int States, int Inputs, int Outputs>
OutputVector frc::LinearSystem< States, Inputs, Outputs >::CalculateY ( const StateVector x,
const InputVector clampedU 
) const
inline

Computes the new y given the control input.

This is used by state observers directly to run updates based on state estimate.

Parameters
xThe current state.
clampedUThe control input.

◆ D() [1/2]

template<int States, int Inputs, int Outputs>
const Matrixd< Outputs, Inputs > & frc::LinearSystem< States, Inputs, Outputs >::D ( ) const
inline

Returns the feedthrough matrix D.

◆ D() [2/2]

template<int States, int Inputs, int Outputs>
double frc::LinearSystem< States, Inputs, Outputs >::D ( int  i,
int  j 
) const
inline

Returns an element of the feedthrough matrix D.

Parameters
iRow of D.
jColumn of D.

◆ operator=() [1/2]

template<int States, int Inputs, int Outputs>
LinearSystem & frc::LinearSystem< States, Inputs, Outputs >::operator= ( const LinearSystem< States, Inputs, Outputs > &  )
default

◆ operator=() [2/2]

template<int States, int Inputs, int Outputs>
LinearSystem & frc::LinearSystem< States, Inputs, Outputs >::operator= ( LinearSystem< States, Inputs, Outputs > &&  )
default

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