export_simulink_interface.cpp
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 
33 #include <acado/code_generation/templates/templates.hpp>
34 
35 #include <sstream>
36 
37 using namespace std;
38 
40 
41 
42 ExportSimulinkInterface::ExportSimulinkInterface( const std::string& _makefileName,
43  const std::string& _wrapperHeaderFileName,
44  const std::string& _wrapperSourceFileName,
45  const std::string& _moduleName,
46  const std::string& _modulePrefix,
47  const std::string& _commonHeaderName,
48  const std::string& _realString,
49  const std::string& _intString,
50  int _precision,
51  const std::string& _commentString
52  )
53  : makefile(MAKEFILE_SFUN_QPOASES, _makefileName, "", _realString, _intString, _precision, "%"),
54  wrapperSource(SOLVER_SFUN_SOURCE, _wrapperSourceFileName, _commonHeaderName, _realString, _intString, _precision, _commentString),
55  wrapperHeader(SOLVER_SFUN_HEADER, _wrapperHeaderFileName, _commonHeaderName, _realString, _intString, _precision, _commentString),
56  moduleName( _moduleName ),
57  modulePrefix( _modulePrefix )
58 {}
59 
60 
62  unsigned NX,
63  unsigned NDX,
64  unsigned NXA,
65  unsigned NU,
66  unsigned NOD,
67  unsigned NY,
68  unsigned NYN,
69  bool _initialStateFixed,
70  unsigned _wMatrixType,
71  bool _hardcodedConstraints,
72  bool _useArrivalCost,
73  bool _compCovMatrix,
74  std::string _qpSolver
75  )
76 {
77  //
78  // Source file configuration
79  //
80 
81  wrapperSource.dictionary[ "@MODULE_NAME@" ] = moduleName;
82  wrapperSource.dictionary[ "@MODULE_PREFIX@" ] = modulePrefix;
83 
85 
86  //
87  // Header file configuration
88  //
89  wrapperHeader.dictionary[ "@MODULE_NAME@" ] = moduleName;
90  wrapperHeader.dictionary[ "@MODULE_PREFIX@" ] = modulePrefix;
91 
93 
94  //
95  // Makefile configuration
96  //
97 
98  makefile.dictionary[ "@MODULE_NAME@" ] = moduleName;
99  makefile.dictionary[ "@MODULE_PREFIX@" ] = modulePrefix;
100 
101  makefile.dictionary[ "@REAL_TYPE@" ] = makefile.realString;
102 
103  makefile.dictionary[ "@N@" ] = toString( N );
104  makefile.dictionary[ "@NX@" ] = toString( NX );
105  makefile.dictionary[ "@NXA@" ] = toString( NXA );
106  makefile.dictionary[ "@NDX@" ] = toString( NDX );
107  makefile.dictionary[ "@NU@" ] = toString( NU );
108  makefile.dictionary[ "@NOD@" ] = toString( NOD );
109  makefile.dictionary[ "@NY@" ] = toString( NY );
110  makefile.dictionary[ "@NYN@" ] = toString( NYN );
111 
112  makefile.dictionary[ "@INIT_STATE_FIXED@" ] = _initialStateFixed == true ? "1" : "0";
113 
114  makefile.dictionary[ "@WEIGHT_MATRIX_TYPE@" ] = toString( _wMatrixType );
115 
116  makefile.dictionary[ "@HARCODED_CONSTRAINTS@" ] = _hardcodedConstraints == true ? "1" : "0";
117 
118  makefile.dictionary[ "@ARRIVAL_COST@" ] = _useArrivalCost == true ? "1" : "0";
119 
120  makefile.dictionary[ "@COV_MATRIX@" ] = _compCovMatrix == true ? "1" : "0";
121 
122  makefile.dictionary[ "@QP_SOLVER@" ] = _qpSolver;
123 
125 
126  return SUCCESSFUL_RETURN;
127 }
128 
130 {
134 
135  return SUCCESSFUL_RETURN;
136 }
137 
138 
#define N
std::map< std::string, std::string > dictionary
#define NY
returnValue configure(unsigned N, unsigned NX, unsigned NDX, unsigned NXA, unsigned NU, unsigned NP, unsigned NY, unsigned NYN, bool _initialStateFixed, unsigned _wMatrixType, bool _hardcodedConstraints, bool _useArrivalCost, bool _compCovMatrix, std::string _qpSolver)
Allows to pass back messages to the calling function.
string toString(T const &value)
#define CLOSE_NAMESPACE_ACADO
ExportSimulinkInterface(const std::string &_makefileName, const std::string &_wrapperHeaderFileName, const std::string &_wrapperSourceFileName, const std::string &_moduleName="acado", const std::string &_modulePrefix="ACADO", const std::string &_commonHeaderName="", const std::string &_realString="double", const std::string &_intString="int", int _precision=16, const std::string &_commentString=std::string())
#define NXA
std::string realString
#define NX
#define NU
#define BEGIN_NAMESPACE_ACADO
#define NYN
virtual returnValue exportCode() const
Definition: export_file.cpp:82


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