nmpc_ddp
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nmpc_ddp::DDPSolver< StateDim, InputDim > Class Template Reference

DDP solver. More...

#include <DDPSolver.h>

Collaboration diagram for nmpc_ddp::DDPSolver< StateDim, InputDim >:
Collaboration graph
[legend]

Classes

struct  ComputationDuration
 Data of computation duration. More...
 
struct  Configuration
 Configuration. More...
 
struct  ControlData
 Control data. More...
 
struct  Derivative
 Derivatives of DDP problem. More...
 
struct  TraceData
 Data to trace optimization loop. More...
 

Public Types

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

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW DDPSolver (const std::shared_ptr< DDPProblem< StateDim, InputDim >> &problem)
 Constructor. More...
 
Configurationconfig ()
 Accessor to configuration. More...
 
const Configurationconfig () const
 Const accessor to configuration. More...
 
bool solve (double current_t, const StateDimVector &current_x, const std::vector< InputDimVector > &initial_u_list)
 Solve optimization. More...
 
void setInputLimitsFunc (const std::function< std::array< InputDimVector, 2 >(double)> &input_limits_func)
 Set function to return input limits. More...
 
const ControlDatacontrolData () const
 Const accessor to control data calculated by solve(). More...
 
const std::vector< TraceData > & traceDataList () const
 Const accessor to trace data list. More...
 
const ComputationDurationcomputationDuration () const
 Const accessor to computation duration. More...
 
void dumpTraceDataList (const std::string &file_path) const
 Dump trace data list. More...
 

Protected Member Functions

int procOnce (int iter)
 Process one iteration. More...
 
bool backwardPass ()
 Process backward pass. More...
 
void forwardPass (double alpha)
 Process forward pass. More...
 

Protected Attributes

Configuration config_
 Configuration. More...
 
std::shared_ptr< DDPProblem< StateDim, InputDim > > problem_
 DDP problem. More...
 
std::vector< TraceDatatrace_data_list_
 Sequence of trace data. More...
 
std::function< std::array< InputDimVector, 2 >double)> input_limits_func_
 Function to return input limits (in the order of lower, upper) More...
 
ComputationDuration computation_duration_
 Computation duration data. More...
 
double current_t_ = 0
 Current time [sec]. More...
 
double lambda_ = 0
 Regularization coefficient. More...
 
double dlambda_ = 0
 Scaling factor of regularization coefficient. More...
 
ControlData control_data_
 Control data (sequence of state, input, and cost) More...
 
ControlData candidate_control_data_
 Candidate control data (sequence of state, input, and cost) More...
 
std::vector< InputDimVectork_list_
 Sequence of feedforward term for input (k[0], ..., k[N-1]) More...
 
std::vector< InputStateDimMatrixK_list_
 Sequence of feedback gain for input w.r.t. state error (K[0], ..., K[N-1]) More...
 
std::vector< Derivativederivative_list_
 Sequence of derivatives. More...
 
StateDimVector last_Vx_
 First-order derivative of value in last step of horizon. More...
 
StateStateDimMatrix last_Vxx_
 Second-order derivative of value in last step of horizon. More...
 
Eigen::Vector2d dV_
 Expected update of value. More...
 

Detailed Description

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

DDP solver.

Template Parameters
StateDimstate dimension
InputDiminput dimension

See the following for a detailed algorithm.

Definition at line 24 of file DDPSolver.h.

Member Typedef Documentation

◆ InputDimVector

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::InputDimVector = typename DDPProblem<StateDim, InputDim>::InputDimVector

Type of vector of input dimension.

Definition at line 31 of file DDPSolver.h.

◆ InputInputDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::InputInputDimMatrix = typename DDPProblem<StateDim, InputDim>::InputInputDimMatrix

Type of matrix of input x input dimension.

Definition at line 37 of file DDPSolver.h.

◆ InputStateDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::InputStateDimMatrix = typename DDPProblem<StateDim, InputDim>::InputStateDimMatrix

Type of matrix of input x state dimension.

Definition at line 43 of file DDPSolver.h.

◆ StateDimVector

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::StateDimVector = typename DDPProblem<StateDim, InputDim>::StateDimVector

Type of vector of state dimension.

Definition at line 28 of file DDPSolver.h.

