- 3.0.2 core module.
Sensitivity.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 
13 {
15  enum class APPROXIMATION
16  {
17  FORWARD_EULER = 0,
20  TUSTIN,
22  };
23 
26  double dt_;
27 
30 };
31 
32 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
33 class Sensitivity : public DiscreteLinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>
34 {
35 public:
36  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
37 
38  typedef std::shared_ptr<StateVectorArray<STATE_DIM, SCALAR>> StateVectorArrayPtr;
39  typedef std::shared_ptr<ControlVectorArray<CONTROL_DIM, SCALAR>> ControlVectorArrayPtr;
40 
41 
42  Sensitivity() : xSubstep_(nullptr), uSubstep_(nullptr) {}
43  virtual ~Sensitivity() {}
45  {
46  throw std::runtime_error("clone not implemented for Sensitivity");
47  }
48 
49  virtual void setLinearSystem(const std::shared_ptr<LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>>& linearSystem) = 0;
50 
52  virtual void setTimeDiscretization(const SCALAR& dt) = 0;
53 
62  std::vector<StateVectorArrayPtr, Eigen::aligned_allocator<StateVectorArrayPtr>>* xSubstep,
63  std::vector<ControlVectorArrayPtr, Eigen::aligned_allocator<ControlVectorArrayPtr>>* uSubstep)
64  {
65  xSubstep_ = xSubstep;
66  uSubstep_ = uSubstep;
67  }
68 
78  virtual void getAandB(const StateVector<STATE_DIM, SCALAR>& x,
80  const StateVector<STATE_DIM, SCALAR>& x_next,
81  const int n,
82  size_t numSteps,
85 
86 protected:
87  std::vector<StateVectorArrayPtr, Eigen::aligned_allocator<StateVectorArrayPtr>>* xSubstep_;
88  std::vector<ControlVectorArrayPtr, Eigen::aligned_allocator<ControlVectorArrayPtr>>* uSubstep_;
89 };
90 }
91 }
interface class for a general linear system or linearized system
Definition: LinearSystem.h:23
std::shared_ptr< ControlVectorArray< CONTROL_DIM, SCALAR > > ControlVectorArrayPtr
Definition: Sensitivity.h:39
Sensitivity()
Definition: Sensitivity.h:42
std::vector< ControlVectorArrayPtr, Eigen::aligned_allocator< ControlVectorArrayPtr > > * uSubstep_
Definition: Sensitivity.h:88
APPROXIMATION approximation_
type of discretization strategy used.
Definition: Sensitivity.h:29
APPROXIMATION
different discrete-time approximations to linear systems
Definition: Sensitivity.h:15
ct::core::ControlVector< control_dim > u
interface class for a general discrete linear system or linearized discrete system ...
Definition: DiscreteLinearSystem.h:23
virtual void setApproximation(const SensitivityApproximationSettings::APPROXIMATION &approx)
update the approximation type for the discrete-time system
Definition: Sensitivity.h:55
Definition: StateMatrix.h:12
const double dt
Definition: ControlVector.h:12
double dt_
discretization time-step
Definition: Sensitivity.h:26
CppAD::AD< CppAD::cg::CG< double > > SCALAR
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
virtual Sensitivity< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
deep cloning
Definition: Sensitivity.h:44
Definition: StateVector.h:12
ct::core::StateVector< state_dim > x
Definition: Sensitivity.h:33
SensitivityApproximationSettings(double dt, APPROXIMATION approx)
Definition: Sensitivity.h:24
settings for the SensitivityApproximation
Definition: Sensitivity.h:12
virtual ~Sensitivity()
Definition: Sensitivity.h:43
std::vector< StateVectorArrayPtr, Eigen::aligned_allocator< StateVectorArrayPtr > > * xSubstep_
Definition: Sensitivity.h:87
void setSubstepTrajectoryReference(std::vector< StateVectorArrayPtr, Eigen::aligned_allocator< StateVectorArrayPtr >> *xSubstep, std::vector< ControlVectorArrayPtr, Eigen::aligned_allocator< ControlVectorArrayPtr >> *uSubstep)
Definition: Sensitivity.h:61
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr< StateVectorArray< STATE_DIM, SCALAR > > StateVectorArrayPtr
Definition: Sensitivity.h:38
Definition: StateControlMatrix.h:12