- 3.0.2 core module.
DiscreteLinearSystem.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 DiscreteLinearSystem : public DiscreteControlledSystem<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  : DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(type)
43  {
44  }
45 
47  virtual ~DiscreteLinearSystem(){};
48 
50  virtual DiscreteLinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>* clone() const override = 0;
51 
53 
63  virtual void propagateControlledDynamics(const state_vector_t& state,
64  const time_t n,
65  const control_vector_t& control,
66  state_vector_t& stateNext) override
67  {
68  state_matrix_t A;
69  state_control_matrix_t B;
70  this->getAandB(state, control, state, n, 1, A, B);
71  stateNext = A * state + B * control;
72  }
73 
74 
76 
94  virtual void getAandB(const state_vector_t& x,
95  const control_vector_t& u,
96  const state_vector_t& x_next,
97  const int n,
98  size_t subSteps,
99  state_matrix_t& A,
100  state_control_matrix_t& B) = 0;
101 
102  void getAandB(const state_vector_t& x,
103  const control_vector_t& u,
104  const int n,
105  state_matrix_t& A,
106  state_control_matrix_t& B)
107  {
108  getAandB(x, u, x, n, 1, A, B);
109  }
110 };
111 
112 } // namespace core
113 } // namespace ct
virtual ~DiscreteLinearSystem()
destructor
Definition: DiscreteLinearSystem.h:47
Base::time_t time_t
Definition: DiscreteLinearSystem.h:29
StateMatrix< STATE_DIM, SCALAR > state_matrix_t
state Jacobian type
Definition: DiscreteLinearSystem.h:34
ct::core::ControlVector< control_dim > u
interface class for a general discrete linear system or linearized discrete system ...
Definition: DiscreteLinearSystem.h:23
void getAandB(const state_vector_t &x, const control_vector_t &u, const int n, state_matrix_t &A, state_control_matrix_t &B)
Definition: DiscreteLinearSystem.h:102
virtual void propagateControlledDynamics(const state_vector_t &state, const time_t n, const control_vector_t &control, state_vector_t &stateNext) override
compute the system dynamics
Definition: DiscreteLinearSystem.h:63
Definition: StateMatrix.h:12
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef DiscreteControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > Base
Definition: DiscreteLinearSystem.h:28
A general, non-linear discrete dynamic system with a control input.
Definition: DiscreteControlledSystem.h:40
virtual void getAandB(const state_vector_t &x, const control_vector_t &u, const state_vector_t &x_next, const int n, size_t subSteps, state_matrix_t &A, state_control_matrix_t &B)=0
retrieve discrete-time linear system matrices A and B.
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual DiscreteLinearSystem< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override=0
deep cloning
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
Base::state_vector_t state_vector_t
Definition: DiscreteLinearSystem.h:31
ct::core::StateVector< state_dim > x
StateControlMatrix< STATE_DIM, CONTROL_DIM, SCALAR > state_control_matrix_t
input Jacobian type
Definition: DiscreteLinearSystem.h:35
SYSTEM_TYPE
type of system
Definition: System.h:15
any non-specific system
Definition: System.h:17
Base::control_vector_t control_vector_t
Definition: DiscreteLinearSystem.h:32
DiscreteLinearSystem(const ct::core::SYSTEM_TYPE &type=ct::core::SYSTEM_TYPE::GENERAL)
default constructor
Definition: DiscreteLinearSystem.h:41
int time_t
the type of the time variable
Definition: DiscreteSystem.h:15
Definition: StateControlMatrix.h:12