DirectTrajectoryOptimization  v0.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
MinimumEnergyCostBolza.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 MINIMUMENERGYCOSTBOLZA_HPP_
32 #define MINIMUMENERGYCOSTBOLZA_HPP_
33 
35 
36 namespace DirectTrajectoryOptimization {
37 namespace Costs {
38 
42 template<class DIMENSIONS>
44 
45 public :
46 
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 
49  typedef typename DIMENSIONS::state_vector_t state_vector_t;
50  typedef typename DIMENSIONS::control_vector_t control_vector_t;
51  typedef typename DIMENSIONS::control_matrix_t control_matrix_t;
52 
57  MinimumEnergyCostBolza(const control_matrix_t & R = control_matrix_t::Identity()):R_matrix(R)
58  { }
59 
60  virtual ~MinimumEnergyCostBolza() {}
61 
62 private :
63 
64  double phi(const state_vector_t & x, const control_vector_t & u);
65  state_vector_t phi_x(const state_vector_t &x, const control_vector_t & u);
66  control_vector_t phi_u(const state_vector_t &x, const control_vector_t & u);
67 
68  double terminalCost(const state_vector_t &x_f);
69  state_vector_t terminalCostDerivative(const state_vector_t &x_f);
70  control_matrix_t R_matrix;
71 
72 };
73 
74 template <class DIMENSIONS>
75 double MinimumEnergyCostBolza<DIMENSIONS>::phi(const state_vector_t &x, const control_vector_t & u) {
76 
77  double val = (u.transpose()*R_matrix*u)(0);
78  return val;
79 }
80 
81 template <class DIMENSIONS>
82 typename DIMENSIONS::state_vector_t MinimumEnergyCostBolza<DIMENSIONS>::phi_x(const state_vector_t &x,
83  const control_vector_t & u) {
84 
85  return(state_vector_t::Zero());
86 }
87 
88 template <class DIMENSIONS>
89 typename DIMENSIONS::control_vector_t MinimumEnergyCostBolza<DIMENSIONS>::phi_u(const state_vector_t &x,
90  const control_vector_t & u) {
91  control_vector_t val = 2*R_matrix*u;
92  return(val);
93 }
94 
95 template <class DIMENSIONS>
96 double MinimumEnergyCostBolza<DIMENSIONS>::terminalCost(const state_vector_t &x_f) {
97 
98  return 0;
99 }
100 
101 template <class DIMENSIONS>
102 typename DIMENSIONS::state_vector_t MinimumEnergyCostBolza<DIMENSIONS>::terminalCostDerivative(const state_vector_t &x_f) {
103 
104  return(state_vector_t::Zero());
105 }
106 
107 }
108 }
109 #endif /* MINIMUMENERGYCOSTBOLZA_HPP_ */
MinimumEnergyCostBolza(const control_matrix_t &R=control_matrix_t::Identity())
Constructor.
Definition: MinimumEnergyCostBolza.hpp:57
Base class to derive cost function of the type J = sum_k( phi_k(x_k,u_k,k) ) + H(X_K) ...
Base class to derive cost function of the type J = sum_k( phi_k(x_k,u_k,k) ) + H(X_K) ...
Definition: CostFunctionBolza.hpp:44
Bolza type cost function minimizing the total energy e = uTRu.
Definition: MinimumEnergyCostBolza.hpp:43