nmpc_ddp
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
nmpc_ddp::DDPProblem< StateDim, InputDim > Class Template Referenceabstract

DDP problem. More...

#include <DDPProblem.h>

Public Types

using StateDimVector = Eigen::Matrix< double, StateDim, 1 >
 Type of vector of state dimension. More...
 
using InputDimVector = Eigen::Matrix< double, InputDim, 1 >
 Type of vector of input dimension. More...
 
using StateStateDimMatrix = Eigen::Matrix< double, StateDim, StateDim >
 Type of matrix of state x state dimension. More...
 
using InputInputDimMatrix = Eigen::Matrix< double, InputDim, InputDim >
 Type of matrix of input x input dimension. More...
 
using StateInputDimMatrix = Eigen::Matrix< double, StateDim, InputDim >
 Type of matrix of state x input dimension. More...
 
using InputStateDimMatrix = Eigen::Matrix< double, InputDim, StateDim >
 Type of matrix of input x state dimension. More...
 

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW DDPProblem (double dt)
 Constructor. More...
 
virtual int inputDim () const
 Gets the input dimension. More...
 
virtual int inputDim (double) const
 Gets the input dimension. More...
 
double dt () const
 Gets the discretization timestep [sec]. More...
 
virtual StateDimVector stateEq (double t, const StateDimVector &x, const InputDimVector &u) const =0
 Calculate discrete state equation. More...
 
virtual double runningCost (double t, const StateDimVector &x, const InputDimVector &u) const =0
 Calculate running cost. More...
 
virtual double terminalCost (double t, const StateDimVector &x) const =0
 Calculate terminal cost. More...
 
virtual void calcStateEqDeriv (double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateStateDimMatrix > state_eq_deriv_x, Eigen::Ref< StateInputDimMatrix > state_eq_deriv_u) const =0
 Calculate first-order derivatives of discrete state equation. More...
 
virtual void calcStateEqDeriv (double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateStateDimMatrix > state_eq_deriv_x, Eigen::Ref< StateInputDimMatrix > state_eq_deriv_u, std::vector< StateStateDimMatrix > &state_eq_deriv_xx, std::vector< InputInputDimMatrix > &state_eq_deriv_uu, std::vector< StateInputDimMatrix > &state_eq_deriv_xu) const =0
 Calculate first-order and second-order derivatives of discrete state equation. More...
 
virtual void calcRunningCostDeriv (double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateDimVector > running_cost_deriv_x, Eigen::Ref< InputDimVector > running_cost_deriv_u) const =0
 Calculate first-order derivatives of running cost. More...
 
virtual void calcRunningCostDeriv (double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateDimVector > running_cost_deriv_x, Eigen::Ref< InputDimVector > running_cost_deriv_u, Eigen::Ref< StateStateDimMatrix > running_cost_deriv_xx, Eigen::Ref< InputInputDimMatrix > running_cost_deriv_uu, Eigen::Ref< StateInputDimMatrix > running_cost_deriv_xu) const =0
 Calculate first-order and second-order derivatives of running cost. More...
 
virtual void calcTerminalCostDeriv (double t, const StateDimVector &x, Eigen::Ref< StateDimVector > terminal_cost_deriv_x) const =0
 Calculate first-order derivatives of terminal cost. More...
 
virtual void calcTerminalCostDeriv (double t, const StateDimVector &x, Eigen::Ref< StateDimVector > terminal_cost_deriv_x, Eigen::Ref< StateStateDimMatrix > terminal_cost_deriv_xx) const =0
 Calculate first-order and second-order derivatives of terminal cost. More...
 

Static Public Member Functions

static constexpr int stateDim ()
 Gets the state dimension. More...
 

Protected Attributes

const double dt_ = 0
 Discretization timestep [sec]. More...
 

Detailed Description

template<int StateDim, int InputDim>
class nmpc_ddp::DDPProblem< StateDim, InputDim >

DDP problem.

Template Parameters
StateDimstate dimension (fixed only)
InputDiminput dimension (fixed or dynamic (i.e., Eigen::Dynamic))

Definition at line 16 of file DDPProblem.h.

Member Typedef Documentation

◆ InputDimVector

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::InputDimVector = Eigen::Matrix<double, InputDim, 1>

