rocket_with_templates_ocp.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
33 #ifndef ROCKET_WITH_TEMPLATES_HPP
34 #define ROCKET_WITH_TEMPLATES_HPP
35 
36 // problem dimensions
37 const int nxd = 3; // number of differential states
38 const int nu = 1; // number of controls
39 
40 // macros for variables
41 #define S xd[0]
42 #define V xd[1]
43 #define M xd[2]
44 
45 #define U u[0]
46 
47 // Names (e.g. for plotting)
48 const char* xd_names[nxd] = {"DifferentialState s","DifferentialState v","DifferentialState m"};
49 const char* u_names[nu] = {"Control u"};
50 
51 // parameters
52 const double t_start = 0.0;
53 const double t_end = 10.0;
54 
55 const bool xd_0_fixed[nxd] = { true , true , true };
56 const bool xd_f_fixed[nxd] = { true , true , false};
57 
58 const double xd_0[nxd] = { 0.0 , 0.0 , 1.0 };
59 const double xd_f[nxd] = { 10.0 , 0.0 , 0.0 };
60 
61 const bool xd_has_lb[nxd] = { false, true , false};
62 const bool xd_has_ub[nxd] = { false, true, false};
63 
64 const double xd_lb[nxd] = { 0.0 , -0.01, 0.0 };
65 const double xd_ub[nxd] = { 0.0 , 1.3, 0.0 };
66 
67 
68 // evaluate objective function
69 template <class DifferentialStateType, class ControlType, class ReturnType>
70 void eval_F(const DifferentialStateType *xd,
71  const ControlType *u,
72  ReturnType &lfun){
73 
74  lfun = U*U;
75 
76 }
77 
78 // evaluate right hand side of the ODE
79 template <class DifferentialStateType, class ControlType, class ReturnType>
80 void eval_G(const DifferentialStateType *xd,
81  const ControlType *u,
82  ReturnType *rhs){
83 
84  rhs[0] = V;
85  rhs[1] = (U-0.02*V*V)/M;
86  rhs[2] = -0.01*U*U;
87 
88 }
89 
90 
91 #undef U
92 #undef V
93 #undef S
94 #undef M
95 
96 
97 #endif // ROCKET_WITH_TEMPLATES_HPP
98 
return ReturnType(abs2(x.value()), x.derivatives()*(Scalar(2)*x.value()))
const double xd_ub[nxd]
const double xd_f[nxd]
const bool xd_0_fixed[nxd]
const char * u_names[nu]
const double xd_0[nxd]
const int nu
void eval_G(const DifferentialStateType *xd, const ControlType *u, ReturnType *rhs)
void eval_F(const DifferentialStateType *xd, const ControlType *u, ReturnType &lfun)
const bool xd_has_lb[nxd]
const double xd_lb[nxd]
void rhs(const real_t *x, real_t *f)
const double t_end
const bool xd_has_ub[nxd]
const double t_start
const bool xd_f_fixed[nxd]
const int nxd
const char * xd_names[nxd]


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:03