- 3.0.2 core module.
StepperBase.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 namespace internal {
11 
19 template <typename MATRIX, typename SCALAR = double>
21 {
22 public:
23  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
24 
26  virtual ~StepperBase() {}
36  virtual void integrate_n_steps(const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
37  MATRIX& state,
38  const SCALAR& startTime,
39  size_t numSteps,
40  SCALAR dt)
41  {
42  throw std::runtime_error("Integrate_n_steps not implemented for the stepper type");
43  }
44 
55  virtual void integrate_n_steps(std::function<void(const MATRIX& x, const SCALAR& t)> observer,
56  const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
57  MATRIX& state,
58  const SCALAR& startTime,
59  size_t numSteps,
60  SCALAR dt)
61  {
62  throw std::runtime_error("Integrate_n_steps not implemented for the stepper type");
63  }
64 
65 
75  virtual void integrate_const(const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
76  MATRIX& state,
77  const SCALAR& startTime,
78  const SCALAR& finalTime,
79  SCALAR dt)
80  {
81  throw std::runtime_error("integrate_const not implemented for the stepper type");
82  }
83 
94  virtual void integrate_const(std::function<void(const MATRIX& x, const SCALAR& t)> observer,
95  const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
96  MATRIX& state,
97  const SCALAR& startTime,
98  const SCALAR& finalTime,
99  SCALAR dt)
100  {
101  throw std::runtime_error("integrate_const not implemented for the stepper type");
102  }
103 
117  virtual void integrate_adaptive(const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
118  MATRIX& state,
119  const SCALAR& startTime,
120  const SCALAR& finalTime,
121  SCALAR dtInitial = SCALAR(0.01))
122  {
123  throw std::runtime_error("integrate_adaptive not implemented for the stepper type");
124  }
125 
140  virtual void integrate_adaptive(std::function<void(const MATRIX& x, const SCALAR& t)> observer,
141  const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
142  MATRIX& state,
143  const SCALAR& startTime,
144  const SCALAR& finalTime,
145  const SCALAR dtInitial = SCALAR(0.01))
146  {
147  throw std::runtime_error("integrate_adaptive not implemented for the stepper type");
148  }
149 
159  virtual void integrate_times(std::function<void(const MATRIX& x, const SCALAR& t)> observer,
160  const std::function<void(const MATRIX&, MATRIX&, SCALAR)>& rhs,
161  MATRIX& state,
162  const tpl::TimeArray<SCALAR>& timeTrajectory,
163  SCALAR dtInitial = SCALAR(0.01))
164  {
165  throw std::runtime_error("integrate_times not implemented for the stepper type");
166  }
167 
174  void setAdaptiveErrorTolerances(const SCALAR absErrTol, const SCALAR& relErrTol)
175  {
176  absErrTol_ = absErrTol;
177  relErrTol_ = relErrTol;
178  }
179 
180 protected:
183 };
184 }
185 }
186 }
virtual void integrate_const(std::function< void(const MATRIX &x, const SCALAR &t)> observer, const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, const SCALAR &finalTime, SCALAR dt)
Equidistant integration based on initial and final time as well as step length.
Definition: StepperBase.h:94
virtual void integrate_n_steps(const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, size_t numSteps, SCALAR dt)
Performs numSteps integration steps.
Definition: StepperBase.h:36
virtual void integrate_n_steps(std::function< void(const MATRIX &x, const SCALAR &t)> observer, const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, size_t numSteps, SCALAR dt)
Performs numSteps integration steps.
Definition: StepperBase.h:55
This class serves as a common interface between the ODEInt and our custom integrators.
Definition: StepperBase.h:20
void setAdaptiveErrorTolerances(const SCALAR absErrTol, const SCALAR &relErrTol)
Sets the adaptive error tolerances.
Definition: StepperBase.h:174
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual ~StepperBase()
Definition: StepperBase.h:26
An array in time.
Definition: TimeArray.h:22
virtual void integrate_adaptive(const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, const SCALAR &finalTime, SCALAR dtInitial=SCALAR(0.01))
Integrates forward in time from an initial to a final time. If an adaptive stepper is used...
Definition: StepperBase.h:117
virtual void integrate_const(const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, const SCALAR &finalTime, SCALAR dt)
Equidistant integration based on initial and final time as well as step length.
Definition: StepperBase.h:75
virtual void integrate_adaptive(std::function< void(const MATRIX &x, const SCALAR &t)> observer, const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const SCALAR &startTime, const SCALAR &finalTime, const SCALAR dtInitial=SCALAR(0.01))
Integrates forward in time from an initial to a final time. If an adaptive stepper is used...
Definition: StepperBase.h:140
virtual void integrate_times(std::function< void(const MATRIX &x, const SCALAR &t)> observer, const std::function< void(const MATRIX &, MATRIX &, SCALAR)> &rhs, MATRIX &state, const tpl::TimeArray< SCALAR > &timeTrajectory, SCALAR dtInitial=SCALAR(0.01))
Integrates a system using a given time sequence.
Definition: StepperBase.h:159
SCALAR absErrTol_
Definition: StepperBase.h:181
EIGEN_MAKE_ALIGNED_OPERATOR_NEW StepperBase()
Definition: StepperBase.h:25
SCALAR relErrTol_
Definition: StepperBase.h:182