Skip to content

Commit 2400c72

Browse files
PhRosenbergerClemensLinnhoff
authored andcommitted
Adding Windows build instructions and refactoring READMEs
Signed-off-by: PhRosenberger <[email protected]>
1 parent 4ca2516 commit 2400c72

21 files changed

+327
-144
lines changed

.gitignore

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
.idea
2-
cmake-build-debug
3-
cmake-build-release
4-
1+
cmake*
2+
build*
3+
.vscode/
4+
.editorconfig
5+
out/
6+
.idea/
7+
.vs/

README.md

+93-58
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,45 @@
1-
# OSI Sensor Model Packaging FMU Framework with Example Strategies
1+
# Modular OSI Sensor Model Packaging FMU Framework with Example Strategies
22

33
<img align="right" src="https://gitlab.com/tuda-fzd/perception-sensor-modeling/object-based-generic-perception-object-model/uploads/17c84e9ec0acf0fac2e35855f038ad0b/fzdlogo.jpg" width="100" />
44
This is the OSMP FMU Framework provided with example strategies and profiles.
55
<br>
66
<img src="https://gitlab.com/tuda-fzd/perception-sensor-modeling/fzd-osmp-model-framework/uploads/172e7820150fb48818bce2c57ce66f85/OSMP_Model_Framework.png" width="800" />
77

