- 3.0.2 optimal control module.
TestLinearSystem.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 
8 namespace ct {
9 namespace core {
10 
11 
12 namespace tpl {
13 
14 template <typename SCALAR>
15 class TestLinearSystem : public ControlledSystem<2, 1, SCALAR>
16 {
17 public:
19  static const size_t STATE_DIM = 2;
20  static const size_t CONTROL_DIM = 1;
21 
24  typedef typename Base::time_t time_t;
25 
28 
29  TestLinearSystem() = delete;
30 
31  // constructor directly using A and B
32  TestLinearSystem(state_matrix_t A,
33  state_control_matrix_t B,
34  std::shared_ptr<Controller<2, 1, SCALAR>> controller = nullptr)
35  : Base(controller, SYSTEM_TYPE::GENERAL), A_(A), B_(B)
36  {
37  }
38 
39  //copy constructor
40  TestLinearSystem(const TestLinearSystem& arg) : Base(arg), A_(arg.A_), B_(arg.B_) {}
41  virtual ~TestLinearSystem() {}
42  TestLinearSystem* clone() const override { return new TestLinearSystem(*this); }
44  const time_t& t,
46  StateVector<STATE_DIM, SCALAR>& derivative) override
47  {
48  derivative = A_ * state + B_ * control;
49  }
50 
51 private:
52  state_matrix_t A_;
53  state_control_matrix_t B_;
54 };
55 
56 } // namespace tpl
57 
59 
60 } // namespace core
61 } // namespace ct
ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: TestLinearSystem.h:23
StateMatrix< STATE_DIM, SCALAR > state_matrix_t
state Jacobian type
Definition: TestLinearSystem.h:26
virtual void computeControlledDynamics(const StateVector< STATE_DIM, SCALAR > &state, const time_t &t, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< STATE_DIM, SCALAR > &derivative) override
Definition: TestLinearSystem.h:43
TestLinearSystem(state_matrix_t A, state_control_matrix_t B, std::shared_ptr< Controller< 2, 1, SCALAR >> controller=nullptr)
Definition: TestLinearSystem.h:32
StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: TestLinearSystem.h:22
StateControlMatrix< STATE_DIM, CONTROL_DIM, SCALAR > state_control_matrix_t
input Jacobian type
Definition: TestLinearSystem.h:27
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
ControlledSystem< 2, 1, SCALAR > Base
Definition: TestLinearSystem.h:18
static const size_t STATE_DIM
Definition: TestLinearSystem.h:19
virtual ~TestLinearSystem()
Definition: TestLinearSystem.h:41
TestLinearSystem(const TestLinearSystem &arg)
Definition: TestLinearSystem.h:40
Definition: TestLinearSystem.h:15
TestLinearSystem * clone() const override
Definition: TestLinearSystem.h:42
Base::time_t time_t
Definition: TestLinearSystem.h:24
static const size_t CONTROL_DIM
Definition: TestLinearSystem.h:20