DirectTrajectoryOptimization
v0.3
|
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 ¶mFile, 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 |
This class allows users to solve direct trajectory optimization problems. using different solvers (ipopt/snopt) and different direct methods for trajectory optimization.
DIMENSIONS | the class defining the vector types and structures with adequate sizes. |
|
inlinestatic |
Create a new DTOSolver instance for single phase problem.
[in] | dynamics | The dynamics of your problem. |
[in] | derivatives | The derivatives of your problem. |
[in] | costFunction | The chosen cost function for the NLP. |
[in] | constraints | The chosen vector of constraints for the NLP. |
[in] | duration | Time bounds (Tmin, Tmax) |
[in] | numberOfNodes | Number of nodes for trajectory discretization. |
[in] | solverType | The solver of to employ for the solution of this NLP - see related enum for options. |
[in] | methodType | The particular direct method to employ for trajectory optimization - see related enum for options. |
[in] | solverVerbose | Show output of solver iterations. |
[in] | methodVerbose | Show output of discretization process. |
[in] | feasiblePointOnly | The type of optimization. |
|
inlinestatic |
Create a new DTOSolver instance.
[in] | dynamics | Vector of the dynamics of your problem. |
[in] | derivatives | Vector of derivatives of your problem. |
[in] | costFunction | The chosen cost function for the NLP. |
[in] | constraints | The chosen vector of constraints for the NLP. |
[in] | duration | Time bounds (Tmin, Tmax). |
[in] | numberOfNodes | Number of nodes for trajectory discretization. |
[in] | solverType | The solver of to employ for the solution of this NLP - see related enum for options. |
[in] | methodType | The particular direct method to employ for trajectory optimization - see related enum for options. |
[in] | solverVerbose | Show output of solver iterations. |
[in] | methodVerbose | Show output of discretization process. |
[in] | feasiblePointOnly | The type of optimization. |
References DirectTrajectoryOptimization::Methods::DIRECT_TRANSCRIPTION, DirectTrajectoryOptimization::Solvers::IPOPT_SOLVER, DirectTrajectoryOptimization::Methods::MULTIPLE_SHOOTING, and DirectTrajectoryOptimization::Solvers::SNOPT_SOLVER.
Referenced by DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::Create().
|
inline |
Get state control and time solution.
[out] | yTraj | The state trajectory solution |
[out] | uTraj | The control trajectory solution |
[out] | hTraj | the time increments solution |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
|
inline |
Get state control , time and phaseId solution.
[out] | yTraj | The state trajectory solution |
[out] | uTraj | The control trajectory solution |
[out] | hTraj | the time increments solution |
[out] | phaseId | The phase Id solution |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
|
inline |
Get final value of constraint vector.
[out] | fVec | The vector of cost function and constraints |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
|
inline |
Initialize the DTOSolver problem.
[in] | problemName | The name of the problem. |
[in] | outputFile | The name of the output file. |
[in] | paramFile | The parameters file (non implemented) |
[in] | computeJacobian | Flag indicating user is providing Jacobians |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
|
inline |
Set constant control trajectory bounds.
[in] | lb | control lower bound |
[in] | ub | control upper bound |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set trajectory of control bounds.
[in] | lb | control trajectory of lower bounds |
[in] | ub | control trajectory of upper bounds |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
SetDircolMethod.
[in] | dmc | 1 The type of direct collocation method (1-Hermite-Simpson 0-Trapezoidal) |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set final state free of bounds.
[in] | state_number | The index of the state to be free |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set pointer to function evaluating guard function.
[in] | fcnVector | Pointer to the guard function |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set percentages of nodes per phase.
[in] | nodeSplit | Eigen integer vector indicating percentage of nodes for each phase |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set constant state trajectory bounds.
[in] | lb | state lower bound |
[in] | ub | state upper bound |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set trajectory of state bounds.
[in] | lb | state trajectory of lower bounds |
[in] | ub | state trajectory of upper bounds |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Set bounds for the time increments between nodes.
[in] | h_min | positive minimum time increment |
[in] | h_max | positive maximum time increment |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method.
|
inline |
Change Verbosity level for solver and method.
[in] | verbose | Flag indicating verbosity |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_method, and DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
|
inline |
Solves the DTO problem.
[in] | warminit | Flag indicating warmstart |
References DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver.
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().
std::shared_ptr<DTOSolverInterface<DIMENSIONS> > DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::_solver |
The pointer to the Solver
Referenced by DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::GetDTOSolution(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::GetFVector(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::InitializeSolver(), DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::SetVerbosity(), and DirectTrajectoryOptimization::DirectTrajectoryOptimizationProblem< DIMENSIONS >::Solve().