Type of vector of input dimension.

Definition at line 23 of file DDPProblem.h.

◆ InputInputDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::InputInputDimMatrix = Eigen::Matrix<double, InputDim, InputDim>

Type of matrix of input x input dimension.

Definition at line 29 of file DDPProblem.h.

◆ InputStateDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::InputStateDimMatrix = Eigen::Matrix<double, InputDim, StateDim>

Type of matrix of input x state dimension.

Definition at line 35 of file DDPProblem.h.

◆ StateDimVector

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::StateDimVector = Eigen::Matrix<double, StateDim, 1>

Type of vector of state dimension.

Definition at line 20 of file DDPProblem.h.

◆ StateInputDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::StateInputDimMatrix = Eigen::Matrix<double, StateDim, InputDim>

Type of matrix of state x input dimension.

Definition at line 32 of file DDPProblem.h.

◆ StateStateDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPProblem< StateDim, InputDim >::StateStateDimMatrix = Eigen::Matrix<double, StateDim, StateDim>

Type of matrix of state x state dimension.

Definition at line 26 of file DDPProblem.h.

Constructor & Destructor Documentation

◆ DDPProblem()

template<int StateDim, int InputDim>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW nmpc_ddp::DDPProblem< StateDim, InputDim >::DDPProblem ( double  dt)
inline

Constructor.

Parameters
dtdiscretization timestep [sec]

Definition at line 43 of file DDPProblem.h.

Member Function Documentation

