rocket_with_templates_ocp.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00033 #ifndef ROCKET_WITH_TEMPLATES_HPP
00034 #define ROCKET_WITH_TEMPLATES_HPP
00035 
00036 // problem dimensions
00037 const int nxd = 3; // number of differential states
00038 const int nu  = 1; // number of controls
00039 
00040 // macros for variables
00041 #define S xd[0]
00042 #define V xd[1]
00043 #define M xd[2]
00044 
00045 #define U u[0]
00046 
00047 // Names (e.g. for plotting)
00048 const char* xd_names[nxd] = {"DifferentialState s","DifferentialState v","DifferentialState m"};
00049 const char* u_names[nu] = {"Control u"};
00050 
00051 // parameters
00052 const double t_start =  0.0;
00053 const double t_end   = 10.0;
00054 
00055 const bool   xd_0_fixed[nxd] = { true , true , true };
00056 const bool   xd_f_fixed[nxd] = { true , true , false};
00057 
00058 const double xd_0[nxd]       = {  0.0 ,  0.0 ,  1.0 };
00059 const double xd_f[nxd]       = { 10.0 ,  0.0 ,  0.0 };
00060 
00061 const bool   xd_has_lb[nxd]  = { false, true , false};
00062 const bool   xd_has_ub[nxd]  = { false, true,  false};
00063 
00064 const double xd_lb[nxd]       = {  0.0 , -0.01,  0.0 };
00065 const double xd_ub[nxd]       = {  0.0 ,   1.3,  0.0 };
00066 
00067 
00068 // evaluate objective function
00069 template <class DifferentialStateType, class ControlType, class ReturnType>
00070 void eval_F(const DifferentialStateType *xd, 
00071             const ControlType *u,
00072             ReturnType &lfun){
00073   
00074   lfun = U*U;
00075   
00076 }
00077 
00078 // evaluate right hand side of the ODE
00079 template <class DifferentialStateType, class ControlType, class ReturnType>
00080 void eval_G(const DifferentialStateType *xd, 
00081             const ControlType *u, 
00082             ReturnType *rhs){
00083   
00084   rhs[0] = V;
00085   rhs[1] = (U-0.02*V*V)/M;
00086   rhs[2] = -0.01*U*U;
00087   
00088 } 
00089 
00090 
00091 #undef U
00092 #undef V
00093 #undef S
00094 #undef M
00095 
00096 
00097 #endif // ROCKET_WITH_TEMPLATES_HPP
00098 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:55