DirectTrajectoryOptimization  v0.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS > Class Template Reference

This class allows users to solve direct trajectory optimization problems. using different solvers (ipopt/snopt) and different direct methods for trajectory optimization. More...

#include <direct_trajectory_optimization_problem.hpp>

Public Member Functions

 ~DirectTrajectoryOptimizationProblem ()
 Destruct the given DTOSolver instance.
 
void InitializeSolver (const std::string &problemName, const std::string &outputFile, const std::string &paramFile, const bool &computeJacobian)
 Initialize the DTOSolver problem. More...
 
void SetInitialState (const state_vector_t &state)
 Set initial state as hard constraint.
 
void SetFinalState (const state_vector_t &state)
 Set final state as hard constraint.
 
void SetFinalVelocityZero (const Eigen::VectorXi &vel_indexes)
 Set final velocity zero as hard constraint.
 
void SetInitialControl (const control_vector_t &control)
 Set initial control.
 
void SetFinalControl (const control_vector_t &control)
 Set final control.
 
void SetEvenTimeIncrements (const bool &opt)
 Set even time increments as hard constraint.
 
void SetPercentageNodesPerDynamics (Eigen::VectorXd nodeSplit)
 Set percentages of nodes per phase. More...
 
void SetGuardFunction (std::vector< double(*)(state_vector_t &)> fcnVector)
 Set pointer to function evaluating guard function. More...
 
void Solve (bool warminit=false)
 Solves the DTO problem. More...
 
void SetVerbosity (bool verbose)
 Change Verbosity level for solver and method. More...
 
void GetDTOSolution (state_vector_array_t &yTraj, control_vector_array_t &uTraj, Eigen::VectorXd &hTraj)
 Get state control and time solution. More...
 
void GetDTOSolution (state_vector_array_t &yTraj, control_vector_array_t &uTraj, Eigen::VectorXd &hTraj, std::vector< int > &phaseId)
 Get state control , time and phaseId solution. More...
 
void GetFVector (Eigen::VectorXd &fVec)
 Get final value of constraint vector. More...
 
int ChangeNumberOfPoints ()
 Change the number of points after construction.
 
void SetStateBounds (const state_vector_t &lb, const state_vector_t &ub)
 Set constant state trajectory bounds. More...
 
void SetStateBounds (const state_vector_array_t &lb, const state_vector_array_t &ub)
 Set trajectory of state bounds. More...
 
void SetControlBounds (const control_vector_t &lb, const control_vector_t &ub)
 Set constant control trajectory bounds. More...
 
void SetControlBounds (const control_vector_array_t &lb, const control_vector_array_t &ub)
 Set trajectory of control bounds. More...
 
void SetFreeFinalState (int state_number)
 Set final state free of bounds. More...
 
void SetTimeIncrementsBounds (const double &h_min, const double &h_max)
 Set bounds for the time increments between nodes. More...
 
void SetDircolMethod (const int &dcm)
 SetDircolMethod. More...
 

Static Public Member Functions

static std::unique_ptr
< DirectTrajectoryOptimizationProblem
< DIMENSIONS > > 
CreateWithMultipleDynamics (std::vector< std::shared_ptr< DynamicsBase< DIMENSIONS > > > dynamics, std::vector< std::shared_ptr< DerivativesBaseDS< DIMENSIONS > > > derivatives, std::shared_ptr< BaseClass::CostFunctionBase< DIMENSIONS > > costFunction, std::vector< std::shared_ptr< BaseClass::ConstraintsBase< DIMENSIONS > > > constraints, Eigen::Vector2d duration, int numberOfNodes, Solvers::solver_t solverType, Methods::method_t methodType, bool solverVerbose, bool methodVerbose, bool feasiblePointOnly=false)
 Create a new DTOSolver instance. More...
 
static std::unique_ptr
< DirectTrajectoryOptimizationProblem
< DIMENSIONS > > 
Create (std::shared_ptr< DynamicsBase< DIMENSIONS > > dynamics, std::shared_ptr< DerivativesBaseDS< DIMENSIONS > > derivatives, std::shared_ptr< BaseClass::CostFunctionBase< DIMENSIONS > > costFunction, std::shared_ptr< BaseClass::ConstraintsBase< DIMENSIONS > > constraints, Eigen::Vector2d duration, int numberOfNodes, Solvers::solver_t solverType, Methods::method_t methodType, bool solverVerbose, bool methodVerbose, bool feasiblePointOnly=false)
 Create a new DTOSolver instance for single phase problem. More...
 

