Skip to content

RaspberryPi

Torsten Sommer edited this page Jul 18, 2019 · 3 revisions

Simulating source code FMUs on a Raspberry Pi

This tutorial shows step-by-step how to simulate an FMU on a Raspberry Pi. Even though the Raspberry Pi does not have an x86 compatible processor (as implicitly assumed by the FMI standard) it is still possible to compile an FMI 2.0 source code FMU and use FMPy to simulate it. The following commands were tested over SSH on a Raspberry Pi 3 (version B) with Raspbian Stretch Lite that has been configured for headless access.

Install the dependencies and FMPy:

pi@raspberrypi:~ $ sudo apt-get update
[...]
pi@raspberrypi:~ $ sudo apt-get install python-numpy python-lxml python-pathlib python-pip
[...]
pi@raspberrypi:~ $ sudo pip install --no-deps fmpy
[...]

Download, compile and simulate an FMU:

pi@raspberrypi:~ $ wget https://github.com/modelica/fmi-cross-check/raw/master/fmus/2.0/cs/c-code/MapleSim/2016.2/CoupledClutches/CoupledClutches.fmu
[...]
pi@raspberrypi:~ $ fmpy info CoupledClutches.fmu

Model Info

  FMI Version       2.0
  Model Name        CoupledClutches
  Description       Model CoupledClutches
  Platforms         c-code, win32
[...]
pi@raspberrypi:~ $ fmpy compile CoupledClutches.fmu
Compiling CoupledClutches.so...
[...]
pi@raspberrypi:~ $ fmpy info CoupledClutches.fmu
[...]
  Platforms         c-code, linux32, win32
[...]
pi@raspberrypi:~ $ fmpy simulate CoupledClutches.fmu --output-file CoupledClutches_out.csv
pi@raspberrypi:~ $ cat CoupledClutches_out.csv
"time","outputs[1]","outputs[2]","outputs[3]","outputs[4]"
0,10,0,0,0
0.003,9.97,0.03,0,0
0.006,9.94282,0.0599999,0,0
0.009,9.91845,0.0899992,0,0
0.015,9.87786,0.149994,0,0
[...]
pi@raspberrypi:~ $