- 3.0.2 core module.
StateFeedbackController.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 
12 
38 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
39 class StateFeedbackController : public Controller<STATE_DIM, CONTROL_DIM, SCALAR>,
40  public DiscreteController<STATE_DIM, CONTROL_DIM, SCALAR>
41 {
42 public:
43  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44 
47 
50 
54 
56  StateFeedbackController() : ContinuousBase(), DiscreteBase() {}
59 
61 
73  StateFeedbackController(const state_vector_array_t& x_ref,
74  const control_vector_array_t& uff,
75  const feedback_array_t& K,
76  const SCALAR deltaT,
77  const SCALAR t0 = 0.0,
78  const InterpolationType& intType = ZOH);
79 
82 
85 
87 
93  virtual void computeControl(const state_vector_t& state, const SCALAR& t, control_vector_t& controlAction) override;
94 
96 
104  virtual void computeControl(const state_vector_t& state, const int n, control_vector_t& controlAction) override;
105 
107 
113  void update(const DiscreteArray<state_vector_t>& x_ref,
116  const tpl::TimeArray<SCALAR>& t);
117 
119  const DiscreteArray<state_vector_t>& x_ref() const;
120 
122  const DiscreteArray<control_vector_t>& uff() const;
123 
126 
128  const tpl::TimeArray<SCALAR>& time() const;
129 
132 
135 
138 
141 
144 
147 
151 
152 protected:
156 };
157 
158 } // namespace core
159 } // namespace ct
StateTrajectory< STATE_DIM, SCALAR > x_ref_
Definition: StateFeedbackController.h:153
An discrete array (vector) of a particular data type.
Definition: DiscreteArray.h:22
const tpl::TimeArray< SCALAR > & time() const
get time array
Definition: StateFeedbackController-impl.h:97
StateTrajectory< STATE_DIM, SCALAR > & getReferenceStateTrajectory()
get a reference to the feedforward trajectory
Definition: StateFeedbackController-impl.h:104
StateFeedbackController()
default constructor
Definition: StateFeedbackController.h:56
const DiscreteArray< FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR > > & K() const
get feedback array (without timings)
Definition: StateFeedbackController-impl.h:91
ControlVectorArray< CONTROL_DIM, SCALAR > control_vector_array_t
Definition: StateFeedbackController.h:52
clear all close all load ct GNMSLog0 mat reformat t
const DiscreteArray< state_vector_t > & x_ref() const
get reference state vector array (without timings)
Definition: StateFeedbackController-impl.h:77
FeedbackTrajectory< STATE_DIM, CONTROL_DIM, SCALAR > & getFeedbackTrajectory()
get a reference to the feedback trajectory
Definition: StateFeedbackController-impl.h:132
Definition: ControlVector.h:12
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual ~StateFeedbackController()
destructor
Definition: StateFeedbackController.h:81
virtual void computeControl(const state_vector_t &state, const SCALAR &t, control_vector_t &controlAction) override
computes the control action in the continuous case
Definition: StateFeedbackController-impl.h:29
InterpolationType
Definition: Interpolation.h:14
A linear state feedback controller.
Definition: StateFeedbackController.h:39
A discrete, timed trajectory with interpolation.
Definition: DiscreteTrajectoryBase.h:31
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
const DiscreteArray< control_vector_t > & uff() const
get feedforward array (without timings)
Definition: StateFeedbackController-impl.h:84
Interface class for all controllers.
Definition: DiscreteController.h:22
DiscreteBase::control_vector_t control_vector_t
Definition: StateFeedbackController.h:49
An array in time.
Definition: TimeArray.h:22
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Controller< STATE_DIM, CONTROL_DIM, SCALAR > ContinuousBase
Definition: StateFeedbackController.h:45
ControlTrajectory< CONTROL_DIM, SCALAR > uff_
state reference trajectory
Definition: StateFeedbackController.h:154
void update(const DiscreteArray< state_vector_t > &x_ref, const DiscreteArray< control_vector_t > &uff, const DiscreteArray< FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR >> &K, const tpl::TimeArray< SCALAR > &t)
updates the controller
Definition: StateFeedbackController-impl.h:45
void extractControlTrajectory(const StateTrajectory< STATE_DIM, SCALAR > &x_traj, ControlTrajectory< CONTROL_DIM, SCALAR > &u_traj)
extracts a physically meaningful control trajectory from the given state-feedback law and a reference...
Definition: StateFeedbackController-impl.h:145
StateFeedbackController< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
deep cloning
Definition: StateFeedbackController-impl.h:69
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: DiscreteController.h:27
Definition: FeedbackMatrix.h:12
FeedbackTrajectory< STATE_DIM, CONTROL_DIM, SCALAR > K_
feedforward control trajectory
Definition: StateFeedbackController.h:155
StateVectorArray< STATE_DIM, SCALAR > state_vector_array_t
Definition: StateFeedbackController.h:51
DiscreteController< STATE_DIM, CONTROL_DIM, SCALAR > DiscreteBase
Definition: StateFeedbackController.h:46
DiscreteBase::state_vector_t state_vector_t
Definition: StateFeedbackController.h:48
FeedbackArray< STATE_DIM, CONTROL_DIM, SCALAR > feedback_array_t
Definition: StateFeedbackController.h:53
Zero-Order hold.
Definition: Interpolation.h:16
ControlTrajectory< CONTROL_DIM, SCALAR > & getFeedforwardTrajectory()
get a reference to the feedforward trajectory
Definition: StateFeedbackController-impl.h:118
Interface class for all controllers.
Definition: Controller.h:26