bip exec_for_deliverable

parent 750a7bea
......@@ -7,5 +7,5 @@ package ujf.verimag.bip.userinterface.cli;
* use "svn annotate" and BLAME the one who has commited it !
*/
public class Version {
public static final String VERSION = "2022.03.054041-DEV";
public static final String VERSION = "2022.03.060929-DEV";
}
Το bip_exec_for_deliverable περιέχει το παράδειγμα για το imageDetection και το toy master.
Παρακάτω περιγράφεται η διαδικασία που ακολουθήθηκε για την δημιουργία του τρέχοντος κατάλογου,
ο οποίος αποτελείται από τα εξής αρχεία:
1. bip_example : Φάκελος του παραδείγματος, με την δυναμική βιβλιοθήκη,το modelDescription.xml,
το πρόγραμμα Inference.py (το οποίο χρησιμοποιείται από το bip για το inference), το yolo νευρωνικό
και τα σήματα / frames. Αυτός ο φάκελος ιδανικά μπορεί να γίνει zip και να μετατραπεί σε .fmu.
2. includes & src, ο πηγαίος κώδικας του toy master
3. create_master.sh το script που τρέχει για να κάνει compile τον toy master με τη δυναμική
βιβλιοθήκη και να παραχθεί το εκτελέσιμο. (για να τρέξει πρέπει να ανανεωθούν τα paths που περιέχει)
4. master το εκτελέσιμο που παράγεται
5. log_for_35_sim_steps.txt τα αποτελέσματα της εκτέλεσης του master και το παράδειγμα imageDetection.
Για την παραγώγη της δυναμικής βιβλιοθήκης του παραδείγματος εκτελέστηκαν οι παρακάτω εντολές που
εμπεριέχονται και στο "run.sh" το οποίο κάνει compile το bip engine και όλα τα παραδείγματα:
g++ -fPIC Deploy/Deploy.cpp learn/src/learn/* ../ext-cpp/utilities.cpp -I learn/include
-I ../ext-cpp/ -I $BIP2_ENGINE_GENERIC_DIR -I $BIP2_ENGINE_SPECIFIC_DIR -shared -o l
ibProject.so -L $BIP_PATH/distribution/build/bip-full/BIP-reference-engine-*/lib/static -lengine
Αφού παραχθεί το libProject.so του παραδείγματος τότε εκτελούμε το script "create_master.sh"
που βρίσκεται στο examples/master_example (στο project bip_fmu) με την παρακάτω εντολή:
./create_master.sh ../SpeedControlModule/modelDetection/imageDetection/ > log_for_35_sim_steps.txt
Το script δέχεται ως όρισμα το path που περιέχει το so και τα απαραίτητα αρχεία. Πιο συγκεκριμένα:
1. Δημιουργεί τον φάκελο bip_example
2. Δημιουργεί τον φάκελο bip_example/binaries
3. Δημιουργεί τον φάκελο bip_example/binaries/linux64
4. Δημιουργεί τον φάκελο bip_example/resources
5. Αντιγραφή του libProject.so στον φάκελο bip_example/binaries/linux64
6. Αντιγραφή του φακέλου Signs στο bip_example/resources
7. Αντιγραφή του φακέλου ext-cpp στο bip_example/resources
8. Αντιγραφή του modelDescription.xml στο bip_example (υπάρχει ένα στοιχειώδης modelDescription.xml στο
project bip_fmu στον φάκελο examples/bip_example/modelDescription.xml)
9. Μετονομασία του libProject.so σε bip_example.so για να είναι συμβατός ο φάκελος bip_example με FMU checkers
10. Μεταγλώττιση του master (src/DEPLOY_TEMPLATE.cpp + includes) με τη δυναμική βιβλιοθήκη bip_example.so
11. Εκτέλεση του master
TODO:
1. Θα πρέπει να ξαναδούμε το XML ώστε να είναι συμβατό με το μοντέλο (π.χ. μεταβλήτη time αφαιρέθηκε, μεταβλητή zero)
2. Θα πρέπει να γίνει το bip_example folder, zip και .fmu ώστε να γίνει fmu check validation.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<fmiModelDescription fmiVersion="2.0" modelName="bip_example" guid="123456789" description="LEC" generationTool="Manually" generationDateAndTime="2022-02-24T12:43:32Z">
<CoSimulation modelIdentifier="bip_example" needsExecutionTool="true" canBeInstantiatedOnlyOncePerProcess="true" canNotUseMemoryManagementFunctions="true" canGetAndSetFMUstate="false" canSerializeFMUstate="false" providesDirectionalDerivative="false" canHandleVariableCommunicationStepSize="true" canInterpolateInputs="false" maxOutputDerivativeOrder="0" canRunAsynchronuously="false"/>
<UnitDefinitions>
<Unit name="s"/>
</UnitDefinitions>
<ModelVariables>
<ScalarVariable name="ROOT.environment._id__inputIndex" valueReference="100" description="input index" causality="local" initial="exact" variability="discrete">
<Integer start="1"/>
<Annotations><Tool name="Amesim"><VarAnnot index="1"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.camera._id__inputIndex" valueReference="102" description="Current index frame for camera" causality="local" variability="discrete">
<Integer min="0" max="10"/>
<Annotations><Tool name="Amesim"><VarAnnot index="3"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.perception._id__inputIndex" valueReference="103" description="Current index frame for perception" causality="local" variability="discrete">
<Integer min="0" max="10"/>
<Annotations><Tool name="Amesim"><VarAnnot index="4"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.perception._id__result" valueReference="104" description="Detection result" causality="output" variability="discrete">
<Integer />
<Annotations><Tool name="Amesim"><VarAnnot index="5"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.controller._id__speed" valueReference="105" description="Vehicle speed" causality="local" variability="discrete" initial="exact">
<Integer min="0" max="270" start="70"/>
<Annotations><Tool name="Amesim"><VarAnnot index="6"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.controller._id__speedLimit" valueReference="106" description="Speed limit" causality="local" variability="discrete">
<Integer min="0" max="120"/>
<Annotations><Tool name="Amesim"><VarAnnot index="7"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.controller._id__deltaSpeed" valueReference="107" description="Delta speed" causality="local" variability="discrete" initial="exact">
<Integer start="0"/>
<Annotations><Tool name="Amesim"><VarAnnot index="8"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.controller._id__zero" valueReference="108" description="Zero" causality="parameter" variability="fixed" initial="exact">
<Integer start="0"/>
<Annotations><Tool name="Amesim"><VarAnnot index="9"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.brake._id__deltaSpeed" valueReference="109" description="Delta speed" causality="local" variability="discrete" initial="exact">
<Integer start="0"/>
<Annotations><Tool name="Amesim"><VarAnnot index="10"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.throttle._id__deltaSpeed" valueReference="110" description="Delta speed" causality="local" variability="discrete" initial="exact">
<Integer start="0"/>
<Annotations><Tool name="Amesim"><VarAnnot index="11"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.speedSensor._id__speed" valueReference="111" description="Vehicle speed" causality="local" variability="discrete">
<Integer min="0" max="120"/>
<Annotations><Tool name="Amesim"><VarAnnot index="12"/></Tool></Annotations>
</ScalarVariable>
<ScalarVariable name="ROOT.speedSensor._id__deltaSpeed" valueReference="112" description="Delta speed" causality="local" variability="discrete" initial="exact">
<Integer start="0"/>
<Annotations><Tool name="Amesim"><VarAnnot index="13"/></Tool></Annotations>
</ScalarVariable>
</ModelVariables>
<ModelStructure>
<Outputs>
<Unknown index="2" dependencies=""/>
<Unknown index="5" dependencies=""/>
</Outputs>
<InitialUnknowns>
<Unknown index="5" dependencies=""/>
</InitialUnknowns>
</ModelStructure>
</fmiModelDescription>
......@@ -23,7 +23,7 @@ int deepLearn(int i){
char buffer [50];
sprintf (buffer, "%d.png", i);
stringstream tmp;
tmp<<"python3 ./ext-cpp/Inference.py ./ext-cpp/yolox_s.onnx Signs/"<<i<<".png > system.txt";
tmp<<"python3 `pwd`/bip_example/resources/ext-cpp/Inference.py `pwd`/bip_example/resources/ext-cpp/yolox_s.onnx `pwd`/bip_example/resources/Signs/"<<i<<".png > system.txt";
//tmp<<"python ./ext-cpp/Inference.py ./ext-cpp/yolox_s.onnx > system.txt";
string execCmd = tmp.str();
int a = system(execCmd.c_str());
......
# for SPEEDCONTROLMODULE/modelDetection/imageDetection example
mkdir bip_example
mkdir bip_example/binaries
mkdir bip_example/binaries/linux64
mkdir bip_example/resources
cp $1/libProject.so bip_example/binaries/linux64
cp -r $1/Signs bip_example/resources
cp -r $1/ext-cpp bip_example/resources
cp ../bip_example/modelDescription.xml bip_example
mv bip_example/binaries/linux64/libProject.so bip_example/binaries/linux64/bip_example.so
g++ src/DEPLOY_TEMPLATE.cpp -I includes -Lbip_example -ldl -o master -Wl,--export-dynamic
./master
/*
FMI Interface for FMU generated by FMICodeGenerator.
This file is part of FMICodeGenerator (https://github.com/ghorwin/FMICodeGenerator)
BSD 3-Clause License
Copyright (c) 2018, Andreas Nicolai
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FMI_templateH
#define FMI_templateH
#include <InstanceData.h>
/*! This class wraps all data needed for a single instance of the FMU. */
class FMI_template : public InstanceData {
public:
/*! Initializes empty instance. */
FMI_template();
/*! Destructor, writes out cached results from Therakles. */
~FMI_template();
/*! Initializes model */
void init();
/*! This function triggers a state-update of the embedded model whenever our cached input
data differs from the input data in the model.
*/
void updateIfModified();
/*! Called from fmi2DoStep(). */
virtual void integrateTo(double tCommunicationIntervalEnd);
virtual void doStep();
// Functions for getting/setting the state
/*! This function computes the size needed for full serizalization of
the FMU and stores the size in m_fmuStateSize.
\note The size includes the leading 8byte for the 64bit integer size
of the memory array (for testing purposes).
*/
virtual void computeFMUStateSize();
/*! Copies the internal state of the FMU to the memory array pointed to by FMUstate.
Memory array always has size m_fmuStateSize.
*/
virtual void serializeFMUstate(void * FMUstate);
/*! Copies the content of the memory array pointed to by FMUstate to the internal state of the FMU.
Memory array always has size m_fmuStateSize.
*/
virtual bool deserializeFMUstate(void * FMUstate);
/*! Cached current time point of the FMU, defines starting point for time integration in co-simulation mode. */
double m_currentTimePoint;
}; // class FMI_template
#endif // FMI_templateH
\ No newline at end of file
/*
Generic FMI Interface Implementation
This file is part of FMICodeGenerator (https://github.com/ghorwin/FMICodeGenerator)
BSD 3-Clause License
Copyright (c) 2018, Andreas Nicolai
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef InstanceDataH
#define InstanceDataH
#include <vector>
#include <map>
#include <set>
#include <string>
#include "fmi2FunctionTypes.h"
#include "Launcher.hpp"
/*! This class wraps data needed for FMUs and implements common functionality.
In order to use this in your own InstanceData structure, you must inherit this
file and implement the following functions:
\code
class MyFMIClass : public InstanceDataCommon {
public:
// Initializes InstanceData
void init();
// Re-implement if you want ModelExchange support
virtual void updateIfModified();
// Re-implement if you want CoSim support
virtual void integrateTo(double tCommunicationIntervalEnd);
};
\endcode
Also, you must define the constant with some GUID and implement the static function create().
\code
const char * const InstanceData::GUID = "{471a3b52-4923-44d8-ab4a-fcdb813c7322}";
InstanceData * InstanceData::create() {
return new MyFMIClass;
}
\endcode
in your MyFMIClass.cpp file.
*/
class InstanceData {
public:
/*! Global unique ID that identifies this FMU.
Must match the GUID in the ModelDescription file.
\note This GUID is model-specific, so you must define this static symbol
in the cpp file of your derived class.
*/
static const char * const GUID;
/*! Factory function, needs to be implemented in user code.
\note Only the model-specific implementation knows the concrete type of the class
derived from abstract InterfaceData class, and so this function must be
implemented in the model-specific code.
*/
static InstanceData * create();
/*! Initializes empty instance.
\note You must initialize all input and output variables here, since input
variable can be set and output variables can be requested, even before
entering initialization mode (i.e. before a call to init()).
*/
InstanceData();
/*! Destructor, resource cleanup. */
virtual ~InstanceData();
/*! Re-implement this function in derived classes to perform initialization
of the model during the initialization phase.
*/
virtual void init() {}
/*! This function triggers a state-update of the embedded model whenever our cached input
data differs from the input data in the model.
Re-implement in models that support model exchange.
\note You should check the state of m_externalInputVarsModified and only
update the results of this flag is true. Afterwards set this flag to false.
*/
virtual void updateIfModified() {}
/*! Called from fmi2DoStep().
Re-implement in models that support co-simulation.
*/
virtual void integrateTo(double tCommunicationIntervalEnd) { (void)tCommunicationIntervalEnd; }
virtual void doStep() {}
/*! Send a logging message to FMU environment if logger is present.*/
void logger(fmi2Status state, fmi2String category, fmi2String msg);
/*! Send a logging message to FMU environment if logger is present.
This function copies the error message (which may be a temporary string object) into the
persistent member variable m_lastError and passes a pointer to this string through the
logger function.
*/
void logger(fmi2Status state, fmi2String category, const std::string & msg) {
m_lastError = msg;
logger(state, category, m_lastError.c_str());
}
/*! Sets a new input parameter of type double. */
void setReal(int varID, double value);
/*! Sets a new input parameter of type int. */
void setInt(int varID, int value);
/*! Sets a new input parameter of type string. */
void setString(int varID, fmi2String value);
/*! Sets a new input parameter of type bool. */
void setBool(int varID, bool value);
/*! Retrieves an output parameter of type double. */
void getReal(int varID, double & value);
/*! Retrieves an output parameter of type int. */
void getInt(int varID, int & value);
/*! Retrieves an output parameter of type string. */
void getString(int varID, fmi2String & value);
/*! Retrieves an output parameter of type bool. */
void getBool(int varID, bool & value);
/*! Called from fmi2CompletedIntegratorStep(): only ModelExchange. */
void completedIntegratorStep();
/*! Called from completedIntegratorStep(): only ModelExchange.
Re-implement with your own code.
*/
virtual void completedIntegratorStep(double t_stepEnd, double * yInput) { (void)t_stepEnd; (void)yInput; }
/*! Re-implement for getFMUState()/setFMUState() support.
This function computes the size needed for full serizalization of
the FMU and stores the size in m_fmuStateSize.
\note The size includes the leading 8byte for the 64bit integer size
of the memory array (for testing purposes).
If serialization is not supported, the function will set an fmu size of 0.
*/
virtual void computeFMUStateSize() { m_fmuStateSize = 0; } // default implementation sets zero size = no serialization
/*! Re-implement for getFMUState() support.
Copies the internal state of the FMU to the memory array pointed to by FMUstate.
Memory array always has size m_fmuStateSize.
*/
virtual void serializeFMUstate(void * FMUstate) { (void)FMUstate; }
/*! Re-implement for setFMUState() support.
Copies the content of the memory array pointed to by FMUstate to the internal state of the FMU.
Memory array always has size m_fmuStateSize.
\return Returns false if checks during deserialization fail.
*/
virtual bool deserializeFMUstate(void * FMUstate) { (void)FMUstate; return true; }
/*! Called from either doStep() or terminate() in CoSimulation mode whenever
a communication interval has been completed and all related buffers can be cleared/output files can be
written.
*/
virtual void clearBuffers() {}
Launcher* m_launcher;
/*! Stores the FMU callback functions for later use.
It is usable between fmi2Instantiate and fmi2Terminate.*/
const fmi2CallbackFunctions* m_callbackFunctions;
/*! True if in initialization mode. */
bool m_initializationMode;
/*! Name of the instance inside the FMU environment.*/
std::string m_instanceName;
/*! Resource root path as set via fmi2Instantiate(). */
std::string m_resourceLocation;
/*! Logging enabled flag as set via fmi2Instantiate(). */
bool m_loggingOn;
/*! Logging categories supported by the master. */
std::vector<std::string> m_loggingCategories;
/*! If true, this is a ModelExchange FMU. */
bool m_modelExchange;
std::map<int,int> m_boolVar;
std::map<int,double> m_realVar;
std::map<int,int> m_integerVar;
std::map<int,std::string> m_stringVar;
/*! Time point in [s] received by last call to fmi2SetTime(). */
double m_tInput;
/*! Model state vector as received by last call to fmi2SetContinuousStates(). */
std::vector<double> m_yInput;
/*! Model derivatives vector as updated by last call to updateIfModified(). */
std::vector<double> m_ydot;
/*! Signals that one of the real parameter inputs have been changed.
This flag is reset whenever updateIfModified() has been called.
The flag is set in any of the setXXXParameter() functions.
*/
bool m_externalInputVarsModified;
/*! Holds the size of the FMU when serialized in memory.
This value does not change after full initialization of the solver so it can be cached.
Initially it will be zero so functions can check if initialization is properly done.
*/
size_t m_fmuStateSize;
/*! Holds pointers to all currently stored FMU states.
Pointers get added in function fmi2GetFMUstate(), and removed in fmi2FreeFMUstate().
Unreleased memory gets deallocated in destructor.
*/
std::set<void*> m_fmuStates;
/*! Persistent string pointing to last error message.
\warning DO not change/resize string manually, only through logger() function.
*/
std::string m_lastError;
}; // class InstanceData
#endif // InstanceDataH
\ No newline at end of file
#ifndef fmi2TypesPlatform_h
#define fmi2TypesPlatform_h
/* Standard header file to define the argument types of the
functions of the Functional Mock-up Interface 2.0.3
This header file must be utilized both by the model and
by the simulation engine.
Revisions:
- Sep. 29, 2019: License changed to 2-clause BSD License (without extensions)
- Apr. 9, 2014: All prefixes "fmi" renamed to "fmi2" (decision from April 8)
- Mar 31, 2014: New datatype fmiChar introduced.
- Feb. 17, 2013: Changed fmiTypesPlatform from "standard32" to "default".
Removed fmiUndefinedValueReference since no longer needed
(because every state is defined in ScalarVariables).
- March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
- Nov. 14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
both for "FMI for model exchange" and for "FMI for co-simulation"
New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
The implementation of "fmiBoolean" is change from "char" to "int".
The #define "fmiPlatform" changed to "fmiTypesPlatform"
(in order that #define and function call are consistent)
- Oct. 4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
for the co-simulation interface
- Jan. 4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
- Dec. 21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
according to meeting on Dec. 18 (by Martin Otter, DLR)
- Dec. 6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
- Sept. 9, 2009: Changes according to FMI-meeting on July 21:
Changed "version" to "platform", "standard" to "standard32",
Added a precise definition of "standard32" as comment
(by Martin Otter, DLR)
- July 19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
and changed meValueReferenced from int to unsigned int
(by Martin Otter, DLR).
- March 2, 2009: Moved enums and function pointer definitions to
ModelFunctions.h (by Martin Otter, DLR).
- Dec. 3, 2008 : First version by Martin Otter (DLR) and
Hans Olsson (Dynasim).
Copyright (C) 2008-2011 MODELISAR consortium,
2012-2021 Modelica Association Project "FMI"
All rights reserved.
This file is licensed by the copyright holders under the 2-Clause BSD License
(https://opensource.org/licenses/BSD-2-Clause):
----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------
*/
/* Platform (unique identification of this header file) */
#define fmi2TypesPlatform "default"
/* Type definitions of variables passed as arguments
Version "default" means:
fmi2Component : an opaque object pointer
fmi2ComponentEnvironment: an opaque object pointer
fmi2FMUstate : an opaque object pointer
fmi2ValueReference : handle to the value of a variable
fmi2Real : double precision floating-point data type
fmi2Integer : basic signed integer data type
fmi2Boolean : basic signed integer data type
fmi2Char : character data type
fmi2String : a pointer to a vector of fmi2Char characters
('\0' terminated, UTF8 encoded)
fmi2Byte : smallest addressable unit of the machine, typically one byte.
*/
typedef void* fmi2Component; /* Pointer to FMU instance */
typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
typedef unsigned int fmi2ValueReference;
typedef double fmi2Real ;
typedef int fmi2Integer;
typedef int fmi2Boolean;
typedef char fmi2Char;
typedef const fmi2Char* fmi2String;
typedef char fmi2Byte;
/* Values for fmi2Boolean */
#define fmi2True 1
#define fmi2False 0
#endif /* fmi2TypesPlatform_h */
File added
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <string>
#include <fmi2Functions.h>
#include <fmi2FunctionTypes.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
int ret = EXIT_SUCCESS;
fmi2Real tstart = 0.0;
fmi2Real tcur = tstart;
fmi2Real hstep = 0.2;
fmi2Real tend = 7.0;
void *handle;
fmi2InstantiateTYPE* (fmi2Instantiate);
fmi2EnterInitializationModeTYPE* (fmi2EnterInitializationMode);
fmi2ExitInitializationModeTYPE* (fmi2ExitInitializationMode);
fmi2SetIntegerTYPE* (fmi2SetInteger);
fmi2GetIntegerTYPE* (fmi2GetInteger);
fmi2DoStepTYPE* (fmi2DoStep);
void (*set_inverted_map)(int,string);
char *error;
handle = dlopen ("bip_example/binaries/linux64/bip_example.so", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());
exit(1);
}
dlerror(); /* Clear any existing error */
fmi2Instantiate = (fmi2InstantiateTYPE*) dlsym(handle, "fmi2Instantiate");
fmi2EnterInitializationMode = (fmi2EnterInitializationModeTYPE*) dlsym(handle, "fmi2EnterInitializationMode");
fmi2ExitInitializationMode = (fmi2ExitInitializationModeTYPE*) dlsym(handle, "fmi2ExitInitializationMode");
fmi2SetInteger = (fmi2SetIntegerTYPE*) dlsym(handle, "fmi2SetInteger");
fmi2GetInteger = (fmi2GetIntegerTYPE*) dlsym(handle, "fmi2GetInteger");
fmi2DoStep = (fmi2DoStepTYPE*) dlsym(handle, "fmi2DoStep");
set_inverted_map = (void (*)(int, std::string)) dlsym(handle, "set_inverted_map");
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
cout<<"CALL fmi2Instantiate...\n";
fmi2Component c = (*fmi2Instantiate)("prModel", fmi2CoSimulation , "prModel", "resource/location", NULL, true, true);
(*set_inverted_map)(100, "ROOT.environment._id__inputIndex");
//(*set_inverted_map)(101, "ROOT.environment._id__time");
(*set_inverted_map)(102, "ROOT.camera._id__inputIndex");
(*set_inverted_map)(103, "ROOT.perception._id__inputIndex");
(*set_inverted_map)(104, "ROOT.perception._id__result");
(*set_inverted_map)(105, "ROOT.controller._id__speed");
(*set_inverted_map)(106, "ROOT.controller._id__speedLimit");
(*set_inverted_map)(107, "ROOT.controller._id__deltaSpeed");
(*set_inverted_map)(108, "ROOT.controller._id__zero");
(*set_inverted_map)(109, "ROOT.brake._id__deltaSpeed");
(*set_inverted_map)(110, "ROOT.throttle._id__deltaSpeed");
(*set_inverted_map)(111, "ROOT.speedSensor._id__speed");
(*set_inverted_map)(112, "ROOT.speedSensor._id__deltaSpeed");
const unsigned int vr[] = {100,/*101,*/ 102,103,104,105,106,107,108,109,110,111,112};
const int values[] = {1,/*10,*/ 0,0,0,0,0,0,0,0,0,100,0};
cout<<"CALL fmi2SetInteger...\n";
(*fmi2SetInteger)(c, vr, 12, values);
cout<<"CALL fmi2EnterInitializationMode...\n";
(*fmi2EnterInitializationMode)(c);
cout<<"CALL fmi2ExitInitializationMode...\n";
(*fmi2ExitInitializationMode)(c);
tcur = tstart;
while(tcur<tend){
fmi2Boolean newStep = fmi2True;
fmi2Integer val[12];
cout<<"tcur: "<<tcur<<'\n';
cout<<"CALL fmi2DoStep...\n";
fmi2DoStep(c, tcur,hstep, newStep);
cout<<"CALL fmi2GetInteger...\n";
fmi2GetInteger(c, vr, 12, val);
tcur += hstep;
}
cout<<"Simulation finished.\n";
dlclose(handle);
return ret;
}
This diff is collapsed.
No preview for this file type
......@@ -219,7 +219,7 @@ Project_SOURCE_DIR:STATIC=/home/siemens/bip/examples/SpeedControlModule/modelCla
RT_path:FILEPATH=/usr/lib/x86_64-linux-gnu/librt.so
//Path to a library.
libengine_path:FILEPATH=/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a
libengine_path:FILEPATH=/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a
########################
......
......@@ -10,8 +10,8 @@ set(CMAKE_CXX_COMPILER_ID "GNU")
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp"
"../learn/include"
)
......
......@@ -80,7 +80,7 @@ system_EXTERNAL_OBJECTS =
system: CMakeFiles/system.dir/Deploy/Deploy.cpp.o
system: CMakeFiles/system.dir/build.make
system: learn/libpack__learn.a
system: /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a
system: /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a
system: /usr/lib/x86_64-linux-gnu/librt.so
system: CMakeFiles/system.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/siemens/bip/examples/SpeedControlModule/modelClassification/output/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable system"
......
......@@ -6,5 +6,5 @@ CXX_FLAGS = -Wall -std=c++0x
CXX_DEFINES =
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/output/learn/include
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/output/learn/include
/usr/bin/c++ -Wall -std=c++0x -rdynamic CMakeFiles/system.dir/Deploy/Deploy.cpp.o -o system learn/libpack__learn.a /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a -lrt
/usr/bin/c++ -Wall -std=c++0x -rdynamic CMakeFiles/system.dir/Deploy/Deploy.cpp.o -o system learn/libpack__learn.a /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a -lrt
......@@ -43,8 +43,8 @@ set(CMAKE_CXX_COMPILER_ID "GNU")
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp"
"../learn/include"
)
......
......@@ -6,5 +6,5 @@ CXX_FLAGS = -Wall -std=c++0x
CXX_DEFINES =
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/output/learn/include
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelClassification/output/learn/include
No preview for this file type
......@@ -23,7 +23,7 @@ int deepLearn(int i){
char buffer [50];
sprintf (buffer, "%d.png", i);
stringstream tmp;
tmp<<"python3 ./ext-cpp/Inference.py ./ext-cpp/yolox_s.onnx Signs/"<<i<<".png > system.txt";
tmp<<"python3 `pwd`/bip_example/resources/ext-cpp/Inference.py `pwd`/bip_example/resources/ext-cpp/yolox_s.onnx `pwd`/bip_example/resources/Signs/"<<i<<".png > system.txt";
//tmp<<"python ./ext-cpp/Inference.py ./ext-cpp/yolox_s.onnx > system.txt";
string execCmd = tmp.str();
int a = system(execCmd.c_str());
......
......@@ -28,8 +28,7 @@ package learn
end
atom type Environment ()
data int inputIndex = 1
data int time = 10
data int inputIndex = 1
export port intPort sendInput(inputIndex)
export port silent getInput()
export port silent getInputInitial()
......
No preview for this file type
......@@ -219,7 +219,7 @@ Project_SOURCE_DIR:STATIC=/home/siemens/bip/examples/SpeedControlModule/modelDet
RT_path:FILEPATH=/usr/lib/x86_64-linux-gnu/librt.so
//Path to a library.
libengine_path:FILEPATH=/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a
libengine_path:FILEPATH=/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a
########################
......
......@@ -10,8 +10,8 @@ set(CMAKE_CXX_COMPILER_ID "GNU")
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp"
"../learn/include"
)
......
......@@ -80,7 +80,7 @@ system_EXTERNAL_OBJECTS =
system: CMakeFiles/system.dir/Deploy/Deploy.cpp.o
system: CMakeFiles/system.dir/build.make
system: learn/libpack__learn.a
system: /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a
system: /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a
system: /usr/lib/x86_64-linux-gnu/librt.so
system: CMakeFiles/system.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/output/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable system"
......
......@@ -6,5 +6,5 @@ CXX_FLAGS = -Wall -std=c++0x
CXX_DEFINES =
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/output/learn/include
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/output/learn/include
/usr/bin/c++ -Wall -std=c++0x -rdynamic CMakeFiles/system.dir/Deploy/Deploy.cpp.o -o system learn/libpack__learn.a /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/lib/static/libengine.a -lrt
/usr/bin/c++ -Wall -std=c++0x -rdynamic CMakeFiles/system.dir/Deploy/Deploy.cpp.o -o system learn/libpack__learn.a /home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/lib/static/libengine.a -lrt
......@@ -46,8 +46,8 @@ set(CMAKE_CXX_COMPILER_ID "GNU")
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic"
"/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific"
"/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp"
"../learn/include"
)
......
......@@ -6,5 +6,5 @@ CXX_FLAGS = -Wall -std=c++0x
CXX_DEFINES =
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.054041-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/output/learn/include
CXX_INCLUDES = -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/generic -I/home/siemens/bip/distribution/build/bip-full/BIP-reference-engine-2022.03.060929-DEV_Linux-x86_64/include/specific -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/ext-cpp -I/home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/output/learn/include
#ifndef LEARN_AT____LEARN____BRAKE_HPP_
#define LEARN_AT____LEARN____BRAKE_HPP_
// /home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/learn.bip:102:1
// /home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/learn.bip:101:1
// include package "master" header
#include <learn.hpp>
......
// /home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/learn.bip:136:1
// /home/siemens/bip/examples/SpeedControlModule/modelDetection/imageDetection/learn.bip:135:1
#include <learn/CT__learn__Compound.hpp>
......
No preview for this file type
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment