WPILibC++ 2023.4.3
discrete_algebraic_riccati_equation.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <cstdlib>
5
6#include <Eigen/Core>
7#include <wpi/SymbolExports.h>
8
9namespace drake {
10namespace math {
11
12/**
13Computes the unique stabilizing solution X to the discrete-time algebraic
14Riccati equation:
15
16AᵀXA − X − AᵀXB(BᵀXB + R)⁻¹BᵀXA + Q = 0
17
18@throws std::exception if Q is not positive semi-definite.
19@throws std::exception if R is not positive definite.
20
21Based on the Schur Vector approach outlined in this paper:
22"On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation"
23by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell
24*/
31
32/**
33Computes the unique stabilizing solution X to the discrete-time algebraic
34Riccati equation:
35
36AᵀXA − X − (AᵀXB + N)(BᵀXB + R)⁻¹(BᵀXA + Nᵀ) + Q = 0
37
38This is equivalent to solving the original DARE:
39
40A₂ᵀXA₂ − X − A₂ᵀXB(BᵀXB + R)⁻¹BᵀXA₂ + Q₂ = 0
41
42where A₂ and Q₂ are a change of variables:
43
44A₂ = A − BR⁻¹Nᵀ and Q₂ = Q − NR⁻¹Nᵀ
45
46This overload of the DARE is useful for finding the control law uₖ that
47minimizes the following cost function subject to xₖ₊₁ = Axₖ + Buₖ.
48
49@verbatim
50 ∞ [xₖ]ᵀ[Q N][xₖ]
51J = Σ [uₖ] [Nᵀ R][uₖ] ΔT
52 k=0
53@endverbatim
54
55This is a more general form of the following. The linear-quadratic regulator
56is the feedback control law uₖ that minimizes the following cost function
57subject to xₖ₊₁ = Axₖ + Buₖ:
58
59@verbatim
60
61J = Σ (xₖᵀQxₖ + uₖᵀRuₖ) ΔT
62 k=0
63@endverbatim
64
65This can be refactored as:
66
67@verbatim
68 ∞ [xₖ]ᵀ[Q 0][xₖ]
69J = Σ [uₖ] [0 R][uₖ] ΔT
70 k=0
71@endverbatim
72
73@throws std::runtime_error if Q − NR⁻¹Nᵀ is not positive semi-definite.
74@throws std::runtime_error if R is not positive definite.
75*/
83} // namespace math
84} // namespace drake
85
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
A matrix or vector expression mapping an existing expression.
Definition: Ref.h:283
WPILIB_DLLEXPORT Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation(const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::MatrixXd > &B, const Eigen::Ref< const Eigen::MatrixXd > &Q, const Eigen::Ref< const Eigen::MatrixXd > &R)
Computes the unique stabilizing solution X to the discrete-time algebraic Riccati equation:
Definition: drake_assertion_error.h:6
static constexpr const unit_t< compound_unit< energy::joules, inverse< temperature::kelvin >, inverse< substance::moles > > > R(8.3144598)
Gas constant.