88
The framework is based on adaptions of OSI Sensor Model Packaging (OSMP) to load individual code modules called strategies and get parameters from profiles into the strategies.
9-
OSMP specifies ways in which models (like e.g. environmental effect models, sensor models and logical models) using the [Open Simulation Interface (OSI)](https://github.com/OpenSimulationInterface/open-simulation-interface) are to be packaged for their use in simulation environments using FMI 2.0.
9+
OSMP specifies ways in which models using the [Open Simulation Interface (OSI)](https://github.com/OpenSimulationInterface/open-simulation-interface) are to be packaged for their use in simulation environments using [FMI 2.0](https://fmi-standard.org).
1010

11-
## Important
12-
13-
This work is based on the [`OSMPDummySensor`](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging/tree/master/examples/OSMPDummySensor) example from the [Open Simulation Inferface Sensor Model Packaging project](https://github.com/OpenSimulationInterface/osi-sensor-model-packaging).
11+
The actual logic of the model is packed in so called strategies.
12+
This is where the magic happens.
13+
The `apply()` function of the strategy is called by the `do_calc()` function of the Framework.
14+
There are two exemplary strategies delivered with this framework:
1415

15-
Before modifying files, carefully read the files [COPYING](COPYING) and [CONTRIBUTING.md](CONTRIBUTING.md).
16+
1. Example strategy: It simply logs some input data to show that it is running.
17+
2. CSV output gt objects strategy: It outputs a .csv file to `CSV_PATH` set via `CMakeLists.txt` containing moving objects from the received ground truth.
1618

17-
### Usage
19+
## Configuration
1820

19-
The actual logic of the model is packed in so called strategies.
20-
The `apply()` function of a strategy is called by the `do_calc()` function of the OSMP Framework.
21+
### Model name
2122

22-
When building and installing, the framework will build an fmu package into `_FMU_INSTALL_DIR_`, which can be used with a simulation tool like CarMaker, dSpace ASM or others.
23+
The model's name (in this case "FrameworkDemoModel") used for CMake-projects and the FMU at the end is defined in file `model_name.conf` located at `src/model`.
2324

24-
## Build Instructions for Ubuntu 18.04 / 20.04
25+
### Install path
2526

26-
When building and installing, the framework will build an FMU package, which can be used with a simulation tool like CarMaker, dSpace ASM or others.
27+
When building and installing, the framework will build an FMU package into `FMU_INSTALL_DIR`, which can be used with a simulation tool that supports OSI and fills the required fields listed below.
2728

28-
### Install Dependencies
29+
### VariableNamingConvention
2930

30-
1. Install cmake 3.12: e.g. with
31-
```bash
32-
$ git clone https://github.com/Kitware/CMake
33-
$ sudo apt install libssl-dev
34-
$ cd CMake
35-
$ ./bootstrap
36-
$ make -j
37-
$ sudo make install
38-
```
39-
2. Install protobuf 3.0.0:
40-
* Check your version via `protoc --version`. It should output: `libprotoc 3.0.0`
41-
* If needed, you can install it via `sudo apt-get install libprotobuf-dev protobuf-compiler`
42-
* or from source:
43-
* Download it from https://github.com/protocolbuffers/protobuf/releases/tag/v3.0.0 and extract the archive.
44-
* Try to run `./autogen.sh`, if it failes, download the gmock-1.7.0.zip from https://pkgs.fedoraproject.org/repo/pkgs/gmock/gmock-1.7.0.zip/073b984d8798ea1594f5e44d85b20d66/gmock-1.7.0.zip, extract it into the protobuf folder and rename the gmock-1.7.0 folter to gmock.
45-
* Proceed with the install with
46-
```bash
47-
$ make
48-
$ sudo make install
49-
$ sudo ldconfig # refresh shared library cache.
50-
```
31+
The parameter variableNamingConvention for the FMU specified within the modelDescription.xml is taken from file `variableNamingConvention.conf` located at `src/osmp`.
32+
Possible values are "flat" or "structured".
5133

52-
### Clone with Submodules, Build, and Install
34+
### Profiles for Parameterization
5335

54-
1. Clone this repository <ins>with submodules</ins>:
55-
```bash
56-
$ git clone https://gitlab.com/tuda-fzd/perception-sensor-modeling/reflection-based-lidar-object-model.git --recurse-submodules
57-
```
58-
or alternatively initialize submodules after cloning:
59-
```
60-
$ git submodule update --init
61-
```
62-
2. Build the model by executing in the extracted project root directory:
63-
```bash
64-
$ mkdir cmake-build
65-
$ cd cmake-build
66-
# If FMU_INSTALL_DIR is not set, CMAKE_BINARY_DIR is used
67-
$ cmake -DCMAKE_BUILD_TYPE=Release -DFMU_INSTALL_DIR:PATH=/opt/osifmu ..
68-
$ make -j N_JOBS
69-
```
70-
3. Take FMU from `FMU_INSTALL_DIR`
36+
The profiles are parameterized in the files `profile_*.hpp.in`.
37+
The parameters are declared in the files `profile.hpp.in`.
38+
The profiles can be extended by the strategies with additional parameters and values in their respective folders.
7139

72-
(Please note that sources are not packed into the FMU at the moment.)
40+
The profile to be loaded for simulation is set via a model parameter defined in the `modelDescription.xml` of the FMU.
41+
The first name in `src/model/profiles/profile_list.conf` is taken as default.
42+
If you would like to have a different one or if your simulation master does not support the configuration of model parameters, you have to adapt the *start* value of the parameter `profile` in `src/osmp/modelDescription.in.xml`.
7343

7444
## How to use (= extend) this framework
7545

@@ -126,7 +96,7 @@ Have a look at the existing strategies to get an idea about how easy it is to in
12696
/* TODO add further profiles and profile generators here */
12797
#include <model/profiles/profile_NAME.hpp>
12898
129-
bool CFZDSensorModel::try_load_profile(const std::string &name) {
99+
bool CFrameworkPackaging::try_load_profile(const std::string &name) {
130100
if (name == "NAME") {
131101
profile = model::profile::NAME::generate();
132102
return true;
@@ -137,10 +107,75 @@ Have a look at the existing strategies to get an idea about how easy it is to in
137107
}
138108
```
139109

140-
**Note:**
141-
The profile to be loaded is set via a model parameter defined in the `modelDescription.xml` of the FMU.
142-
It can be set by the FMU master.
143-
If it is not set by the FMU master, the first name in `src/model/profiles/profile_list.conf` is simply taken as default.
110+
## Build Instructions in Windows 10
111+
112+
### Install Dependencies in Windows 10
113+
114+
1. Install cmake from https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-windows-x86_64.msi
115+
2. Install protobuf for [MSYS-2020](install_protobuf_Win64_MSYS-2020.md) or [Visual Studio 2017](install_protobuf_Win64_VS2017.md)
116+
117+
### Clone with Submodules, Build, and Install in Windows 10
118+
119+
1. Clone this repository <ins>with submodules</ins>:
120+
```bash
121+
$ git clone https://gitlab.com/tuda-fzd/perception-sensor-modeling/modular-osmp-framework.git --recurse-submodules
122+
```
123+
2. Build the model in [MSYS-2020](install_model_Win64_MSYS-2020.md) or [Visual Studio 2017](install_model_Win64_VS2017.md)
124+
3. Take FMU from `FMU_INSTALL_DIR`
125+
126+
(Please note that sources are not packed into the FMU at the moment.)
127+
128+
## Build Instructions in Ubuntu 18.04 / 20.04
129+
130+
### Install Dependencies in Ubuntu 18.04 / 20.04
131+
132+
1. Install cmake 3.12
133+
* as told in [these install instructions](install_cmake_ubuntu_3-12.md)
134+
2. Install protobuf 3.0.0:
135+
* Check your version via `protoc --version`. It should output: `libprotoc 3.0.0`
136+
* If needed, you can install it via `sudo apt-get install libprotobuf-dev protobuf-compiler`
137+
* or from source:
138+
* Download it from https://github.com/protocolbuffers/protobuf/releases/tag/v3.0.0 and extract the archive.
139+
* Try to run `./autogen.sh`, if it failes, download the gmock-1.7.0.zip from https://pkgs.fedoraproject.org/repo/pkgs/gmock/gmock-1.7.0.zip/073b984d8798ea1594f5e44d85b20d66/gmock-1.7.0.zip, extract it into the protobuf folder and rename the gmock-1.7.0 folter to gmock.
140+
* Proceed with the install with
141+
```bash
142+
$ make
143+
$ sudo make install
144+
$ sudo ldconfig # refresh shared library cache.
145+
```
146+
3. <ins>For ROS-Output-Strategies:</ins> Install ROS melodic (Ubuntu 18.04) / noetic (Ubuntu 20.04)
147+
* **Ubuntu 18.04: ROS melodic** <br> http://wiki.ros.org/melodic/Installation/Ubuntu (go with `desktop-full`)
148+
* **Ubuntu 20.04: ROS noetic** <br> http://wiki.ros.org/noetic/Installation/Ubuntu (go with `desktop-full`)
149+
150+
### Clone with Submodules, Build, and Install in Ubuntu 18.04 / 20.04
151+
152+
1. Clone this repository <ins>with submodules</ins>:
153+
```bash
154+
$ git clone https://gitlab.com/tuda-fzd/perception-sensor-modeling/modular-osmp-framework.git --recurse-submodules
155+
```
156+
2. <ins>For ROS-Output-Strategies:</ins> Change CMakeLists.txt in every ROS-Strategy according to ROS-version
157+
* In `src/model/strategies/ros-.../CMakeLists.txt` change the two lines
158+
- **Ubuntu 18.04: ROS melodic**
159+
```CMake
160+
list(APPEND CMAKE_PREFIX_PATH /opt/ros/melodic/)
161+
set(PYTHONPATH /opt/ros/melodic/lib/python2.7/dist-packages)
162+
```
163+
- **Ubuntu 20.04: ROS noetic**
164+
```CMake
165+
list(APPEND CMAKE_PREFIX_PATH /opt/ros/noetic/)
166+
set(PYTHONPATH /opt/ros/melodic/lib/python3/dist-packages)
167+
```
168+
3. Build the model by executing in the extracted project root directory:
169+
```bash
170+
$ mkdir cmake-build
171+
$ cd cmake-build
172+
# If FMU_INSTALL_DIR is not set, CMAKE_BINARY_DIR is used
173+
$ cmake -DCMAKE_BUILD_TYPE=Release -DFMU_INSTALL_DIR:PATH=/tmp ..
174+
$ make -j N_JOBS
175+
```
176+
4. Take FMU from `FMU_INSTALL_DIR`
177+
178+
(Please note that sources are not packed into the FMU at the moment.)
144179

145180
## Licensing
146181

install_cmake_ubuntu_3-12.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#### Download and compile:
2+
```bash
3+
$ wget http://www.cmake.org/files/v3.12/cmake-3.12.1.tar.gz
4+
$ tar -xvzf cmake-3.12.1.tar.gz
5+
$ cd cmake-3.12.1/
6+
$ ./configure
7+
$ make
8+
```
9+
10+
Make's install command installs cmake by default in /usr/local/bin/cmake, shared files are installed into /usr/local/share/cmake-3.10.
11+
12+
Now it's time to create a backup, in case you need to roll back to the old version:
13+
```bash
14+
$ /usr/bin/cmake --version
15+
cmake version 3.10.1
16+
17+
CMake suite maintained and supported by Kitware (kitware.com/cmake).
18+
19+
$ sudo cp -p /usr/bin/cmake{,.3.10.1}
20+
21+
$ ll /usr/bin/cmake*
22+
-rwxr-xr-x 1 root root 16509675 Dez 22 2017 /usr/local/bin/cmake
23+
-rwxr-xr-x 1 root root 16509675 Dez 22 2017 /usr/local/bin/cmake.3.10.1
24+
```
25+
26+
To install (copy) the binary and libraries to the new destination, run:
27+
```bash
28+
$ sudo make install
29+
```
30+
31+
If you haven't already installed a newer cmake installation, run the following command to tell Ubuntu that the cmake command is now being replaced by an alternative installation:
32+
```bash
33+
$ sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force
34+
```
35+
36+
If you already have a custom cmake version installed (in my case I still had the 3.10.1 version active), the update-alternatives command is not necessary.
37+
The make install command will replace the existing binary in /usr/local/bin/cmake. This can be verified using:
38+
```bash
39+
$ cmake --version
40+
cmake version 3.12.1
41+
42+
CMake suite maintained and supported by Kitware (kitware.com/cmake).
43+
```

install_model_Win64_MSYS-2020.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Build the model by running the following bash script in MSYS-2020:
2+
```bash
3+
#!/bin/bash
4+
export CC="gcc -std=c++17 -s"
5+
export CXX="g++ -std=c++17 -s"
6+
mkdir -p build-MSYS && cd build-MSYS && rm -r *
7+
mkdir -p install-osi
8+
"C:/Program Files/CMake/bin/cmake.exe" \
9+
-G "MSYS Makefiles" \
10+
-DCMAKE_BUILD_TYPE=Release \
11+
-DCMAKE_INSTALL_PREFIX=install-osi \
12+
-DFMU_INSTALL_DIR:PATH=C:/tmp \
13+
-DPROTOBUF_PROTOC_EXECUTABLE=C:/protobuf-3.3/bin/protoc.exe \
14+
-DPROTOBUF_FOUND=C:/protobuf-3.3 \
15+
-DProtobuf_INCLUDE_DIR=C:/protobuf-3.3/include \
16+
-DPROTOBUF_LIBRARY=C:/protobuf-3.3/lib/libprotobuf.a \
17+
..
18+
make -j12
19+
make install
20+
```

install_model_Win64_VS2017.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Install protobuf for Win64 and Visual Studio 2017
2+
3+
1. Create and run Shell-Script (e.g. with cmd.exe):
4+
```bash
5+
#!/bin/bash
6+
mkdir -p build-VS2017 && cd build-VS2017 && rm -r *
7+
mkdir -p install-osi
8+
"C:/Program Files/CMake/bin/cmake.exe" \
9+
-G "Visual Studio 15 2017" \
10+
-DCMAKE_BUILD_TYPE=Debug \
11+
-DCMAKE_INSTALL_PREFIX=install-osi \
12+
-DFMU_INSTALL_DIR:PATH=C:/tmp \
13+
-DCMAKE_GENERATOR_PLATFORM:INTERNAL=x64 \
14+
-DCMAKE_SHARED_LINKER_FLAGS:STRING=/machine:x64 \
15+
-DCMAKE_STATIC_LINKER_FLAGS:STRING=/machine:x64 \
16+
-DCMAKE_EXE_LINKER_FLAGS:STRING=/machine:x64 \
17+
-DCMAKE_MODULE_LINKER_FLAGS:STRING=/machine:x64 \
18+
-DProtobuf_INCLUDE_DIR=C:/protobuf-3.14/include \
19+
-DPROTOBUF_PROTOC_EXECUTABLE=C:/protobuf-3.14/bin/protoc.exe \
20+
-DProtobuf_LIBRARY_DEBUG=C:/protobuf-3.14/lib/libprotobufd.lib \
21+
-DProtobuf_LIBRARY_RELEASE=C:/protobuf-3.14/lib/libprotobuf.lib \
22+
-DProtobuf_LITE_LIBRARY_DEBUG=C:/protobuf-3.14/lib/libprotobuf-lited.lib \
23+
-DProtobuf_LITE_LIBRARY_RELEASE=C:/protobuf-3.14/lib/libprotobuf-lite.lib \
24+
-DProtobuf_PROTOC_LIBRARY_DEBUG=C:/protobuf-3.14/lib/libprotocd.lib \
25+
-DProtobuf_PROTOC_LIBRARY_RELEASE=C:/protobuf-3.14/lib/libprotoc.lib \
26+
..
27+
```
28+
3. Open FrameworkDemoModel.sln located in build-dir from above with **Visual Studio 2017**
29+
4. Build Solution for *Release* AND for *Debug*
30+
5. Build INSTALL for *Release* AND for *Debug*

install_protobuf_Win64_MSYS-2020.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Install protobuf for Win64 and MSYS-2020
2+
3+
Create and run Shell-Script with **MSYS-2020**:
4+
```bash
5+
#!/bin/bash
6+
# Protobuf 3.3.0
7+
cd C:/tmp
8+
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.zip
9+
unzip -qq protobuf-cpp-3.3.0.zip
10+
cd protobuf-3.3.0
11+
export CC="gcc -std=c++17 -s"
12+
export CXX="g++ -std=c++17 -s"
13+
mkdir -p build-dir && cd build-dir && rm -r *
14+
../configure --prefix=C:/protobuf-3.3 --disable-shared
15+
make -j12 && make install
16+
```

install_protobuf_Win64_VS2017.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Install protobuf for Win64 and Visual Studio 2017
2+
3+
1. Create and run Shell-Script (e.g. with cmd.exe):
4+
```bash
5+
#!/bin/bash
6+
# Protobuf 3.14.0
7+
cd C:/tmp
8+
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protobuf-cpp-3.14.0.zip
9+
unzip -qq protobuf-cpp-3.14.0.zip
10+
cd protobuf-3.14.0/cmake
11+
mkdir -p build-dir && cd build-dir && rm -r *
12+
"C:/Program Files/CMake/bin/cmake.exe" \
13+
-G "Visual Studio 15 2017" \
14+
-DCMAKE_INSTALL_PREFIX:PATH=C:/protobuf-3.14 \
15+
-DCMAKE_SHARED_LINKER_FLAGS:STRING=/machine:x64 \
16+
-DCMAKE_STATIC_LINKER_FLAGS:STRING=/machine:x64 \
17+
-DCMAKE_EXE_LINKER_FLAGS:STRING=/machine:x64 \
18+
-DCMAKE_MODULE_LINKER_FLAGS:STRING=/machine:x64 \
19+
-DCMAKE_GENERATOR_PLATFORM:INTERNAL=x64 \
20+
-Dprotobuf_WITH_ZLIB:BOOL=OFF \
21+
-Dprotobuf_BUILD_TESTS:BOOL=OFF \
22+
..
23+
```
24+
2. Run extract_includes.bat located in build-dir from above
25+
3. Open protobuf.sln located in build-dir from above with **Visual Studio 2017**
26+
4. Change Properties->C/C++->Code Generation of **all** solutions for Configuration *Release* AND *Debug*<br>
27+
- Runtime Library for *Release* must be set to "Multi-threaded DLL (/MD)":<br>
28+
<img src="https://gitlab.com/tuda-fzd/perception-sensor-modeling/reflection-based-lidar-object-model/uploads/38c646d7442362bbbbce936d67a26836/ASM_protobuf_runtime_library_release.png" width="800"><br><br>
29+
- Runtime Library for *Debug* must be set to "Multi-threaded Debug DLL (/MDd)":<br>
30+
<img src="https://gitlab.com/tuda-fzd/perception-sensor-modeling/reflection-based-lidar-object-model/uploads/be2f9e3f0cda9da9bb4686805379b37e/ASM_protobuf_runtime_library_debug.png" width="800">
31+
5. Build Solution for *Release* AND for *Debug*
32+
6. Build INSTALL for *Release* AND for *Debug*

lib/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# FZD OSMP Framework - *lib* Folder
1+
# Modular OSMP Framework - *lib* Folder
22

3-
The lib folder contains libraries used for the entire model. At the moment only OSI and FMI are included, but you can add other libraries for your model, e.g. as git submodules.
3+
The lib folder contains libraries used for the entire model. At the moment OSI, FMI and Eigen are included, but you can add other libraries for your model, e.g. as git submodules.

src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FZD OSMP Framework - src Folder
1+
# Modular OSMP Framework - src Folder
22

33
The src folder is subdevided into *model* and *osmp*.
44

src/model/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FZD OSMP Framework - *model* Folder
1+
# Modular OSMP Framework - *model* Folder
22

33
The *model* folder contains the actual model logic and is subdevided into *include*, *profiles* and *strategies*. It also contains the *model_name.conf*. In this file the name of the model can be set. This will define the name of the overall fmu package as well as the name inside the model description.
44

src/model/include/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# FZD OSMP Framework - *include* Folder
1+
# Modular OSMP Framework - *include* Folder
22

33
The include folder does not have to be changed by the user. It contains the definition of the strategy class and defines framework in which the strategies are called.

src/model/profiles/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FZD OSMP Framework - *profiles* Folder
1+
# Modular OSMP Framework - *profiles* Folder
22

33
The *profiles* folder contains the parts of the parameter profiles, that are strategy-independent.
44

src/model/profiles/profile_list.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* TODO add further profiles and profile generators here */
2525
#include <model/profiles/profile_example.hpp>
2626

27-
bool CFZDSensorModel::try_load_profile(const std::string &name) {
27+
bool CFrameworkPackaging::try_load_profile(const std::string &name) {
2828
if (name == "example") {
2929
profile = model::profile::example::generate();
3030
return true;

src/model/strategies/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# FZD OSMP Framework - *strategies* Folder
1+
# Modular OSMP Framework - *strategies* Folder
22

33
The strategies folder contains individual folders for every strategy. Inside the modular strategies the actual model code is written. So every strategy is contained in their own folder with their own includes, src and CMakeLists.
44

5-
The *sequence.conf* defines, in which order the strategies are called by the framework. The indicidual strategies are listed in lines in this file. In this example only the "empty-strategy" is called.
5+
The *sequence.conf* defines, in which order the strategies are called by the framework. The individual strategies are listed in lines in this file. In this example first the "empty-strategy" is called, then the "csv-output-gtobjects-strategy".

0 commit comments

Comments
 (0)