Public Attributes

std::shared_ptr
< DTOMethodInterface
< DIMENSIONS > > 
_method
 
std::shared_ptr
< DTOSolverInterface
< DIMENSIONS > > 
_solver
 

Detailed Description

template<typename DIMENSIONS>
class DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >

This class allows users to solve direct trajectory optimization problems. using different solvers (ipopt/snopt) and different direct methods for trajectory optimization.

Template Parameters
DIMENSIONSthe class defining the vector types and structures with adequate sizes.

Member Function Documentation

template<typename DIMENSIONS >
static std::unique_ptr<DirectTrajectoryOptimizationProblem<DIMENSIONS> > DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::Create ( std::shared_ptr< DynamicsBase< DIMENSIONS > >  dynamics,
std::shared_ptr< DerivativesBaseDS< DIMENSIONS > >  derivatives,
std::shared_ptr< BaseClass::CostFunctionBase< DIMENSIONS > >  costFunction,
std::shared_ptr< BaseClass::ConstraintsBase< DIMENSIONS > >  constraints,
Eigen::Vector2d  duration,
int  numberOfNodes,
Solvers::solver_t  solverType,
Methods::method_t  methodType,
bool  solverVerbose,
bool  methodVerbose,
bool  feasiblePointOnly = false 
)
inlinestatic

Create a new DTOSolver instance for single phase problem.

Parameters
[in]dynamicsThe dynamics of your problem.
[in]derivativesThe derivatives of your problem.
[in]costFunctionThe chosen cost function for the NLP.
[in]constraintsThe chosen vector of constraints for the NLP.
[in]durationTime bounds (Tmin, Tmax)
[in]numberOfNodesNumber of nodes for trajectory discretization.
[in]solverTypeThe solver of to employ for the solution of this NLP - see related enum for options.
[in]methodTypeThe particular direct method to employ for trajectory optimization - see related enum for options.
[in]solverVerboseShow output of solver iterations.
[in]methodVerboseShow output of discretization process.
[in]feasiblePointOnlyThe type of optimization.
Returns
A unique pointer to the created solver.
Examples:
acrobot_ipopt_example.cpp, and acrobot_snopt_example.cpp.

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::CreateWithMultipleDynamics().

template<typename DIMENSIONS >
static std::unique_ptr<DirectTrajectoryOptimizationProblem<DIMENSIONS> > DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::CreateWithMultipleDynamics ( std::vector< std::shared_ptr< DynamicsBase< DIMENSIONS > > >  dynamics,
std::vector< std::shared_ptr< DerivativesBaseDS< DIMENSIONS > > >  derivatives,
std::shared_ptr< BaseClass::CostFunctionBase< DIMENSIONS > >  costFunction,
std::vector< std::shared_ptr< BaseClass::ConstraintsBase< DIMENSIONS > > >  constraints,
Eigen::Vector2d  duration,
int  numberOfNodes,
Solvers::solver_t  solverType,
Methods::method_t  methodType,
bool  solverVerbose,
bool  methodVerbose,
bool  feasiblePointOnly = false 
)
inlinestatic

Create a new DTOSolver instance.

Parameters
[in]dynamicsVector of the dynamics of your problem.
[in]derivativesVector of derivatives of your problem.
[in]costFunctionThe chosen cost function for the NLP.
[in]constraintsThe chosen vector of constraints for the NLP.
[in]durationTime bounds (Tmin, Tmax).
[in]numberOfNodesNumber of nodes for trajectory discretization.
[in]solverTypeThe solver of to employ for the solution of this NLP - see related enum for options.
[in]methodTypeThe particular direct method to employ for trajectory optimization - see related enum for options.
[in]solverVerboseShow output of solver iterations.
[in]methodVerboseShow output of discretization process.
[in]feasiblePointOnlyThe type of optimization.
Returns
A unique pointer to the created solver.

