DirectTrajectoryOptimization  v0.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
direct_transcription.hpp
Go to the documentation of this file.
1 /***********************************************************************************
2 Copyright (c) 2017, Diego Pardo. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6  * Redistributions of source code must retain the above copyright notice,
7  this list of conditions and the following disclaimer.
8  * Redistributions in binary form must reproduce the above copyright notice,
9  this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of ETH ZURICH nor the names of its contributors may be used
12  to endorse or promote products derived from this software without specific
13  prior written permission.
14 
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
16 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
18 SHALL ETH ZURICH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
19 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 ***************************************************************************************/
25 
31 #ifndef DIRECTRANSCRIPTION_HPP_
32 #define DIRECTRANSCRIPTION_HPP_
33 
34 #include <stdexcept>
35 #include <vector>
36 #include <iostream>
37 #include <fstream>
38 
39 #include <memory>
40 #include <Eigen/Dense>
41 
42 #include <dynamical_systems/base/DynamicsBase.hpp>
43 #include <dynamical_systems/base/DerivativesBaseDS.hpp>
47 
48 namespace DirectTrajectoryOptimization {
49 
54 template<class DIMENSIONS>
55 class DTODirectTranscription: public DTOMethodInterface<DIMENSIONS> {
56 
57 public:
58  //Required as class has Eigen Members
59  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 
61  typedef typename DIMENSIONS::state_vector_t state_vector_t;
62  typedef typename DIMENSIONS::control_vector_t control_vector_t;
63  typedef typename DIMENSIONS::state_vector_array_t state_vector_array_t;
64  typedef typename DIMENSIONS::control_vector_array_t control_vector_array_t;
65  typedef typename DIMENSIONS::control_gain_matrix_t control_gain_matrix_t;
66  typedef typename DIMENSIONS::state_matrix_t state_matrix_t;
67 
79  std::vector<std::shared_ptr<DynamicsBase<DIMENSIONS> > > dynamics,
80  std::vector<std::shared_ptr<DerivativesBaseDS<DIMENSIONS> > > derivatives,
81  std::shared_ptr<BaseClass::CostFunctionBase<DIMENSIONS> > costFunction,
82  std::vector<std::shared_ptr<BaseClass::ConstraintsBase<DIMENSIONS> > > constraints,
83  Eigen::Vector2d duration, int number_of_nodes, bool methodVerbose) :
84  DTOMethodInterface<DIMENSIONS>(dynamics, derivatives, costFunction,
85  constraints, duration, number_of_nodes, methodVerbose) {
86 
87  if (methodVerbose) {
88  std::cout << "DTO Object successfully created" << std::endl;
89  }
90  }
91 
92  virtual ~DTODirectTranscription() {}
93 
94 //protected: ToDo solve once test friends implemented
95 
96  virtual void evalSparseJacobianConstraint(double* val) override;
97  virtual void evaluateDefects(Eigen::VectorXd & defect_vector) override;
98 
99  virtual void SetDircolMethod(const int &dcm) override;
100 
101  int dircol_method = 0;
102  state_matrix_t I_y = state_matrix_t::Identity();
103 };
104 
105 } // namespace DirectTrajectoryOptimization
106 
108 
109 #endif /* DIRECTRANSCRIPTION_HPP_ */
This class implements Direct transcription.
Definition: direct_transcription.hpp:55
This class serves as a base interface for inheriting classes.
Definition: base_method_interface.hpp:60
Base class for constraints.
DTODirectTranscription(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 number_of_nodes, bool methodVerbose)
Constructor of DTODirectTranscription.
Definition: direct_transcription.hpp:78
Base class for TO constraints.
Definition: ConstraintsBase.hpp:46
Base class to derive cost functions.
Base class for direct methods.