◆ StateInputDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::StateInputDimMatrix = typename DDPProblem<StateDim, InputDim>::StateInputDimMatrix

Type of matrix of state x input dimension.

Definition at line 40 of file DDPSolver.h.

◆ StateStateDimMatrix

template<int StateDim, int InputDim>
using nmpc_ddp::DDPSolver< StateDim, InputDim >::StateStateDimMatrix = typename DDPProblem<StateDim, InputDim>::StateStateDimMatrix

Type of matrix of state x state dimension.

Definition at line 34 of file DDPSolver.h.

Constructor & Destructor Documentation

◆ DDPSolver()

template<int StateDim, int InputDim>
nmpc_ddp::DDPSolver< StateDim, InputDim >::DDPSolver ( const std::shared_ptr< DDPProblem< StateDim, InputDim >> &  problem)

Constructor.

Parameters
problemDDP problem

Definition at line 21 of file DDPSolver.hpp.

Member Function Documentation

◆ backwardPass()

template<int StateDim, int InputDim>
bool nmpc_ddp::DDPSolver< StateDim, InputDim >::backwardPass
protected

Process backward pass.

Returns
whether the process is finished successfully

Definition at line 343 of file DDPSolver.hpp.

◆ computationDuration()

template<int StateDim, int InputDim>
const ComputationDuration& nmpc_ddp::DDPSolver< StateDim, InputDim >::computationDuration ( ) const
inline

Const accessor to computation duration.

Definition at line 300 of file DDPSolver.h.

◆ config() [1/2]

template<int StateDim, int InputDim>
Configuration& nmpc_ddp::DDPSolver< StateDim, InputDim >::config ( )
inline

Accessor to configuration.

Definition at line 258 of file DDPSolver.h.

◆ config() [2/2]

template<int StateDim, int InputDim>
const Configuration& nmpc_ddp::DDPSolver< StateDim, InputDim >::config ( ) const
inline

Const accessor to configuration.

Definition at line 264 of file DDPSolver.h.

◆ controlData()

template<int StateDim, int InputDim>
const ControlData& nmpc_ddp::DDPSolver< StateDim, InputDim >::controlData ( ) const
inline

Const accessor to control data calculated by solve().

Definition at line 288 of file DDPSolver.h.

◆ dumpTraceDataList()

template<int StateDim, int InputDim>
void nmpc_ddp::DDPSolver< StateDim, InputDim >::dumpTraceDataList ( const std::string &  file_path) const

Dump trace data list.

Parameters
file_pathpath to output file

Definition at line 563 of file DDPSolver.hpp.

◆ forwardPass()

template<int StateDim, int InputDim>
void nmpc_ddp::DDPSolver< StateDim, InputDim >::forwardPass ( double  alpha)
protected

Process forward pass.

Parameters
alphascaling factor of k

Definition at line 537 of file DDPSolver.hpp.

◆ procOnce()

template<int StateDim, int InputDim>
int nmpc_ddp::DDPSolver< StateDim, InputDim >::procOnce ( int  iter)
protected

Process one iteration.

Parameters
itercurrent iteration
Returns
0 for continue, 1 for terminate, -1 for failure

Definition at line 144 of file DDPSolver.hpp.

◆ setInputLimitsFunc()

template<int StateDim, int InputDim>
void nmpc_ddp::DDPSolver< StateDim, InputDim >::setInputLimitsFunc ( const std::function< std::array< InputDimVector, 2 >(double)> &  input_limits_func)
inline

Set function to return input limits.

Parameters
input_limits_funcfunction to return input limits (in the order of lower, upper)
Note
The input limits are only considered when with_input_constraint in configuration is true.

Definition at line 282 of file DDPSolver.h.

◆ solve()

template<int StateDim, int InputDim>
bool nmpc_ddp::DDPSolver< StateDim, InputDim >::solve ( double  current_t,
const StateDimVector current_x,
const std::vector< InputDimVector > &  initial_u_list 
)

Solve optimization.

Parameters
current_tcurrent time [sec]
current_xcurrent state
initial_u_listinitial sequence of input
Returns
whether the process is finished successfully

Definition at line 27 of file DDPSolver.hpp.

◆ traceDataList()

template<int StateDim, int InputDim>
const std::vector<TraceData>& nmpc_ddp::DDPSolver< StateDim, InputDim >::traceDataList ( ) const
inline

