Open traversaro opened 5 years ago
Comparison of S-Functions and FMUs:
Code-based configuration vs file based configuration
In Simulink S-Functions and consequently in blockfactory, several configuration info such as the number of the ports, etc etc are specified by calling specific methods (in particular setIOPortsData
in the configureSizeAndPorts
method). In FMI, this information are specified in the XML file. To handle this, possible solutions are (the last one is my favorite):
configureSizeAndPorts
method of the block to wrap as FMU (this will be problematic when cross-compiling, but it seems that easy solution for now)TL;DR: Handle how to generate XML files for FMU block
Generate the XML files after the build by running a program that invokes the
configureSizeAndPorts
method of the block to wrap as FMU
Interestingly, part of this solution could be eventually re-used to automatize the existing manual process of writing the .slx
file of the block library (i.e. the one described in https://robotology.github.io/blockfactory/mkdocs/create_new_library/#create-an-new-simulink-library).
As you can check by manually inspecting an .slx
file, and by reading in https://stackoverflow.com/questions/23408186/information-about-simulink-mdl-and-slx-formats, the .slx
is just a .zip
file that contains a bunch of .xml
(and some other format) files. A complete parser for reading/writing .slx
does not seem to be available or feasible, but perhaps it could make sense to have a "template" .slx
that can be be configured based on the library blocks' and ports.
Having a templated slx imho does not simplify that much the creation / maintenance of a Simulink Library, it is usually a trivial step from the GUI. I am pretty sure that Matlab (even the cli version) has some functions to automatize it without dealing with the file formats.
The main problem are the masks, the have to be developed from the GUI. I'm afraid that operating only on the slx
or mdl
would never be enough :/
[2, 1]
[335, 69, 470, 116]
1
BlockFactory
'SignalMath','ExampleToolbox',operation
off
off
off
We can probably move this discussion in a separate issue, btw.
We can probably move this discussion in a separate issue, btw.
:+1:
Simulink related discussion moved to https://github.com/robotology/blockfactory/issues/10 .
PR adding some part of the array support to the FMI standard: https://github.com/modelica/fmi-standard/pull/543 .
Interesting paper on FMI interface with a real time communication protocol (in this case RabbitMQ): https://github.com/INTO-CPS-Association/rabbitmq-fmu-documentation/blob/e6e57da07394858bc1519ef7b746df8459123ed6/rabbitmq-fmu.pdf , similar to how BlockFactory is used with YARP.
These are some random notes related to get
blockfactory
to generate FMUs according to the FMI standard ( https://fmi-standard.org/downloads/ ). It is meant to be more a place where to store relevant information, rather than an issue that should be closed in the short term. @diegoferigo let me know if you are ok with this, or if you prefer that I move this notes/brainstorming somewhere else.FMI version:
a[1]
,a[2]
, etc etc, see https://fmi-standard.org/docs/2.0.1-develop/#_variable_naming_conventions_variablenamingconvention . However, full support will be included only in FMI v3, that is currently under development in themaster
branch of https://github.com/modelica/fmi-standard . For this reason, it make sense to just aim for FMI v3 only support, even if there is almost no tool support at the moment, given the draft status of the specification. For preliminary testing, it could make sense to explore the use of thefeature/fmi3
branch of FMPy: https://github.com/CATIA-Systems/FMPy/tree/feature/fmi3/fmpy .FMI direct feed-through:
y = f(u)
, i.e."instantaneous" systems with just a direct feed-through. There are a few issues in the FMI issue tracker related to systems with direct feed-through, that we should checkout: https://github.com/modelica/fmi-standard/issues/117, https://github.com/modelica/fmi-standard/issues/126FMI for Model Exchange