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
 States Number of states. Inputs Number of inputs. Outputs Number of outputs.

## ◆ InputVector

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

## ◆ OutputVector

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

## ◆ StateVector

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

## ◆ 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
 A System matrix. B Input matrix. C Output matrix. D Feedthrough matrix.
Exceptions
 std::domain_error if 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

## ◆ 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
 i Row of A. j Column 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
 i Row of B. j Column 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
 i Row of C. j Column 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
 x The current state. clampedU The control input. dt Timestep 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
 x The current state. clampedU The 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
 i Row of D. j Column 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: