- 3.0.2 core module.
ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR > Class Template Reference

Computes the linearization of a general non-linear ControlledSystem using numerical differentiation. More...

#include <SystemLinearizer.h>

Inheritance diagram for ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >:
ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR > ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > ct::core::System< STATE_DIM, SCALAR >

Public Types

typedef Base::time_t time_t
 Time type as defined in System. More...
 
typedef Base::state_vector_t state_vector_t
 state vector type More...
 
typedef Base::control_vector_t control_vector_t
 input vector type More...
 
typedef Base::state_matrix_t state_matrix_t
 state Jacobian type More...
 
typedef Base::state_control_matrix_t state_control_matrix_t
 input Jacobian type More...
 
typedef ControlledSystem< STATE_DIM, CONTROL_DIM, SCALARsystem_t
 type of system to be linearized More...
 
- Public Types inherited from ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >
typedef Base::time_t time_t
 
typedef StateVector< STATE_DIM, SCALARstate_vector_t
 state vector type More...
 
typedef ControlVector< CONTROL_DIM, SCALARcontrol_vector_t
 input vector type More...
 
typedef StateMatrix< STATE_DIM, SCALARstate_matrix_t
 state Jacobian type More...
 
typedef StateControlMatrix< STATE_DIM, CONTROL_DIM, SCALARstate_control_matrix_t
 input Jacobian type More...
 
- Public Types inherited from ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR >
typedef std::shared_ptr< ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > Ptr
 
typedef Base::time_t time_t
 
- Public Types inherited from ct::core::System< STATE_DIM, SCALAR >
typedef SCALAR time_t
 the type of the time variable More...
 

Public Member Functions

 SystemLinearizer (std::shared_ptr< system_t > nonlinearSystem, bool doubleSidedDerivative=true)
 default constructor More...
 
 SystemLinearizer (const SystemLinearizer &arg)
 copy constructor More...
 
virtual ~SystemLinearizer ()
 destructor More...
 
SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR > * clone () const override
 deep cloning More...
 
virtual const state_matrix_tgetDerivativeState (const state_vector_t &x, const control_vector_t &u, const time_t t=0.0) override
 get the Jacobian with respect to the state More...
 
virtual const state_control_matrix_tgetDerivativeControl (const state_vector_t &x, const control_vector_t &u, const time_t t=0.0) override
 get the Jacobian with respect to the input More...
 
- Public Member Functions inherited from ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >
 LinearSystem (const ct::core::SYSTEM_TYPE &type=ct::core::SYSTEM_TYPE::GENERAL)
 default constructor More...
 
virtual ~LinearSystem ()
 destructor More...
 
virtual void computeControlledDynamics (const state_vector_t &state, const time_t &t, const control_vector_t &control, state_vector_t &derivative) override
 compute the system dynamics More...
 
virtual void getDerivatives (state_matrix_t &A, state_control_matrix_t &B, const state_vector_t &x, const control_vector_t &u, const time_t t=time_t(0.0))
 Get both linear system matrices A and B in one call. More...
 
- Public Member Functions inherited from ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR >
 ControlledSystem (const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
 default constructor More...
 
 ControlledSystem (std::shared_ptr< ct::core::Controller< STATE_DIM, CONTROL_DIM, SCALAR >> controller, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
 constructor More...
 
 ControlledSystem (const ControlledSystem &arg)
 copy constructor More...
 
virtual ~ControlledSystem ()
 destructor More...
 
void setController (const std::shared_ptr< Controller< STATE_DIM, CONTROL_DIM, SCALAR >> &controller)
 set a new controller More...
 
void getController (std::shared_ptr< Controller< STATE_DIM, CONTROL_DIM, SCALAR >> &controller) const
 get the controller instance More...
 
std::shared_ptr< Controller< STATE_DIM, CONTROL_DIM, SCALAR > > getController ()
 get the controller instace More...
 
virtual void computeDynamics (const StateVector< STATE_DIM, SCALAR > &state, const time_t &t, StateVector< STATE_DIM, SCALAR > &derivative) override
 compute the dynamics of the system More...
 
virtual void computeControlledDynamics (const StateVector< STATE_DIM, SCALAR > &state, const time_t &t, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< STATE_DIM, SCALAR > &derivative)=0
 
ControlVector< CONTROL_DIM, SCALARgetLastControlAction ()
 
- Public Member Functions inherited from ct::core::System< STATE_DIM, SCALAR >
 System (const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
 default constructor More...
 
 System (const System &other)
 copy constructor More...
 
virtual ~System ()
 destructor More...
 
virtual void computeDynamics (const StateVector< STATE_DIM, SCALAR > &state, const time_t &t, StateVector< STATE_DIM, SCALAR > &derivative)=0
 computes the system dynamics More...
 
SYSTEM_TYPE getType () const
 get the type of system More...
 
virtual bool isSymplectic () const
 Determines if the system is in symplectic form. More...
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef LinearSystem< STATE_DIM, CONTROL_DIM, SCALARBase
 Base class type. More...
 
- Public Attributes inherited from ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ControlledSystem< STATE_DIM, CONTROL_DIM, SCALARBase
 
- Public Attributes inherited from ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef System< STATE_DIM, SCALARBase
 
- Public Attributes inherited from ct::core::System< STATE_DIM, SCALAR >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef SCALAR S
 the scalar type More...
 

Protected Attributes

std::shared_ptr< system_tnonlinearSystem_
 instance of non-linear system More...
 
DynamicsLinearizerNumDiff< STATE_DIM, CONTROL_DIM, SCALAR, SCALARlinearizer_
 instance of numerical-linearizer More...
 
state_matrix_t dFdx_
 Jacobian wrt state. More...
 
state_control_matrix_t dFdu_
 Jacobian wrt input. More...
 
bool isSecondOrderSystem_
 flag if system is a second order system More...
 
- Protected Attributes inherited from ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR >
std::shared_ptr< Controller< STATE_DIM, CONTROL_DIM, SCALAR > > controller_
 the controller instance More...
 
ControlVector< CONTROL_DIM, SCALARcontrolAction_
 
- Protected Attributes inherited from ct::core::System< STATE_DIM, SCALAR >
SYSTEM_TYPE type_
 type of system More...
 

Detailed Description

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
class ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >

Computes the linearization of a general non-linear ControlledSystem using numerical differentiation.

This class takes a non-linear ControlledSystem $ \dot{x} = f(x,u,t) $ and computes the linearization around a certain point $ x = x_s $, $ u = u_s $.

\[ \dot{x} = A x + B u \]

where

\[ \begin{aligned} A &= \frac{df}{dx} |_{x=x_s, u=u_s} \\ B &= \frac{df}{du} |_{x=x_s, u=u_s} \end{aligned} \]

In case the ControlledSystem is a pure second-order system, the upper half of A is not explicitely computed but A is assumed to be of the following form

\[ A = \begin{bmatrix} 0 & I \\ ... & ... \end{bmatrix} \]

Examples for using the SystemLinearizer (and the Auto-diff Linearizer) can be found in AutoDiffLinearizerTest.cpp

Note
In case your ControlledSystem is templated on scalar type, we suggest using the ADCodegenLinearizer for highest efficiency and accuracy. If this is not the case but your system is a RigidBodySystem you can fall back to the ct::rbd::RBDLinearizer for good accuracy and speed.
Template Parameters
STATE_DIMdimension of state vector
CONTROL_DIMdimension of control vector
SCALARunderlying scalar type of the system
Examples:
AutoDiffLinearizerTest.cpp.

Member Typedef Documentation

◆ time_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef Base::time_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::time_t

Time type as defined in System.

◆ state_vector_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef Base::state_vector_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::state_vector_t

state vector type

◆ control_vector_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef Base::control_vector_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::control_vector_t

input vector type

◆ state_matrix_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef Base::state_matrix_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::state_matrix_t

state Jacobian type

◆ state_control_matrix_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef Base::state_control_matrix_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::state_control_matrix_t

input Jacobian type

◆ system_t

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
typedef ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR> ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::system_t

type of system to be linearized

Constructor & Destructor Documentation

◆ SystemLinearizer() [1/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::SystemLinearizer ( std::shared_ptr< system_t nonlinearSystem,
bool  doubleSidedDerivative = true 
)
inline

default constructor

Initializes the linearizer with a non-linear system.

Parameters
nonlinearSystemnon-linear system to linearize
doubleSidedDerivativeif true, double sided numerical differentiation is used

References ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdu_, ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdx_, ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::isSecondOrderSystem_, and ct::core::SECOND_ORDER.

◆ SystemLinearizer() [2/2]

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::SystemLinearizer ( const SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR > &  arg)
inline

copy constructor

◆ ~SystemLinearizer()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
virtual ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::~SystemLinearizer ( )
inlinevirtual

destructor

Member Function Documentation

◆ clone()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
SystemLinearizer<STATE_DIM, CONTROL_DIM, SCALAR>* ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::clone ( ) const
inlineoverridevirtual

deep cloning

Implements ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >.

Referenced by TEST().

◆ getDerivativeState()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
virtual const state_matrix_t& ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::getDerivativeState ( const state_vector_t x,
const control_vector_t u,
const time_t  t = 0.0 
)
inlineoverridevirtual

get the Jacobian with respect to the state

This computes the linearization of the system with respect to the state at a given point $ x=x_s $, $ u=u_s $, i.e. it computes

\[ A = \frac{df}{dx} |_{x=x_s, u=u_s} \]

Parameters
xstate to linearize at
ucontrol to linearize at
ttime
Returns
Jacobian wrt state

Implements ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >.

References ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdx_, ct::core::DynamicsLinearizerNumDiff< STATE_DIM, CONTROL_DIM, SCALAR, TIME >::getDerivativeState(), ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::isSecondOrderSystem_, ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::linearizer_, and t.

Referenced by TEST().

◆ getDerivativeControl()

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
virtual const state_control_matrix_t& ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::getDerivativeControl ( const state_vector_t x,
const control_vector_t u,
const time_t  t = 0.0 
)
inlineoverridevirtual

get the Jacobian with respect to the input

This computes the linearization of the system with respect to the input at a given point $ x=x_s $, $ u=u_s $, i.e. it computes

\[ B = \frac{df}{du} |_{x=x_s, u=u_s} \]

Parameters
xstate to linearize at
ucontrol to linearize at
ttime
Returns
Jacobian wrt input

Implements ct::core::LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR >.

References ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdu_, ct::core::DynamicsLinearizerNumDiff< STATE_DIM, CONTROL_DIM, SCALAR, TIME >::getDerivativeControl(), ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::isSecondOrderSystem_, ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::linearizer_, and t.

Referenced by TEST().

Member Data Documentation

◆ Base

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR> ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::Base

Base class type.

◆ nonlinearSystem_

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
std::shared_ptr<system_t> ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::nonlinearSystem_
protected

instance of non-linear system

◆ linearizer_

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
DynamicsLinearizerNumDiff<STATE_DIM, CONTROL_DIM, SCALAR, SCALAR> ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::linearizer_
protected

◆ dFdx_

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
state_matrix_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdx_
protected

◆ dFdu_

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
state_control_matrix_t ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::dFdu_
protected

◆ isSecondOrderSystem_

template<size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
bool ct::core::SystemLinearizer< STATE_DIM, CONTROL_DIM, SCALAR >::isSecondOrderSystem_
protected

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