autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
Loading...
Searching...
No Matches
cgmres::OCP_mobilerobot Class Reference

Definition of the optimal control problem (OCP) of mobilerobot. 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 vx_ref = 0.4
 
double v_min = -0.5
 
double v_max = 0.5
 
double w_min = -0.75
 
double w_max = 0.75
 
double X_1 = 1
 
double Y_1 = 0.25
 
double R_1 = 0.5
 
double X_2 = 2
 
double Y_2 = -0.25
 
double R_2 = 0.5
 
std::array< double, 3 > q = {10, 1, 0.01}
 
std::array< double, 2 > r = {0.1, 0.1}
 
std::array< double, 3 > x_ref = {0, 0, 0}
 
std::array< double, nubumin = {-1.0, -1.0}
 
std::array< double, nubumax = {1.0, 1.0}
 
std::array< double, nubdummy_weight = {0.1, 0.1}
 
std::array< double, nhfb_eps = {0.01, 0.01}
 

Static Public Attributes

static constexpr int nx = 3
 Dimension of the state. More...
 
static constexpr int nu = 2
 Dimension of the control input. More...
 
static constexpr int nc = 2
 Dimension of the equality constraints. More...
 
static constexpr int nh = 2
 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 = 2
 Dimension of the bound constraints on the control input. More...
 
static constexpr std::array< int, nububound_indices = {0, 1}
 

Friends

std::ostream & operator<< (std::ostream &os, const OCP_mobilerobot &ocp)
 

Detailed Description

Definition of the optimal control problem (OCP) of mobilerobot.

Member Function Documentation

◆ disp()

void cgmres::OCP_mobilerobot::disp ( std::ostream &  os) const
inline

◆ eval_f() [1/2]

void cgmres::OCP_mobilerobot::eval_f ( const double  t,
const double *  x,
const double *  u,
double *  dx 
) const
inline

Computes the state equation dx = f(t, x, u).

Parameters
[in]tTime.
[in]xState.
[in]uControl input.
[out]dxEvaluated value of the state equation.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_f() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 >
void cgmres::OCP_mobilerobot::eval_f ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  u,
const MatrixBase< VectorType3 > &  dx 
) const
inline

Computes the state equation dx = f(t, x, u).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]uControl input. Size must be nu.
[out]dxEvaluated value of the state equation. Size must be nx.

◆ eval_hu() [1/2]

void cgmres::OCP_mobilerobot::eval_hu ( const double  t,
const double *  x,
const double *  u,
const double *  lmd,
double *  hu 
) const
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).

Parameters
[in]tTime.
[in]xState.
[in]uConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints.
[in]lmdCostate.
[out]huEvaluated value of the partial derivative of the Hamiltonian.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_hu() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void cgmres::OCP_mobilerobot::eval_hu ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  uc,
const MatrixBase< VectorType3 > &  lmd,
const MatrixBase< VectorType4 > &  hu 
) const
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).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]ucConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc.
[in]lmdCostate. Size must be nx.
[out]huEvaluated value of the partial derivative of the Hamiltonian. Size must be nuc.

◆ eval_hx() [1/2]

void cgmres::OCP_mobilerobot::eval_hx ( const double  t,
const double *  x,
const double *  u,
const double *  lmd,
double *  hx 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to state, i.e., hx = dH/dx(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState.
[in]uConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints.
[in]lmdCostate.
[out]hxEvaluated value of the partial derivative of the Hamiltonian.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_hx() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void cgmres::OCP_mobilerobot::eval_hx ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  uc,
const MatrixBase< VectorType3 > &  lmd,
const MatrixBase< VectorType4 > &  hx 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to the state, i.e., hx = dH/dx(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]ucConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc.
[in]lmdCostate. Size must be nx.
[out]hxEvaluated value of the partial derivative of the Hamiltonian. Size must be nx.

◆ eval_phix() [1/2]

void cgmres::OCP_mobilerobot::eval_phix ( const double  t,
const double *  x,
double *  phix 
) const
inline

Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).

Parameters
[in]tTime.
[in]xState.
[out]phixEvaluated value of the partial derivative of terminal cost.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_phix() [2/2]

template<typename VectorType1 , typename VectorType2 >
void cgmres::OCP_mobilerobot::eval_phix ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  phix 
) const
inline

Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[out]phixEvaluated value of the partial derivative of terminal cost. Size must be nx.

◆ synchronize()

void cgmres::OCP_mobilerobot::synchronize ( )
inline

Synchrozies the internal parameters of this OCP with the external references. This method is called at the beginning of each MPC update.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const OCP_mobilerobot ocp 
)
friend

Member Data Documentation

◆ dummy_weight

std::array<double, nub> cgmres::OCP_mobilerobot::dummy_weight = {0.1, 0.1}

◆ fb_eps

std::array<double, nh> cgmres::OCP_mobilerobot::fb_eps = {0.01, 0.01}

◆ nc

constexpr int cgmres::OCP_mobilerobot::nc = 2
staticconstexpr

Dimension of the equality constraints.

◆ nh

constexpr int cgmres::OCP_mobilerobot::nh = 2
staticconstexpr

Dimension of the Fischer-Burmeister function (already counded in nc).

◆ nu

constexpr int cgmres::OCP_mobilerobot::nu = 2
staticconstexpr

Dimension of the control input.

◆ nub

constexpr int cgmres::OCP_mobilerobot::nub = 2
staticconstexpr

Dimension of the bound constraints on the control input.

◆ nuc

constexpr int cgmres::OCP_mobilerobot::nuc = nu + nc
staticconstexpr

Dimension of the concatenation of the control input and equality constraints.

◆ nx

constexpr int cgmres::OCP_mobilerobot::nx = 3
staticconstexpr

Dimension of the state.

◆ q

std::array<double, 3> cgmres::OCP_mobilerobot::q = {10, 1, 0.01}

◆ r

std::array<double, 2> cgmres::OCP_mobilerobot::r = {0.1, 0.1}

◆ R_1

double cgmres::OCP_mobilerobot::R_1 = 0.5

◆ R_2

double cgmres::OCP_mobilerobot::R_2 = 0.5

◆ ubound_indices

constexpr std::array<int, nub> cgmres::OCP_mobilerobot::ubound_indices = {0, 1}
staticconstexpr

◆ umax

std::array<double, nub> cgmres::OCP_mobilerobot::umax = {1.0, 1.0}

◆ umin

std::array<double, nub> cgmres::OCP_mobilerobot::umin = {-1.0, -1.0}

◆ v_max

double cgmres::OCP_mobilerobot::v_max = 0.5

◆ v_min

double cgmres::OCP_mobilerobot::v_min = -0.5

◆ vx_ref

double cgmres::OCP_mobilerobot::vx_ref = 0.4

◆ w_max

double cgmres::OCP_mobilerobot::w_max = 0.75

◆ w_min

double cgmres::OCP_mobilerobot::w_min = -0.75

◆ X_1

double cgmres::OCP_mobilerobot::X_1 = 1

◆ X_2

double cgmres::OCP_mobilerobot::X_2 = 2

◆ x_ref

std::array<double, 3> cgmres::OCP_mobilerobot::x_ref = {0, 0, 0}

◆ Y_1

double cgmres::OCP_mobilerobot::Y_1 = 0.25

◆ Y_2

double cgmres::OCP_mobilerobot::Y_2 = -0.25

The documentation for this class was generated from the following file: