Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00032 #include <acado/code_generation/export_simulink_interface.hpp>
00033 #include <acado/code_generation/templates/templates.hpp>
00034
00035 #include <sstream>
00036
00037 using namespace std;
00038
00039 BEGIN_NAMESPACE_ACADO
00040
00041
00042 ExportSimulinkInterface::ExportSimulinkInterface( const std::string& _makefileName,
00043 const std::string& _wrapperHeaderFileName,
00044 const std::string& _wrapperSourceFileName,
00045 const std::string& _moduleName,
00046 const std::string& _commonHeaderName,
00047 const std::string& _realString,
00048 const std::string& _intString,
00049 int _precision,
00050 const std::string& _commentString
00051 )
00052 : makefile(MAKEFILE_SFUN_QPOASES, _makefileName, "", _realString, _intString, _precision, "%"),
00053 wrapperSource(SOLVER_SFUN_SOURCE, _wrapperSourceFileName, _commonHeaderName, _realString, _intString, _precision, _commentString),
00054 wrapperHeader(SOLVER_SFUN_HEADER, _wrapperHeaderFileName, _commonHeaderName, _realString, _intString, _precision, _commentString),
00055 moduleName( _moduleName )
00056 {}
00057
00058
00059 returnValue ExportSimulinkInterface::configure( unsigned N,
00060 unsigned NX,
00061 unsigned NDX,
00062 unsigned NXA,
00063 unsigned NU,
00064 unsigned NOD,
00065 unsigned NY,
00066 unsigned NYN,
00067 bool _initialStateFixed,
00068 unsigned _wMatrixType,
00069 bool _hardcodedConstraints,
00070 bool _useArrivalCost,
00071 bool _compCovMatrix,
00072 std::string _qpSolver
00073 )
00074 {
00075
00076
00077
00078
00079 wrapperSource.dictionary[ "@MODULE_NAME@" ] = moduleName;
00080
00081 wrapperSource.fillTemplate();
00082
00083
00084
00085
00086 wrapperHeader.dictionary[ "@MODULE_NAME@" ] = moduleName;
00087
00088 wrapperHeader.fillTemplate();
00089
00090
00091
00092
00093
00094 makefile.dictionary[ "@MODULE_NAME@" ] = moduleName;
00095 makefile.dictionary[ "@REAL_TYPE@" ] = makefile.realString;
00096
00097 makefile.dictionary[ "@N@" ] = toString( N );
00098 makefile.dictionary[ "@NX@" ] = toString( NX );
00099 makefile.dictionary[ "@NXA@" ] = toString( NXA );
00100 makefile.dictionary[ "@NDX@" ] = toString( NDX );
00101 makefile.dictionary[ "@NU@" ] = toString( NU );
00102 makefile.dictionary[ "@NOD@" ] = toString( NOD );
00103 makefile.dictionary[ "@NY@" ] = toString( NY );
00104 makefile.dictionary[ "@NYN@" ] = toString( NYN );
00105
00106 makefile.dictionary[ "@INIT_STATE_FIXED@" ] = _initialStateFixed == true ? "1" : "0";
00107
00108 makefile.dictionary[ "@WEIGHT_MATRIX_TYPE@" ] = toString( _wMatrixType );
00109
00110 makefile.dictionary[ "@HARCODED_CONSTRAINTS@" ] = _hardcodedConstraints == true ? "1" : "0";
00111
00112 makefile.dictionary[ "@ARRIVAL_COST@" ] = _useArrivalCost == true ? "1" : "0";
00113
00114 makefile.dictionary[ "@COV_MATRIX@" ] = _compCovMatrix == true ? "1" : "0";
00115
00116 makefile.dictionary[ "@QP_SOLVER@" ] = _qpSolver;
00117
00118 makefile.fillTemplate();
00119
00120 return SUCCESSFUL_RETURN;
00121 }
00122
00123 returnValue ExportSimulinkInterface::exportCode()
00124 {
00125 makefile.exportCode();
00126 wrapperSource.exportCode();
00127 wrapperHeader.exportCode();
00128
00129 return SUCCESSFUL_RETURN;
00130 }
00131
00132
00133 CLOSE_NAMESPACE_ACADO