export_simulink_interface.cpp
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 
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         // Source file configuration
00077         //
00078 
00079         wrapperSource.dictionary[ "@MODULE_NAME@" ] = moduleName;
00080 
00081         wrapperSource.fillTemplate();
00082 
00083         //
00084         // Header file configuration
00085         //
00086         wrapperHeader.dictionary[ "@MODULE_NAME@" ] = moduleName;
00087 
00088         wrapperHeader.fillTemplate();
00089 
00090         //
00091         // Makefile configuration
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


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:37:01