- 3.0.2 optimal control module.
FHDTLQR.hpp
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 
10 
11 namespace ct {
12 namespace optcon {
13 
37 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
38 class FHDTLQR
39 {
40 public:
41  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 
44  typedef Eigen::Matrix<SCALAR, STATE_DIM, STATE_DIM> state_matrix_t;
45  typedef Eigen::Matrix<SCALAR, CONTROL_DIM, CONTROL_DIM> control_matrix_t;
46  typedef Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM> control_state_matrix_t;
47  typedef Eigen::Matrix<SCALAR, STATE_DIM, CONTROL_DIM> control_gain_matrix_t;
48  typedef Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM> control_feedback_t;
49 
53 
56 
57 
59 
63 
64  ~FHDTLQR();
65 
66 
68 
85  void designController(const state_vector_array_t& x_trajectory,
86  const control_vector_array_t& u_trajectory,
87  const state_matrix_array_t& A,
88  const control_gain_matrix_array_t& B,
89  SCALAR dt,
90  control_feedback_array_t& K,
91  bool performNumericalChecks = true);
92 
93 
95 
109  void designController(const state_vector_array_t& x_trajectory,
110  const control_vector_array_t& u_trajectory,
111  std::shared_ptr<core::LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>> derivatives,
112  SCALAR dt,
113  control_feedback_array_t& K,
114  bool performNumericalChecks = true);
115 
116 
117 private:
119 
136  void linearizeModel(const state_vector_array_t& x_trajectory,
137  const control_vector_array_t& u_trajectory,
138  size_t N,
139  SCALAR dt,
140  std::shared_ptr<core::LinearSystem<STATE_DIM, CONTROL_DIM, SCALAR>>& derivatives,
141  state_matrix_array_t& A,
142  control_gain_matrix_array_t& B);
143 
144 
146 
165  void solve(const state_vector_array_t& x_trajectory,
166  const control_vector_array_t& u_trajectory,
167  const state_matrix_array_t& A,
168  const control_gain_matrix_array_t& B,
169  size_t N,
170  SCALAR dt,
171  control_feedback_array_t& K,
172  bool performNumericalChecks = true);
173 
174 
175  std::shared_ptr<CostFunctionQuadratic<STATE_DIM, CONTROL_DIM, SCALAR>>
176  costFunction_;
178 };
179 
180 } // namespace optcon
181 } // namespace ct
Eigen::Matrix< SCALAR, STATE_DIM, STATE_DIM > state_matrix_t
Definition: FHDTLQR.hpp:44
Eigen::Matrix< SCALAR, STATE_DIM, CONTROL_DIM > control_gain_matrix_t
Definition: FHDTLQR.hpp:47
Eigen::Matrix< SCALAR, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: FHDTLQR.hpp:46
ct::core::StateMatrixArray< STATE_DIM, SCALAR > state_matrix_array_t
Definition: FHDTLQR.hpp:52
Eigen::Matrix< SCALAR, CONTROL_DIM, STATE_DIM > control_feedback_t
Definition: FHDTLQR.hpp:48
ct::core::StateControlMatrixArray< STATE_DIM, CONTROL_DIM, SCALAR > control_gain_matrix_array_t
Definition: FHDTLQR.hpp:55
const double dt
Definition: LQOCSolverTiming.cpp:18
Describes a cost function with a quadratic approximation, i.e. one that can compute first and second ...
Definition: CostFunctionQuadratic.hpp:29
core::ControlVectorArray< CONTROL_DIM, SCALAR > control_vector_array_t
Definition: FHDTLQR.hpp:51
Finite-Horizon Discrete Time LQR.
Definition: FHDTLQR.hpp:38
Dynamic Riccati Equation.
Definition: DynamicRiccatiEquation.hpp:22
CppAD::AD< CppAD::cg::CG< double > > SCALAR
ct::core::FeedbackArray< STATE_DIM, CONTROL_DIM, SCALAR > control_feedback_array_t
Definition: FHDTLQR.hpp:54
FHDTLQR(std::shared_ptr< CostFunctionQuadratic< STATE_DIM, CONTROL_DIM, SCALAR >> costFunction)
Constructor.
Definition: FHDTLQR-impl.hpp:12
void designController(const state_vector_array_t &x_trajectory, const control_vector_array_t &u_trajectory, const state_matrix_array_t &A, const control_gain_matrix_array_t &B, SCALAR dt, control_feedback_array_t &K, bool performNumericalChecks=true)
design a time-varying feedback trajectory using user-provided matrices A and B
Definition: FHDTLQR-impl.hpp:24
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef core::ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: FHDTLQR.hpp:43
core::StateVectorArray< STATE_DIM, SCALAR > state_vector_array_t
Definition: FHDTLQR.hpp:50
~FHDTLQR()
Definition: FHDTLQR-impl.hpp:19
Eigen::Matrix< SCALAR, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: FHDTLQR.hpp:45