- 3.0.2 core module.
TestSymplecticSystem.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 #include <cmath>
9 #include <memory>
10 #include <iostream>
11 
12 namespace ct {
13 namespace core {
14 namespace tpl {
15 
19 template <typename SCALAR>
20 class TestSymplecticSystem : public SymplecticSystem<1, 1, 1, SCALAR>
21 {
22 public:
23  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
24 
25  static const size_t STATE_DIM = 2;
26  static const size_t CONTROL_DIM = 1;
27  static const size_t POS_DIM = 1;
28  static const size_t VEL_DIM = 1;
29 
30  TestSymplecticSystem() = delete;
31 
32  // constructor directly using frequency and damping coefficients
33  TestSymplecticSystem(SCALAR w_n, std::shared_ptr<Controller<2, 1, SCALAR>> controller = nullptr)
34  : SymplecticSystem<1, 1, 1, SCALAR>(controller), w_n_(w_n)
35  {
36  }
37 
38  TestSymplecticSystem(const TestSymplecticSystem& arg) : SymplecticSystem<1, 1, 1, SCALAR>(arg), w_n_(arg.w_n_) {}
39 
40  virtual ~TestSymplecticSystem() = default;
41 
42  TestSymplecticSystem* clone() const override { return new TestSymplecticSystem(*this); }
43 
48  StateVector<POS_DIM, SCALAR>& pDot) override
49  {
50  pDot(0) = v(0);
51  }
52 
57  StateVector<VEL_DIM, SCALAR>& vDot) override
58  {
59  vDot(0) = control(0) - w_n_ * w_n_ * p(0);
60  }
61 
62 private:
63  SCALAR w_n_;
64 };
65 
66 } // namespace tpl
67 
69 
70 } // namespace core
71 } // namespace ct
static const size_t CONTROL_DIM
Definition: TestSymplecticSystem.h:26
TestSymplecticSystem(const TestSymplecticSystem &arg)
Definition: TestSymplecticSystem.h:38
static EIGEN_MAKE_ALIGNED_OPERATOR_NEW const size_t STATE_DIM
Definition: TestSymplecticSystem.h:25
TestSymplecticSystem * clone() const override
Creates a new instance of the object with same properties than original.
Definition: TestSymplecticSystem.h:42
virtual void computeVdot(const StateVector< POS_DIM+VEL_DIM, SCALAR > &x, const StateVector< POS_DIM, SCALAR > &p, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< VEL_DIM, SCALAR > &vDot) override
need to override this method for a symplectic system
Definition: TestSymplecticSystem.h:54
Definition: ControlVector.h:12
CppAD::AD< CppAD::cg::CG< double > > SCALAR
TestSymplecticSystem(SCALAR w_n, std::shared_ptr< Controller< 2, 1, SCALAR >> controller=nullptr)
Definition: TestSymplecticSystem.h:33
virtual void computePdot(const StateVector< POS_DIM+VEL_DIM, SCALAR > &x, const StateVector< VEL_DIM, SCALAR > &v, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< POS_DIM, SCALAR > &pDot) override
need to override this method for a symplectic system
Definition: TestSymplecticSystem.h:45
Definition: TestSymplecticSystem.h:20
virtual ~TestSymplecticSystem()=default
The base class for the implementation of a symplectic system. In a symplectic system, the position and the velocity update can be separated. During integration, the velocity gets update first and the position update uses the updated velocity.
Definition: SymplecticSystem.h:25
static const size_t POS_DIM
Definition: TestSymplecticSystem.h:27
static const size_t VEL_DIM
Definition: TestSymplecticSystem.h:28
Interface class for all controllers.
Definition: Controller.h:26