- 3.0.2 core module.
LinearSystem.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
10 
11 
12 namespace ct {
13 namespace core {
14 
16 
22 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
23 class LinearSystem : public ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>
24 {
25 public:
26  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 
29  typedef typename Base::time_t time_t;
30 
33 
36 
38 
42  : ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(type)
43  {
44  }
45 
47  virtual ~LinearSystem(){};
48 
50  virtual LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>* clone() const override = 0;
51 
53 
63  virtual void computeControlledDynamics(const state_vector_t& state,
64  const time_t& t,
65  const control_vector_t& control,
66  state_vector_t& derivative) override
67  {
68  // x_dot(t) = A(x,u,t) * x(t) + B(x,u,t) * u(t)
69 
70  derivative = getDerivativeState(state, control, t) * state + getDerivativeControl(state, control, t) * control;
71  }
72 
74 
80  virtual const state_matrix_t& getDerivativeState(const state_vector_t& x,
81  const control_vector_t& u,
82  const time_t t = time_t(0.0)) = 0;
83 
85 
91  virtual const state_control_matrix_t& getDerivativeControl(const state_vector_t& x,
92  const control_vector_t& u,
93  const time_t t = time_t(0.0)) = 0;
94 
95 
109  virtual void getDerivatives(state_matrix_t& A,
110  state_control_matrix_t& B,
111  const state_vector_t& x,
112  const control_vector_t& u,
113  const time_t t = time_t(0.0))
114  {
115  A = getDerivativeState(x, u, t);
116  B = getDerivativeControl(x, u, t);
117  }
118 };
119 
120 } // namespace core
121 } // namespace ct
interface class for a general linear system or linearized system
Definition: LinearSystem.h:23
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > Base
Definition: LinearSystem.h:28
ct::core::ControlVector< control_dim > u
LinearSystem(const ct::core::SYSTEM_TYPE &type=ct::core::SYSTEM_TYPE::GENERAL)
default constructor
Definition: LinearSystem.h:41
Definition: StateMatrix.h:12
clear all close all load ct GNMSLog0 mat reformat t
virtual const state_matrix_t & getDerivativeState(const state_vector_t &x, const control_vector_t &u, const time_t t=time_t(0.0))=0
get the A matrix of a linear system
Base::time_t time_t
Definition: LinearSystem.h:29
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.
Definition: LinearSystem.h:109
Definition: ControlVector.h:12
virtual LinearSystem< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override=0
deep cloning
CppAD::AD< CppAD::cg::CG< double > > SCALAR
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
Definition: LinearSystem.h:63
virtual const state_control_matrix_t & getDerivativeControl(const state_vector_t &x, const control_vector_t &u, const time_t t=time_t(0.0))=0
get the B matrix of a linear system
Definition: StateVector.h:12
StateVector< STATE_DIM, SCALAR > state_vector_t
state vector type
Definition: LinearSystem.h:31
ct::core::StateVector< state_dim > x
StateMatrix< STATE_DIM, SCALAR > state_matrix_t
state Jacobian type
Definition: LinearSystem.h:34
SYSTEM_TYPE
type of system
Definition: System.h:15
StateControlMatrix< STATE_DIM, CONTROL_DIM, SCALAR > state_control_matrix_t
input Jacobian type
Definition: LinearSystem.h:35
any non-specific system
Definition: System.h:17
virtual ~LinearSystem()
destructor
Definition: LinearSystem.h:47
ControlVector< CONTROL_DIM, SCALAR > control_vector_t
input vector type
Definition: LinearSystem.h:32
Definition: StateControlMatrix.h:12
A general, non-linear dynamic system with a control input.
Definition: ControlledSystem.h:46