- 3.0.2 core module.
IntegratorSymplectic.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 <type_traits>
9 #include <functional>
10 #include <cmath>
11 
12 #include <boost/numeric/odeint.hpp>
13 
14 #include "eigenIntegration.h"
15 
17 
19 
20 
21 namespace ct {
22 namespace core {
23 
33 template <size_t POS_DIM, size_t VEL_DIM, size_t CONTROL_DIM, class Stepper, typename SCALAR = double>
35 {
36 public:
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38  typedef typename std::pair<Eigen::Matrix<SCALAR, POS_DIM, 1>, Eigen::Matrix<SCALAR, VEL_DIM, 1>> pair_t;
39 
40  typedef std::shared_ptr<EventHandler<POS_DIM + VEL_DIM, SCALAR>> EventHandlerPtr;
41  typedef std::vector<EventHandlerPtr, Eigen::aligned_allocator<EventHandlerPtr>> EventHandlerPtrVector;
42 
43 
51  const EventHandlerPtrVector& eventHandlers = EventHandlerPtrVector(0));
52 
60  const EventHandlerPtr& eventHandler);
61 
62 
76  const SCALAR& startTime,
77  size_t numSteps,
78  SCALAR dt,
80  tpl::TimeArray<SCALAR>& timeTrajectory);
81 
93  const SCALAR& startTime,
94  size_t numSteps,
95  SCALAR dt);
96 
97  void reset();
98 
99 private:
104  void setupSystem();
106 
107  std::function<void(const Eigen::Matrix<SCALAR, POS_DIM, 1>&, Eigen::Matrix<SCALAR, POS_DIM, 1>&)>
108  systemFunctionPosition_;
109  std::function<void(const Eigen::Matrix<SCALAR, VEL_DIM, 1>&, Eigen::Matrix<SCALAR, VEL_DIM, 1>&)>
110  systemFunctionVelocity_;
111 
112  std::shared_ptr<SymplecticSystem<POS_DIM, VEL_DIM, CONTROL_DIM, SCALAR>> systemSymplectic_;
113 
114  Stepper stepper_;
115 
117 };
118 
119 
120 /*******************************************************************
121  * Defining the integrators
122  *******************************************************************/
123 
124 template <size_t POS_DIM, size_t VEL_DIM, size_t CONTROL_DIM, typename SCALAR = double>
127 
128 template <size_t POS_DIM, size_t VEL_DIM, size_t CONTROL_DIM, typename SCALAR = double>
131 }
132 }
std::vector< EventHandlerPtr, Eigen::aligned_allocator< EventHandlerPtr > > EventHandlerPtrVector
Definition: IntegratorSymplectic.h:41
An discrete array (vector) of a particular data type.
Definition: DiscreteArray.h:22
void reset()
Definition: IntegratorSymplectic-impl.h:83
std::shared_ptr< EventHandler< POS_DIM+VEL_DIM, SCALAR > > EventHandlerPtr
Definition: IntegratorSymplectic.h:40
void integrate_n_steps(StateVector< POS_DIM+VEL_DIM, SCALAR > &state, const SCALAR &startTime, size_t numSteps, SCALAR dt, StateVectorArray< POS_DIM+VEL_DIM, SCALAR > &stateTrajectory, tpl::TimeArray< SCALAR > &timeTrajectory)
Equidistant integration based on number of time steps and step length.
Definition: IntegratorSymplectic-impl.h:32
CppAD::AD< CppAD::cg::CG< double > > SCALAR
An array in time.
Definition: TimeArray.h:22
This class wraps the symplectic integrators from boost to this toolbox.
Definition: IntegratorSymplectic.h:34
IntegratorSymplectic(const std::shared_ptr< SymplecticSystem< POS_DIM, VEL_DIM, CONTROL_DIM, SCALAR >> system, const EventHandlerPtrVector &eventHandlers=EventHandlerPtrVector(0))
The constructor. This integrator can only treat symplectic systems.
Definition: IntegratorSymplectic-impl.h:13
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
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::pair< Eigen::Matrix< SCALAR, POS_DIM, 1 >, Eigen::Matrix< SCALAR, VEL_DIM, 1 > > pair_t
Definition: IntegratorSymplectic.h:38