- 3.0.2 core module.
SwitchedControlledSystem.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"
10 
11 namespace ct {
12 namespace core {
13 
15 
42 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
43 class SwitchedControlledSystem : public ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>
44 {
45 public:
46  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47 
48  typedef typename std::shared_ptr<SwitchedControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>> Ptr;
49  typedef typename std::shared_ptr<ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>> SystemPtr;
51 
53  typedef typename Base::time_t time_t;
54 
55 
57 
60  SwitchedControlledSystem(const SwitchedSystems& switchedSystems,
61  const ContinuousModeSequence& continuousModeSequence,
62  const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL)
63  : ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(type),
64  switchedSystems_(switchedSystems),
65  continuousModeSequence_(continuousModeSequence){};
66 
68 
73  SwitchedControlledSystem(const SwitchedSystems& switchedSystems,
74  const ContinuousModeSequence& continuousModeSequence,
75  std::shared_ptr<ct::core::Controller<STATE_DIM, CONTROL_DIM, SCALAR>> controller,
76  const SYSTEM_TYPE& type = SYSTEM_TYPE::GENERAL)
77  : ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(controller, type),
78  switchedSystems_(switchedSystems),
79  continuousModeSequence_(continuousModeSequence){};
80 
83  : ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>(arg), continuousModeSequence_(arg.continuousModeSequence_)
84  {
85  switchedSystems_.clear();
86  for (auto& subSystem : arg.switchedSystems_)
87  {
88  switchedSystems_.emplace_back(subSystem->clone());
89  }
90  };
91 
94 
97  {
98  return new SwitchedControlledSystem(*this);
99  };
100 
102  const time_t& t,
103  const ControlVector<CONTROL_DIM, SCALAR>& control,
104  StateVector<STATE_DIM, SCALAR>& derivative) override
105  {
107  switchedSystems_[mode]->computeControlledDynamics(state, t, control, derivative);
108  };
109 
110 protected:
111  SwitchedSystems switchedSystems_;
113 };
114 }
115 }
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: SwitchedControlledSystem.h:108
SCALAR time_t
the type of the time variable
Definition: System.h:44
SwitchedControlledSystem(const SwitchedControlledSystem &arg)
copy constructor
Definition: SwitchedControlledSystem.h:82
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr< SwitchedControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > Ptr
Definition: SwitchedControlledSystem.h:48
virtual void computeControlledDynamics(const StateVector< STATE_DIM, SCALAR > &state, const time_t &t, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< STATE_DIM, SCALAR > &derivative) override
Definition: SwitchedControlledSystem.h:101
SwitchedControlledSystem(const SwitchedSystems &switchedSystems, const ContinuousModeSequence &continuousModeSequence, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
default constructor
Definition: SwitchedControlledSystem.h:60
Switched< SystemPtr > SwitchedSystems
Definition: SwitchedControlledSystem.h:50
System< STATE_DIM, SCALAR > Base
Definition: SwitchedControlledSystem.h:52
Base::time_t time_t
Definition: SwitchedControlledSystem.h:53
Definition: ControlVector.h:12
virtual SwitchedControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
deep copy
Definition: SwitchedControlledSystem.h:96
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Definition: StateVector.h:12
virtual ~SwitchedControlledSystem()
destructor
Definition: SwitchedControlledSystem.h:93
SwitchedControlledSystem(const SwitchedSystems &switchedSystems, const ContinuousModeSequence &continuousModeSequence, std::shared_ptr< ct::core::Controller< STATE_DIM, CONTROL_DIM, SCALAR >> controller, const SYSTEM_TYPE &type=SYSTEM_TYPE::GENERAL)
constructor
Definition: SwitchedControlledSystem.h:73
SYSTEM_TYPE
type of system
Definition: System.h:15
A general, switched non-linear dynamic system with a control input.
Definition: SwitchedControlledSystem.h:43
Phase getPhaseFromTime(Time time) const
get phase pointer from time
Definition: Switching.h:68
any non-specific system
Definition: System.h:17
Interface class for a general system described by an ordinary differential equation (ODE) ...
Definition: System.h:38
std::shared_ptr< ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > SystemPtr
Definition: SwitchedControlledSystem.h:49
A general, non-linear dynamic system with a control input.
Definition: ControlledSystem.h:46
Interface class for all controllers.
Definition: Controller.h:26
ContinuousModeSequence continuousModeSequence_
the prespecified mode sequence
Definition: SwitchedControlledSystem.h:112