- 3.0.2 core module.
SymplecticSystem.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 "ControlledSystem.h"
9 
10 namespace ct {
11 namespace core {
12 
24 template <size_t POS_DIM, size_t VEL_DIM, size_t CONTROL_DIM, typename SCALAR = double>
25 class SymplecticSystem : public ControlledSystem<POS_DIM + VEL_DIM, CONTROL_DIM, SCALAR>
26 {
27 public:
28  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
30  typedef typename Base::time_t time_t;
31 
37  SymplecticSystem(const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL) : Base(type) {}
45  const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL)
46  : Base(controller, type)
47  {
48  }
49 
55  SymplecticSystem(const SymplecticSystem& arg) : ControlledSystem<POS_DIM + VEL_DIM, CONTROL_DIM, SCALAR>(arg) {}
59  virtual ~SymplecticSystem() {}
66 
67  virtual bool isSymplectic() const override { return true; }
69  const time_t& t,
71  StateVector<POS_DIM + VEL_DIM, SCALAR>& derivative) override
72  {
75 
76  computePdot(state, state.tail(VEL_DIM), control, pDot);
77  computeVdot(state, state.head(POS_DIM), control, vDot);
78 
79  derivative << pDot, vDot;
80  }
81 
82 
93  {
95  if (this->controller_)
96  this->controller_->computeControl(x, 0.0, controlAction);
97  else
98  controlAction.setZero();
99 
100  computePdot(x, v, controlAction, pDot);
101  }
102 
113  {
115  if (this->controller_)
116  this->controller_->computeControl(x, 0.0, controlAction);
117  else
118  controlAction.setZero();
119 
120  computeVdot(x, p, controlAction, vDot);
121  }
122 
123 
134  const ControlVector<CONTROL_DIM, SCALAR>& control,
135  StateVector<POS_DIM, SCALAR>& pDot) = 0;
136 
147  const ControlVector<CONTROL_DIM, SCALAR>& control,
148  StateVector<VEL_DIM, SCALAR>& vDot) = 0;
149 
150 protected:
151 };
152 
153 } // namespace core
154 } // namespace ct
void computePdot(const StateVector< POS_DIM+VEL_DIM, SCALAR > &x, const StateVector< VEL_DIM, SCALAR > &v, StateVector< POS_DIM, SCALAR > &pDot)
Computes the derivative of the position.
Definition: SymplecticSystem.h:90
virtual bool isSymplectic() const override
Determines if the system is in symplectic form.
Definition: SymplecticSystem.h:67
Definition: ControlVector.h:12
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void computeVdot(const StateVector< POS_DIM+VEL_DIM, SCALAR > &x, const StateVector< POS_DIM, SCALAR > &p, StateVector< VEL_DIM, SCALAR > &vDot)
Computes the derivative of the velocity.
Definition: SymplecticSystem.h:110
Base::time_t time_t
Definition: SymplecticSystem.h:30
SymplecticSystem(std::shared_ptr< ct::core::Controller< POS_DIM+VEL_DIM, CONTROL_DIM, SCALAR >> controller, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
Constructor.
Definition: SymplecticSystem.h:44
ct::core::StateVector< state_dim > x
SymplecticSystem(const SymplecticSystem &arg)
Copy constructor.
Definition: SymplecticSystem.h:55
std::shared_ptr< Controller< STATE_DIM, CONTROL_DIM, SCALAR > > controller_
the controller instance
Definition: ControlledSystem.h:145
virtual ~SymplecticSystem()
Destructor.
Definition: SymplecticSystem.h:59
SYSTEM_TYPE
type of system
Definition: System.h:15
any non-specific system
Definition: System.h:17
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ControlledSystem< POS_DIM+VEL_DIM, CONTROL_DIM, SCALAR > Base
Definition: SymplecticSystem.h:29
virtual void computeControlledDynamics(const StateVector< POS_DIM+VEL_DIM, SCALAR > &state, const time_t &t, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< POS_DIM+VEL_DIM, SCALAR > &derivative) override
Definition: SymplecticSystem.h:68
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
SymplecticSystem(const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
Constructor.
Definition: SymplecticSystem.h:37
virtual SymplecticSystem< POS_DIM, VEL_DIM, CONTROL_DIM, SCALAR > * clone() const override=0
Creates a new instance of the object with same properties than original.
A general, non-linear dynamic system with a control input.
Definition: ControlledSystem.h:46
Interface class for all controllers.
Definition: Controller.h:26