- 3.0.2 core module.
ConstantStateFeedbackController.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 "Controller.h"
10 
11 namespace ct {
12 namespace core {
13 
15 
29 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
30 class ConstantStateFeedbackController : public Controller<STATE_DIM, CONTROL_DIM, SCALAR>
31 {
32 public:
33  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 
36 
40  {
41  u_ff_.setZero();
42  x_ref_.setZero();
43  K_.setZero();
44  }
45 
46 
48 
57  : u_ff_(uff), x_ref_(x), K_(K)
58  {
59  }
60 
61 
64  : Controller<STATE_DIM, CONTROL_DIM, SCALAR>(other), u_ff_(other.u_ff_), x_ref_(other.x_ref_), K_(other.K_)
65  {
66  }
67 
68 
72 
77  {
79  }
80 
81 
83 
91  const SCALAR& t,
92  ControlVector<CONTROL_DIM, SCALAR>& controlAction) override
93  {
94  controlAction = u_ff_ + K_ * (x - x_ref_);
95  }
96 
97 
99 
108  {
109  u_ff_ = uff;
110  x_ref_ = x;
111  K_ = K;
112  }
113 
114 
115 private:
118 
121 
124 };
125 
126 } // namespace core
127 } // namespace ct
void updateControlLaw(const ControlVector< CONTROL_DIM, SCALAR > &uff, const StateVector< STATE_DIM, SCALAR > &x, const FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR > &K=FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR >::Zero())
update the control law with a new set of parameters
Definition: ConstantStateFeedbackController.h:104
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ConstantStateFeedbackController()
Default constructor.
Definition: ConstantStateFeedbackController.h:39
void computeControl(const StateVector< STATE_DIM, SCALAR > &x, const SCALAR &t, ControlVector< CONTROL_DIM, SCALAR > &controlAction) override
Computes current control.
Definition: ConstantStateFeedbackController.h:90
Definition: ControlVector.h:12
ConstantStateFeedbackController< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
Clone operator.
Definition: ConstantStateFeedbackController.h:76
CppAD::AD< CppAD::cg::CG< double > > SCALAR
ConstantStateFeedbackController(const ControlVector< CONTROL_DIM, SCALAR > &uff, const StateVector< STATE_DIM, SCALAR > &x, const FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR > &K)
Constructor.
Definition: ConstantStateFeedbackController.h:54
Definition: StateVector.h:12
A constant state feedback controller.
Definition: ConstantStateFeedbackController.h:30
Definition: FeedbackMatrix.h:12
~ConstantStateFeedbackController()
Destructor.
Definition: ConstantStateFeedbackController.h:70
ConstantStateFeedbackController(const ConstantStateFeedbackController< STATE_DIM, CONTROL_DIM, SCALAR > &other)
Copy constructor.
Definition: ConstantStateFeedbackController.h:63
Interface class for all controllers.
Definition: Controller.h:26