References DirectTrajectoryOptimization::Methods::DIRECT_TRANSCRIPTION, DirectTrajectoryOptimization::Solvers::IPOPT_SOLVER, DirectTrajectoryOptimization::Methods::MULTIPLE_SHOOTING, and DirectTrajectoryOptimization::Solvers::SNOPT_SOLVER.

Referenced by DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::Create().

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::GetDTOSolution ( state_vector_array_t &  yTraj,
control_vector_array_t &  uTraj,
Eigen::VectorXd &  hTraj 
)
inline

Get state control and time solution.

Parameters
[out]yTrajThe state trajectory solution
[out]uTrajThe control trajectory solution
[out]hTrajthe time increments solution

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::GetDTOSolution ( state_vector_array_t &  yTraj,
control_vector_array_t &  uTraj,
Eigen::VectorXd &  hTraj,
std::vector< int > &  phaseId 
)
inline

Get state control , time and phaseId solution.

Parameters
[out]yTrajThe state trajectory solution
[out]uTrajThe control trajectory solution
[out]hTrajthe time increments solution
[out]phaseIdThe phase Id solution

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::GetFVector ( Eigen::VectorXd &  fVec)
inline

Get final value of constraint vector.

Parameters
[out]fVecThe vector of cost function and constraints

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::InitializeSolver ( const std::string &  problemName,
const std::string &  outputFile,
const std::string &  paramFile,
const bool &  computeJacobian 
)
inline

Initialize the DTOSolver problem.

Parameters
[in]problemNameThe name of the problem.
[in]outputFileThe name of the output file.
[in]paramFileThe parameters file (non implemented)
[in]computeJacobianFlag indicating user is providing Jacobians

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetControlBounds ( const control_vector_t &  lb,
const control_vector_t &  ub 
)
inline

Set constant control trajectory bounds.

Parameters
[in]lbcontrol lower bound
[in]ubcontrol upper bound

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetControlBounds ( const control_vector_array_t &  lb,
const control_vector_array_t &  ub 
)
inline

Set trajectory of control bounds.

Parameters
[in]lbcontrol trajectory of lower bounds
[in]ubcontrol trajectory of upper bounds

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetDircolMethod ( const int &  dcm)
inline

SetDircolMethod.

Parameters
[in]dmc1 The type of direct collocation method (1-Hermite-Simpson 0-Trapezoidal)

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetFreeFinalState ( int  state_number)
inline

Set final state free of bounds.

Parameters
[in]state_numberThe index of the state to be free

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetGuardFunction ( std::vector< double(*)(state_vector_t &)>  fcnVector)
inline

Set pointer to function evaluating guard function.

Parameters
[in]fcnVectorPointer to the guard function

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetPercentageNodesPerDynamics ( Eigen::VectorXd  nodeSplit)
inline

Set percentages of nodes per phase.

Parameters
[in]nodeSplitEigen integer vector indicating percentage of nodes for each phase

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetStateBounds ( const state_vector_t &  lb,
const state_vector_t &  ub 
)
inline

Set constant state trajectory bounds.

Parameters
[in]lbstate lower bound
[in]ubstate upper bound

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetStateBounds ( const state_vector_array_t &  lb,
const state_vector_array_t &  ub 
)
inline

Set trajectory of state bounds.

Parameters
[in]lbstate trajectory of lower bounds
[in]ubstate trajectory of upper bounds

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetTimeIncrementsBounds ( const double &  h_min,
const double &  h_max 
)
inline

Set bounds for the time increments between nodes.

Parameters
[in]h_minpositive minimum time increment
[in]h_maxpositive maximum time increment

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.

template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetVerbosity ( bool  verbose)
inline
template<typename DIMENSIONS >
void DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::Solve ( bool  warminit = false)
inline

Solves the DTO problem.

Parameters
[in]warminitFlag indicating warmstart

References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.

Member Data Documentation

template<typename DIMENSIONS >
std::shared_ptr<DTOMethodInterface<DIMENSIONS> > DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method

The pointer to the DT method

Referenced by DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::ChangeNumberOfPoints(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetControlBounds(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetDircolMethod(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetEvenTimeIncrements(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetFinalControl(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetFinalState(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetFinalVelocityZero(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetFreeFinalState(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetGuardFunction(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetInitialControl(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetInitialState(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetPercentageNodesPerDynamics(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetStateBounds(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetTimeIncrementsBounds(), and DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetVerbosity().


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