◆ calcRunningCostDeriv() [1/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcRunningCostDeriv ( double  t,
const StateDimVector x,
const InputDimVector u,
Eigen::Ref< StateDimVector running_cost_deriv_x,
Eigen::Ref< InputDimVector running_cost_deriv_u 
) const
pure virtual

Calculate first-order derivatives of running cost.

Parameters
ttime [sec]
xstate
uinput
running_cost_deriv_xfirst-order derivative of running cost w.r.t. state
running_cost_deriv_ufirst-order derivative of running cost w.r.t. input

◆ calcRunningCostDeriv() [2/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcRunningCostDeriv ( double  t,
const StateDimVector x,
const InputDimVector u,
Eigen::Ref< StateDimVector running_cost_deriv_x,
Eigen::Ref< InputDimVector running_cost_deriv_u,
Eigen::Ref< StateStateDimMatrix running_cost_deriv_xx,
Eigen::Ref< InputInputDimMatrix running_cost_deriv_uu,
Eigen::Ref< StateInputDimMatrix running_cost_deriv_xu 
) const
pure virtual

Calculate first-order and second-order derivatives of running cost.

Parameters
ttime [sec]
xstate
uinput
running_cost_deriv_xfirst-order derivative of running cost w.r.t. state
running_cost_deriv_ufirst-order derivative of running cost w.r.t. input
running_cost_deriv_xxsecond-order derivative of running cost w.r.t. state
running_cost_deriv_uusecond-order derivative of running cost w.r.t. input
running_cost_deriv_xusecond-order derivative of running cost w.r.t. state and input

◆ calcStateEqDeriv() [1/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcStateEqDeriv ( double  t,
const StateDimVector x,
const InputDimVector u,
Eigen::Ref< StateStateDimMatrix state_eq_deriv_x,
Eigen::Ref< StateInputDimMatrix state_eq_deriv_u 
) const
pure virtual

Calculate first-order derivatives of discrete state equation.

Parameters
ttime [sec]
xstate
uinput
state_eq_deriv_xfirst-order derivative of state equation w.r.t. state
state_eq_deriv_ufirst-order derivative of state equation w.r.t. input

◆ calcStateEqDeriv() [2/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcStateEqDeriv ( double  t,
const StateDimVector x,
const InputDimVector u,
Eigen::Ref< StateStateDimMatrix state_eq_deriv_x,
Eigen::Ref< StateInputDimMatrix state_eq_deriv_u,
std::vector< StateStateDimMatrix > &  state_eq_deriv_xx,
std::vector< InputInputDimMatrix > &  state_eq_deriv_uu,
std::vector< StateInputDimMatrix > &  state_eq_deriv_xu 
) const
pure virtual

Calculate first-order and second-order derivatives of discrete state equation.

Parameters
ttime [sec]
xstate
uinput
state_eq_deriv_xfirst-order derivative of state equation w.r.t. state
state_eq_deriv_ufirst-order derivative of state equation w.r.t. input
state_eq_deriv_xxsecond-order derivative of state equation w.r.t. state
state_eq_deriv_uusecond-order derivative of state equation w.r.t. input
state_eq_deriv_xusecond-order derivative of state equation w.r.t. state and input

◆ calcTerminalCostDeriv() [1/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcTerminalCostDeriv ( double  t,
const StateDimVector x,
Eigen::Ref< StateDimVector terminal_cost_deriv_x 
) const
pure virtual

Calculate first-order derivatives of terminal cost.

Parameters
ttime [sec]
xstate
terminal_cost_deriv_xfirst-order derivative of terminal cost w.r.t. state

◆ calcTerminalCostDeriv() [2/2]

template<int StateDim, int InputDim>
virtual void nmpc_ddp::DDPProblem< StateDim, InputDim >::calcTerminalCostDeriv ( double  t,
const StateDimVector x,
Eigen::Ref< StateDimVector terminal_cost_deriv_x,
Eigen::Ref< StateStateDimMatrix terminal_cost_deriv_xx 
) const
pure virtual

Calculate first-order and second-order derivatives of terminal cost.

Parameters
ttime [sec]
xstate
terminal_cost_deriv_xfirst-order derivative of terminal cost w.r.t. state
terminal_cost_deriv_xxsecond-order derivative of terminal cost w.r.t. state

◆ dt()

template<int StateDim, int InputDim>
double nmpc_ddp::DDPProblem< StateDim, InputDim >::dt ( ) const
inline

Gets the discretization timestep [sec].

Definition at line 88 of file DDPProblem.h.

◆ inputDim() [1/2]

template<int StateDim, int InputDim>
virtual int nmpc_ddp::DDPProblem< StateDim, InputDim >::inputDim ( ) const
inlinevirtual

Gets the input dimension.

Note
If input dimension is dynamic, this must not be called. Instead, inputDim(t) must be called passing time as a parameter.

Definition at line 61 of file DDPProblem.h.

◆ inputDim() [2/2]

template<int StateDim, int InputDim>
virtual int nmpc_ddp::DDPProblem< StateDim, InputDim >::inputDim ( double  ) const
inlinevirtual

Gets the input dimension.

Parameters
ttime
Note
If input dimension is dynamic, this must be overridden.

Definition at line 74 of file DDPProblem.h.

◆ runningCost()

template<int StateDim, int InputDim>
virtual double nmpc_ddp::DDPProblem< StateDim, InputDim >::runningCost ( double  t,
const StateDimVector x,
const InputDimVector u 
) const
pure virtual

Calculate running cost.

Parameters
ttime [sec]
xcurrent state (x[k])
ucurrent input (u[k])
Returns
running cost (L[k])

◆ stateDim()

template<int StateDim, int InputDim>
static constexpr int nmpc_ddp::DDPProblem< StateDim, InputDim >::stateDim ( )
inlinestaticconstexpr

Gets the state dimension.

Definition at line 52 of file DDPProblem.h.

◆ stateEq()

template<int StateDim, int InputDim>
virtual StateDimVector nmpc_ddp::DDPProblem< StateDim, InputDim >::stateEq ( double  t,
const StateDimVector x,
const InputDimVector u 
) const
pure virtual

Calculate discrete state equation.

Parameters
ttime [sec]
xcurrent state (x[k])
ucurrent input (u[k])
Returns
next state (x[k+1])

◆ terminalCost()

template<int StateDim, int InputDim>
virtual double nmpc_ddp::DDPProblem< StateDim, InputDim >::terminalCost ( double  t,
const StateDimVector x 
) const
pure virtual

Calculate terminal cost.

Parameters
ttime [sec]
xcurrent state (x[k])
Returns
terminal cost (phi[k])

Member Data Documentation

◆ dt_

template<int StateDim, int InputDim>
const double nmpc_ddp::DDPProblem< StateDim, InputDim >::dt_ = 0
protected

Discretization timestep [sec].

Definition at line 202 of file DDPProblem.h.


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