Lodestar
An integrated real-time control package in C++
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim > Class Template Reference
Inheritance diagram for ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >:
[legend]
Collaboration diagram for ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >:
[legend]

Public Types

typedef Eigen::Matrix< TScalar, TStateDim, TStateDim > TDStateMatrix
 
typedef Eigen::Matrix< TScalar, TStateDim, TInputDim > TDInputMatrix
 
typedef Eigen::Matrix< TScalar, TOutputDim, TStateDim > TDOutputMatrix
 
typedef Eigen::Matrix< TScalar, TOutputDim, TInputDim > TDFeedforwardMatrix
 

Public Member Functions

 StateSpace ()
 Default constructor.
 
 StateSpace (TDStateMatrix *A, TDInputMatrix *B, TDOutputMatrix *C, TDOutputMatrix *D)
 Construct a state space system with the given matrices. More...
 
template<typename DerivedA , typename DerivedB , typename DerivedC , typename DerivedD >
 StateSpace (const Eigen::EigenBase< DerivedA > &A, const Eigen::EigenBase< DerivedB > &B, const Eigen::EigenBase< DerivedC > &C, const Eigen::EigenBase< DerivedD > &D)
 
 StateSpace (const StateSpace &other)
 Copy constructor. More...
 
const TDStateMatrix & getA () const
 Gets the state matrix. More...
 
void setA (TDStateMatrix *A)
 Sets the state matrix. More...
 
template<typename Derived >
void setA (Eigen::EigenBase< Derived > *A)
 
void setA (const TDStateMatrix &A)
 Sets the state matrix. More...
 
template<typename Derived >
void setA (const Eigen::EigenBase< Derived > &A)
 
const TDInputMatrix & getB () const
 Gets the input matrix. More...
 
void setB (TDInputMatrix *B)
 Sets the input matrix. More...
 
template<typename Derived >
void setB (Eigen::EigenBase< Derived > *B)
 
void setB (const TDInputMatrix &B)
 Sets the input matrix. More...
 
template<typename Derived >
void setB (const Eigen::EigenBase< Derived > &B)
 
const TDOutputMatrix & getC () const
 Gets the output matrix. More...
 
void setC (TDOutputMatrix *C)
 Sets the output matrix. More...
 
template<typename Derived >
void setC (Eigen::EigenBase< Derived > *C)
 
void setC (const TDOutputMatrix &C)
 Sets the output matrix. More...
 
template<typename Derived >
void setC (const Eigen::EigenBase< Derived > &C)
 
const TDFeedforwardMatrix & getD () const
 Gets the feedforward matrix. More...
 
void setD (TDFeedforwardMatrix *D)
 Sets the feedforward matrix. More...
 
template<typename Derived >
void setD (Eigen::EigenBase< Derived > *D)
 
void setD (const TDFeedforwardMatrix &D)
 Sets the feedforward matrix. More...
 
template<typename Derived >
void setD (const Eigen::EigenBase< Derived > &D)
 
void copyMatrices (const StateSpace &other)
 Copies matrices from one state space object to the current instance. More...
 
void setDiscreteParams (double dt)
 Sets the discrete time system parameters. More...
 
void setDiscreteParams (double dt, bool discrete)
 Sets the discrete time system parameters. More...
 
bool isDiscrete () const
 Returns a bool that tells if the system is discrete. More...
 
double getSamplingPeriod () const
 Returns the sampling period. More...
 
void setSamplingPeriod (double dt)
 Sets the sampling period. More...
 
 stateDim () const
 Returns the state dimension. More...
 
long stateDimDynamic () const
 
 stateDim () const
 
long stateDimStatic () const
 
 inputDim () const
 Returns the input dimension. More...
 
long inputDimDynamic () const
 
 inputDim () const
 
long inputDimStatic () const
 
 outputDim () const
 Returns the output dimension. More...
 
long outputDimDynamic () const
 
 outputDim () const
 
long outputDimStatic () const
 
template<int TStateDim2, int TOutputDim2>
void append (const StateSpace< TScalar, TStateDim2, TOutputDim, TOutputDim2 > &ss)
 Appends to state space systems. More...
 
bool isStable (double tolerance=0) const
 Determines if the system is stable based on its eigenvalues. More...
 
template<typename T_TScalar = TScalar, const int T_TStateDim = TStateDim, const int T_TInputDim = TInputDim, const int T_TOutputDim = TOutputDim>
ls::systems::StateSpace< T_TScalar, LS_STATIC_UNLESS_DYNAMIC(T_TStateDim+T_TOutputDim), T_TInputDim, T_TOutputDim > addIntegralAction (LS_IS_DYNAMIC_DEFAULT(T_TStateDim, T_TInputDim, T_TOutputDim)) const
 Returns a state space representation that adds integral action to the original system. More...
 