Const accessor to trace data list.

Definition at line 294 of file DDPSolver.h.

Member Data Documentation

◆ candidate_control_data_

template<int StateDim, int InputDim>
ControlData nmpc_ddp::DDPSolver< StateDim, InputDim >::candidate_control_data_
protected

Candidate control data (sequence of state, input, and cost)

Definition at line 356 of file DDPSolver.h.

◆ computation_duration_

template<int StateDim, int InputDim>
ComputationDuration nmpc_ddp::DDPSolver< StateDim, InputDim >::computation_duration_
protected

Computation duration data.

Definition at line 341 of file DDPSolver.h.

◆ config_

template<int StateDim, int InputDim>
Configuration nmpc_ddp::DDPSolver< StateDim, InputDim >::config_
protected

Configuration.

Definition at line 329 of file DDPSolver.h.

◆ control_data_

template<int StateDim, int InputDim>
ControlData nmpc_ddp::DDPSolver< StateDim, InputDim >::control_data_
protected

Control data (sequence of state, input, and cost)

Definition at line 353 of file DDPSolver.h.

◆ current_t_

template<int StateDim, int InputDim>
double nmpc_ddp::DDPSolver< StateDim, InputDim >::current_t_ = 0
protected

Current time [sec].

Definition at line 344 of file DDPSolver.h.

◆ derivative_list_

template<int StateDim, int InputDim>
std::vector<Derivative> nmpc_ddp::DDPSolver< StateDim, InputDim >::derivative_list_
protected

Sequence of derivatives.

Definition at line 365 of file DDPSolver.h.

◆ dlambda_

template<int StateDim, int InputDim>
double nmpc_ddp::DDPSolver< StateDim, InputDim >::dlambda_ = 0
protected

Scaling factor of regularization coefficient.

Definition at line 350 of file DDPSolver.h.

◆ dV_

template<int StateDim, int InputDim>
Eigen::Vector2d nmpc_ddp::DDPSolver< StateDim, InputDim >::dV_
protected

Expected update of value.

Definition at line 374 of file DDPSolver.h.

◆ input_limits_func_

template<int StateDim, int InputDim>
std::function<std::array<InputDimVector, 2>double)> nmpc_ddp::DDPSolver< StateDim, InputDim >::input_limits_func_
protected

Function to return input limits (in the order of lower, upper)

Definition at line 338 of file DDPSolver.h.

◆ k_list_

template<int StateDim, int InputDim>
std::vector<InputDimVector> nmpc_ddp::DDPSolver< StateDim, InputDim >::k_list_
protected

Sequence of feedforward term for input (k[0], ..., k[N-1])

Definition at line 359 of file DDPSolver.h.

◆ K_list_

template<int StateDim, int InputDim>
std::vector<InputStateDimMatrix> nmpc_ddp::DDPSolver< StateDim, InputDim >::K_list_
protected

Sequence of feedback gain for input w.r.t. state error (K[0], ..., K[N-1])

Definition at line 362 of file DDPSolver.h.

◆ lambda_

template<int StateDim, int InputDim>
double nmpc_ddp::DDPSolver< StateDim, InputDim >::lambda_ = 0
protected

Regularization coefficient.

Definition at line 347 of file DDPSolver.h.

◆ last_Vx_

template<int StateDim, int InputDim>
StateDimVector nmpc_ddp::DDPSolver< StateDim, InputDim >::last_Vx_
protected

First-order derivative of value in last step of horizon.

Definition at line 368 of file DDPSolver.h.

◆ last_Vxx_

template<int StateDim, int InputDim>
StateStateDimMatrix nmpc_ddp::DDPSolver< StateDim, InputDim >::last_Vxx_
protected

Second-order derivative of value in last step of horizon.

Definition at line 371 of file DDPSolver.h.

◆ problem_

template<int StateDim, int InputDim>
std::shared_ptr<DDPProblem<StateDim, InputDim> > nmpc_ddp::DDPSolver< StateDim, InputDim >::problem_
protected

DDP problem.

Definition at line 332 of file DDPSolver.h.

◆ trace_data_list_

template<int StateDim, int InputDim>
std::vector<TraceData> nmpc_ddp::DDPSolver< StateDim, InputDim >::trace_data_list_
protected

Sequence of trace data.

Definition at line 335 of file DDPSolver.h.


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