- 3.0.2 optimal control module.
InputDisturbedSystem-impl.h
Go to the documentation of this file.
1 
2 /**********************************************************************************************************************
3 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
4 Licensed under the BSD-2 license (see LICENSE file in main directory)
5 **********************************************************************************************************************/
6 
7 #pragma once
8 
9 namespace ct {
10 namespace optcon {
11 
12 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
15  : Base(sys->getController()), system_(sys)
16 {
17 }
18 
19 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
21  : Base(*this), system_(other.system_->clone())
22 {
23 }
24 
25 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
27  const
28 {
29  return new InputDisturbedSystem(*this);
30 }
31 
32 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
35  const SCALAR& t,
38 {
39  // the derivative of the original, non-augmented system
41 
42  // the control consists of actual commanded control plus the estimated input disturbance,
43  // which is the augmented part of the state vector
44  ct::core::ControlVector<CONTROL_DIM, SCALAR> disturbed_control = control + state.template tail<CONTROL_DIM>();
45 
46  // the dynamics of the augmented system consist of the original dynamics ...
47  system_->computeControlledDynamics(state.template head<STATE_DIM>(), t, disturbed_control, tempDerivative);
48  derivative.template head<STATE_DIM>() = tempDerivative;
49 
50  // and the disturbance dynamics, which is zero as the disturbance is assumed constant.
51  derivative.template tail<CONTROL_DIM>().setZero();
52 }
53 
54 } // namespace optcon
55 } // namespace ct
InputDisturbedSystem * clone() const override
deep cloning
Definition: InputDisturbedSystem-impl.h:26
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
CppAD::AD< CppAD::cg::CG< double > > SCALAR
typename ct::optcon::DisturbedSystem< STATE_DIM, CONTROL_DIM, CONTROL_DIM, SCALAR > Base
Definition: InputDisturbedSystem.h:36
Implementation of an input disturbed system where, the dimension of the disturbance is equal to the d...
Definition: InputDisturbedSystem.h:28
void computeControlledDynamics(const ct::core::StateVector< AUGMENTED_STATE_DIM, SCALAR > &state, const SCALAR &t, const ct::core::ControlVector< CONTROL_DIM, SCALAR > &control, ct::core::StateVector< AUGMENTED_STATE_DIM, SCALAR > &derivative) override
compute the dynamics (the left-hand-side of the dynamics equation) for the disturbance-augmented syst...
Definition: InputDisturbedSystem-impl.h:33
InputDisturbedSystem(std::shared_ptr< ct::core::ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR >> sys)
Construct a new Input Disturbed System object.
Definition: InputDisturbedSystem-impl.h:13