template<typename T_TScalar = TScalar, const int T_TStateDim = TStateDim, const int T_TInputDim = TInputDim, const int T_TOutputDim = TOutputDim>
ls::systems::StateSpace< T_TScalar, LS_STATIC_UNLESS_DYNAMIC(T_TStateDim+T_TOutputDim), T_TInputDim, T_TOutputDim > addIntegralAction (LS_IS_STATIC_DEFAULT(T_TStateDim, T_TInputDim, T_TOutputDim)) const
 Returns a state space representation that adds integral action to the original system. More...
 
template<typename T_TScalar , const int T_TStateDim, const int T_TInputDim, const int T_TOutputDim>
ls::systems::StateSpace< T_TScalar, LS_STATIC_UNLESS_DYNAMIC(T_TStateDim+T_TOutputDim), T_TInputDim, T_TOutputDim > addIntegralAction (LS_IS_DYNAMIC(T_TStateDim, T_TInputDim, T_TOutputDim)) const
 
template<typename T_TScalar , const int T_TStateDim, const int T_TInputDim, const int T_TOutputDim>
ls::systems::StateSpace< T_TScalar, LS_STATIC_UNLESS_DYNAMIC(T_TStateDim+T_TOutputDim), T_TInputDim, T_TOutputDim > addIntegralAction (LS_IS_STATIC(T_TStateDim, T_TInputDim, T_TOutputDim)) const
 

Protected Attributes

TDStateMatrix * A_
 
TDInputMatrix * B_
 TState matrix.
 
TDOutputMatrix * C_
 Input matrix.
 
TDFeedforwardMatrix * D_
 Output matrix.
 
double dt_
 Feedforward matrix.
 
bool isDiscrete_
 Sampling period.
 

Constructor & Destructor Documentation

◆ StateSpace() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::StateSpace ( TDStateMatrix *  A,
TDInputMatrix *  B,
TDOutputMatrix *  C,
TDOutputMatrix *  D 
)

Construct a state space system with the given matrices.

Note
TState space systems are assumed to be in continuous time by default.
Parameters
APointer to state matrix.
BPointer to input matrix.
CPointer to output matrix.
DPointer to feedforward matrix.

◆ StateSpace() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::StateSpace ( const StateSpace< TScalar, TStateDim, TInputDim, TOutputDim > &  other)

Copy constructor.

Parameters
otherTState space object to copy.

Member Function Documentation

◆ addIntegralAction() [1/2]

template<typename TScalar = double, const int TStateDim = Eigen::Dynamic, const int TInputDim = Eigen::Dynamic, const int TOutputDim = Eigen::Dynamic>
template<typename T_TScalar = TScalar, const int T_TStateDim = TStateDim, const int T_TInputDim = TInputDim, const int T_TOutputDim = TOutputDim>
ls::systems::StateSpace<T_TScalar, LS_STATIC_UNLESS_DYNAMIC( T_TStateDim + T_TOutputDim), T_TInputDim, T_TOutputDim> ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::addIntegralAction ( LS_IS_DYNAMIC_DEFAULT(T_TStateDim, T_TInputDim, T_TOutputDim)  ) const

Returns a state space representation that adds integral action to the original system.

For details on the discrete time case, see [1].

See also
D. D. Ruscio, “Discrete LQ optimal control with integral action: A simple controller on incremental form for MIMO systems,” MIC, vol. 33, no. 2, pp. 35–44, 2012, doi: 10.4173/mic.2012.2.1.
Note
This particular function gets called when the state space system is dynamic.
Template Parameters
T_TScalarCopy of TScalar.
T_TStateDimCopy of TStateDim.
T_TInputDimCopy of TInputDim.
T_TOutputDimCopy of TOutputDim.
Returns
State space system augmented with integral action.

◆ addIntegralAction() [2/2]

template<typename TScalar = double, const int TStateDim = Eigen::Dynamic, const int TInputDim = Eigen::Dynamic, const int TOutputDim = Eigen::Dynamic>
template<typename T_TScalar = TScalar, const int T_TStateDim = TStateDim, const int T_TInputDim = TInputDim, const int T_TOutputDim = TOutputDim>
ls::systems::StateSpace<T_TScalar, LS_STATIC_UNLESS_DYNAMIC( T_TStateDim + T_TOutputDim), T_TInputDim, T_TOutputDim> ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::addIntegralAction ( LS_IS_STATIC_DEFAULT(T_TStateDim, T_TInputDim, T_TOutputDim)  ) const

Returns a state space representation that adds integral action to the original system.

For details on the discrete time case, see [1].

