autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
|
Definition of the optimal control problem (OCP) of hexacopter. More...
#include <ocp.hpp>
Public Member Functions | |
void | disp (std::ostream &os) const |
void | synchronize () |
Synchrozies the internal parameters of this OCP with the external references. This method is called at the beginning of each MPC update. More... | |
void | eval_f (const double t, const double *x, const double *u, double *dx) const |
Computes the state equation dx = f(t, x, u). More... | |
void | eval_phix (const double t, const double *x, double *phix) const |
Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x). More... | |
void | eval_hx (const double t, const double *x, const double *u, const double *lmd, double *hx) const |
Computes the partial derivative of the Hamiltonian with respect to state, i.e., hx = dH/dx(t, x, u, lmd). More... | |
void | eval_hu (const double t, const double *x, const double *u, const double *lmd, double *hu) const |
Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd). More... | |
template<typename VectorType1 , typename VectorType2 , typename VectorType3 > | |
void | eval_f (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &u, const MatrixBase< VectorType3 > &dx) const |
Computes the state equation dx = f(t, x, u). More... | |
template<typename VectorType1 , typename VectorType2 > | |
void | eval_phix (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &phix) const |
Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x). More... | |
template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 > | |
void | eval_hx (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &uc, const MatrixBase< VectorType3 > &lmd, const MatrixBase< VectorType4 > &hx) const |
Computes the partial derivative of the Hamiltonian with respect to the state, i.e., hx = dH/dx(t, x, u, lmd). More... | |
template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 > | |
void | eval_hu (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &uc, const MatrixBase< VectorType3 > &lmd, const MatrixBase< VectorType4 > &hu) const |
Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd). More... | |
Public Attributes | |
double | m = 1.44 |
double | l = 0.23 |
double | k = 1.6e-09 |
double | Ixx = 0.0348 |
double | Iyy = 0.0459 |
double | Izz = 0.0977 |
double | gamma = 0.01 |
double | g = 9.80665 |
double | z_ref = 5 |
std::array< double, 12 > | q = {1, 1, 1, 0.01, 0.01, 0, 0.01, 0.01, 0.01, 0.1, 0.1, 0.001} |
std::array< double, 12 > | q_terminal = {1, 1, 1, 0.01, 0.01, 0, 0.01, 0.01, 0.01, 0.1, 0.1, 0.001} |
std::array< double, 6 > | r = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01} |
std::array< double, nub > | umin = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144} |
std::array< double, nub > | umax = {6.0, 6.0, 6.0, 6.0, 6.0, 6.0} |
std::array< double, nub > | dummy_weight = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1} |
Static Public Attributes | |
static constexpr int | nx = 12 |
Dimension of the state. More... | |
static constexpr int | nu = 6 |
Dimension of the control input. More... | |
static constexpr int | nc = 0 |
Dimension of the equality constraints. More... | |
static constexpr int | nh = 0 |
Dimension of the Fischer-Burmeister function (already counded in nc). More... | |
static constexpr int | nuc = nu + nc |
Dimension of the concatenation of the control input and equality constraints. More... | |
static constexpr int | nub = 6 |
Dimension of the bound constraints on the control input. More... | |
static constexpr std::array< int, nub > | ubound_indices = {0, 1, 2, 3, 4, 5} |
Friends | |
std::ostream & | operator<< (std::ostream &os, const OCP_hexacopter &ocp) |
Definition of the optimal control problem (OCP) of hexacopter.
|
inline |
|
inline |
Computes the state equation dx = f(t, x, u).
[in] | t | Time. |
[in] | x | State. |
[in] | u | Control input. |
[out] | dx | Evaluated value of the state equation. |
|
inline |
Computes the state equation dx = f(t, x, u).
[in] | t | Time. |
[in] | x | State. Size must be nx. |
[in] | u | Control input. Size must be nu. |
[out] | dx | Evaluated value of the state equation. Size must be nx. |
|
inline |
Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd).
[in] | t | Time. |
[in] | x | State. |
[in] | u | Concatenatin of the control input and Lagrange multiplier with respect to the equality constraints. |
[in] | lmd | Costate. |
[out] | hu | Evaluated value of the partial derivative of the Hamiltonian. |
|
inline |
Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd).
[in] | t | Time. |
[in] | x | State. Size must be nx. |
[in] | uc | Concatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc. |
[in] | lmd | Costate. Size must be nx. |
[out] | hu | Evaluated value of the partial derivative of the Hamiltonian. Size must be nuc. |
|
inline |
Computes the partial derivative of the Hamiltonian with respect to state, i.e., hx = dH/dx(t, x, u, lmd).
[in] | t | Time. |
[in] | x | State. |
[in] | u | Concatenatin of the control input and Lagrange multiplier with respect to the equality constraints. |
[in] | lmd | Costate. |
[out] | hx | Evaluated value of the partial derivative of the Hamiltonian. |
|
inline |
Computes the partial derivative of the Hamiltonian with respect to the state, i.e., hx = dH/dx(t, x, u, lmd).
[in] | t | Time. |
[in] | x | State. Size must be nx. |
[in] | uc | Concatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc. |
[in] | lmd | Costate. Size must be nx. |
[out] | hx | Evaluated value of the partial derivative of the Hamiltonian. Size must be nx. |
|
inline |
Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).
[in] | t | Time. |
[in] | x | State. |
[out] | phix | Evaluated value of the partial derivative of terminal cost. |
|
inline |
Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).
[in] | t | Time. |
[in] | x | State. Size must be nx. |
[out] | phix | Evaluated value of the partial derivative of terminal cost. Size must be nx. |
|
inline |
Synchrozies the internal parameters of this OCP with the external references. This method is called at the beginning of each MPC update.
|
friend |
std::array<double, nub> cgmres::OCP_hexacopter::dummy_weight = {0.1, 0.1, 0.1, 0.1, 0.1, 0.1} |
double cgmres::OCP_hexacopter::g = 9.80665 |
double cgmres::OCP_hexacopter::gamma = 0.01 |
double cgmres::OCP_hexacopter::Ixx = 0.0348 |
double cgmres::OCP_hexacopter::Iyy = 0.0459 |
double cgmres::OCP_hexacopter::Izz = 0.0977 |
double cgmres::OCP_hexacopter::k = 1.6e-09 |
double cgmres::OCP_hexacopter::l = 0.23 |
double cgmres::OCP_hexacopter::m = 1.44 |
|
staticconstexpr |
Dimension of the equality constraints.
|
staticconstexpr |
Dimension of the Fischer-Burmeister function (already counded in nc).
|
staticconstexpr |
Dimension of the control input.
|
staticconstexpr |
Dimension of the bound constraints on the control input.
Dimension of the concatenation of the control input and equality constraints.
|
staticconstexpr |
Dimension of the state.
std::array<double, 12> cgmres::OCP_hexacopter::q = {1, 1, 1, 0.01, 0.01, 0, 0.01, 0.01, 0.01, 0.1, 0.1, 0.001} |
std::array<double, 12> cgmres::OCP_hexacopter::q_terminal = {1, 1, 1, 0.01, 0.01, 0, 0.01, 0.01, 0.01, 0.1, 0.1, 0.001} |
std::array<double, 6> cgmres::OCP_hexacopter::r = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01} |
|
staticconstexpr |
std::array<double, nub> cgmres::OCP_hexacopter::umax = {6.0, 6.0, 6.0, 6.0, 6.0, 6.0} |
std::array<double, nub> cgmres::OCP_hexacopter::umin = {0.144, 0.144, 0.144, 0.144, 0.144, 0.144} |
double cgmres::OCP_hexacopter::z_ref = 5 |