- 3.0.2 core module.
SwitchedDiscreteControlledSystem.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 
11 
12 namespace ct {
13 namespace core {
14 
16 
43 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
44 class SwitchedDiscreteControlledSystem : public DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>
45 {
46 public:
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 
49  typedef typename std::shared_ptr<SwitchedDiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>> Ptr;
50  typedef typename std::shared_ptr<DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>> SystemPtr;
52 
54 
57  typedef typename Base::time_t time_t;
58 
60 
63  SwitchedDiscreteControlledSystem(const SwitchedSystems& switchedSystems,
64  const DiscreteModeSequence& discreteModeSequence,
65  const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL)
66  : DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(type),
67  switchedSystems_(switchedSystems),
68  discreteModeSequence_(discreteModeSequence){};
69 
71 
76  SwitchedDiscreteControlledSystem(const SwitchedSystems& switchedSystems,
77  const DiscreteModeSequence& discreteModeSequence,
78  std::shared_ptr<DiscreteController<STATE_DIM, CONTROL_DIM, SCALAR>> controller,
79  const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL)
80  : DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(controller, type),
81  switchedSystems_(switchedSystems),
82  discreteModeSequence_(discreteModeSequence){};
83 
86  : DiscreteControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(arg),
88  {
89  switchedSystems_.clear();
90  for (auto& subSystem : arg.switchedSystems_)
91  {
92  switchedSystems_.emplace_back(subSystem->clone());
93  }
94  };
95 
98 
101  {
102  return new SwitchedDiscreteControlledSystem(*this);
103  };
104 
106 
113  virtual void propagateControlledDynamics(const state_vector_t& state,
114  const time_t n,
115  const control_vector_t& control,
116  state_vector_t& stateNext) override
117  {
119  switchedSystems_[mode]->propagateControlledDynamics(state, n, control, stateNext);
120  };
121 
122 protected:
123  SwitchedSystems switchedSystems_;
125 };
126 } // namespace core
127 } // namespace ct
std::vector< T, Alloc > Switched
Declaring Switched alias such that we can write Switched<System>
Definition: Switching.h:12
SwitchedSystems switchedSystems_
switched system container
Definition: SwitchedDiscreteControlledSystem.h:120
Switched< SystemPtr > SwitchedSystems
Definition: SwitchedDiscreteControlledSystem.h:51
Base::control_vector_t control_vector_t
Definition: SwitchedDiscreteControlledSystem.h:56
Base::time_t time_t
Definition: SwitchedDiscreteControlledSystem.h:57
SwitchedDiscreteControlledSystem(const SwitchedSystems &switchedSystems, const DiscreteModeSequence &discreteModeSequence, std::shared_ptr< DiscreteController< STATE_DIM, CONTROL_DIM, SCALAR >> controller, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
constructor
Definition: SwitchedDiscreteControlledSystem.h:76
Definition: ControlVector.h:12
SwitchedDiscreteControlledSystem(const SwitchedDiscreteControlledSystem &arg)
copy constructor
Definition: SwitchedDiscreteControlledSystem.h:85
A general, non-linear discrete dynamic system with a control input.
Definition: DiscreteControlledSystem.h:40
CppAD::AD< CppAD::cg::CG< double > > SCALAR
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
Definition: StateVector.h:12
SwitchedDiscreteControlledSystem(const SwitchedSystems &switchedSystems, const DiscreteModeSequence &discreteModeSequence, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
default constructor
Definition: SwitchedDiscreteControlledSystem.h:63
Interface class for all controllers.
Definition: DiscreteController.h:22
std::shared_ptr< DiscreteControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > SystemPtr
Definition: SwitchedDiscreteControlledSystem.h:50
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr< SwitchedDiscreteControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > Ptr
Definition: SwitchedDiscreteControlledSystem.h:49
virtual SwitchedDiscreteControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
deep copy
Definition: SwitchedDiscreteControlledSystem.h:100
SYSTEM_TYPE
type of system
Definition: System.h:15
virtual void propagateControlledDynamics(const state_vector_t &state, const time_t n, const control_vector_t &control, state_vector_t &stateNext) override
propagates the controlled system dynamics forward by one step
Definition: SwitchedDiscreteControlledSystem.h:113
Phase getPhaseFromTime(Time time) const
get phase pointer from time
Definition: Switching.h:68
any non-specific system
Definition: System.h:17
DiscreteSystem< STATE_DIM, CONTROL_DIM, SCALAR > Base
Definition: SwitchedDiscreteControlledSystem.h:53
A general, switched non-linear discrete dynamic system with a control input.
Definition: SwitchedDiscreteControlledSystem.h:44
Definition: DiscreteSystem.h:12
virtual ~SwitchedDiscreteControlledSystem()
destructor
Definition: SwitchedDiscreteControlledSystem.h:97
Base::state_vector_t state_vector_t
Definition: SwitchedDiscreteControlledSystem.h:55
int time_t
the type of the time variable
Definition: DiscreteSystem.h:15
DiscreteModeSequence discreteModeSequence_
the prespecified mode sequence
Definition: SwitchedDiscreteControlledSystem.h:124