See also
[1] D. D. Ruscio, “Discrete LQ optimal control with integral action: A simple controller on incremental form for MIMO systems,” MIC, vol. 33, no. 2, pp. 35–44, 2012, doi: 10.4173/mic.2012.2.1.
Note
This particular function gets called when the state space system is static.
Template Parameters
T_TScalarCopy of TScalar.
T_TStateDimCopy of TStateDim.
T_TInputDimCopy of TInputDim.
T_TOutputDimCopy of TOutputDim.
Returns
State space system augmented with integral action.

◆ append()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
template<int TStateDim2, int TOutputDim2>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::append ( const StateSpace< TScalar, TStateDim2, TOutputDim, TOutputDim2 > &  ss)

Appends to state space systems.

If the discrete time parameters do not match the current system, the input system is altered to match the current system.

Parameters
ssTState space system to append.

◆ copyMatrices()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::copyMatrices ( const StateSpace< TScalar, TStateDim, TInputDim, TOutputDim > &  other)

Copies matrices from one state space object to the current instance.

Parameters
ssTState space object to copy matrices from.

◆ getA()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
const ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::TDStateMatrix & ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::getA

Gets the state matrix.

Returns
TState matrix.

◆ getB()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
const ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::TDInputMatrix & ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::getB

Gets the input matrix.

Returns
Input matrix.

◆ getC()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
const ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::TDOutputMatrix & ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::getC

Gets the output matrix.

Returns
Output matrix.

◆ getD()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
const ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::TDFeedforwardMatrix & ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::getD

Gets the feedforward matrix.

Returns
Feedforward matrix.

◆ getSamplingPeriod()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
double ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::getSamplingPeriod
inline

Returns the sampling period.

Returns
Sampling period.

◆ inputDim()

template<typename TScalar = double, const int TStateDim = Eigen::Dynamic, const int TInputDim = Eigen::Dynamic, const int TOutputDim = Eigen::Dynamic>
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::inputDim ( ) const
inline

Returns the input dimension.

Returns
Input dimension.

◆ isDiscrete()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
bool ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::isDiscrete
inline

Returns a bool that tells if the system is discrete.

Returns
True if the system is discrete.

◆ isStable()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
bool ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::isStable ( double  tolerance = 0) const
inline

Determines if the system is stable based on its eigenvalues.

tolerance sets the stability margin that is taken into account during computation.

Parameters
toleranceEigenvalue tolerance.
Returns
True if system is stable.

◆ outputDim()

template<typename TScalar = double, const int TStateDim = Eigen::Dynamic, const int TInputDim = Eigen::Dynamic, const int TOutputDim = Eigen::Dynamic>
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::outputDim ( ) const
inline

Returns the output dimension.

Returns
Output dimension

◆ setA() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setA ( const TDStateMatrix &  A)

Sets the state matrix.

Parameters
ATState matrix.

◆ setA() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setA ( TDStateMatrix *  A)

Sets the state matrix.

Parameters
APointer to state matrix.

◆ setB() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setB ( const TDInputMatrix &  B)

Sets the input matrix.

Parameters
BInput matrix.

◆ setB() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setB ( TDInputMatrix *  B)

Sets the input matrix.

Parameters
BPointer to input matrix.

◆ setC() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setC ( const TDOutputMatrix &  C)

Sets the output matrix.

Parameters
COutput matrix.

◆ setC() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setC ( TDOutputMatrix *  C)

Sets the output matrix.

Parameters
CPointer to output matrix.

◆ setD() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setD ( const TDFeedforwardMatrix &  D)

Sets the feedforward matrix.

Parameters
DPointer to feedforward matrix.

◆ setD() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setD ( TDFeedforwardMatrix *  D)

Sets the feedforward matrix.

Parameters
DFeedforward matrix.

◆ setDiscreteParams() [1/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setDiscreteParams ( double  dt)

Sets the discrete time system parameters.

Parameters
dtSampling period.

◆ setDiscreteParams() [2/2]

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setDiscreteParams ( double  dt,
bool  discrete 
)

Sets the discrete time system parameters.

Parameters
dtSampling period.
discreteIf true, the system is treated as a discrete time system.

◆ setSamplingPeriod()

template<typename TScalar , int TStateDim, int TInputDim, int TOutputDim>
void ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::setSamplingPeriod ( double  dt)

Sets the sampling period.

Parameters
dtSampling period.

◆ stateDim()

template<typename TScalar = double, const int TStateDim = Eigen::Dynamic, const int TInputDim = Eigen::Dynamic, const int TOutputDim = Eigen::Dynamic>
ls::systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim >::stateDim ( ) const
inline

Returns the state dimension.

Returns
TState dimension.

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