robotology / blockfactory

A tiny framework to wrap algorithms for dataflow programming
https://robotology.github.io/blockfactory
GNU Lesser General Public License v2.1
40 stars 16 forks source link

Notes about FMI support #5

Open traversaro opened 5 years ago

traversaro commented 5 years ago

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.

traversaro commented 5 years ago

Comparison of S-Functions and FMUs:

traversaro commented 5 years ago
traversaro commented 5 years ago

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.

diegoferigo commented 5 years ago

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 :/

traversaro commented 5 years ago
OT reply moved to https://github.com/robotology/blockfactory/issues/10#issuecomment-454439725 > 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. It is trivial, *if you have MATLAB/Simulink*. It would be nice to be able to setup a blockfactory library without having MATLAB/Simulink on your PC (my current situation, for example : ) ). > 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 :/ Why this should be the case? Everything that you input through the GUI should be contained in the `.slx`, right? As far as I can see, in particular the Mask information is contained in the `` tag of `simulink/blockdiagram.xml` , for example for the `SignalMath` block in the `ExampleToolbox`: ~~~xml

[2, 1]

[335, 69, 470, 116]

1

BlockFactory

'SignalMath','ExampleToolbox',operation

off

off

off

disp('Signal Math') port_label('input',1,'Input 1') port_label('input',2,'Input 2') port_label('output',1,'Output') Operation Addition
~~~ Indeed automatically generating this may not be trivial, but I do not think it is impossible.
traversaro commented 5 years ago

We can probably move this discussion in a separate issue, btw.

diegoferigo commented 5 years ago

We can probably move this discussion in a separate issue, btw.

:+1:

OT reply > Indeed automatically generating this may not be trivial, but I do not think it is impossible. Just to be clear, I never intended that this is impossible ^^ It is just complicating your own life. And, btw, if you don't plan to use Simulink (since you don't have it), why do you want to create a Simulink Library? If the aim is using / testing blockfactory, for simple models you could: - Create a plugin library containing classes that inherit from `blockfactory::core::Block` - Implement a simple `blockfactory::core::BlockInformation` for your use case - Develop a system that connects the blocks by assigning a simulation order and sharing data between their input / outputs with buffers Without having Simulink I don't see any benefit of passing through the `slx`, but probably I didn't get entirely what you're trying to do.
traversaro commented 5 years ago

Simulink related discussion moved to https://github.com/robotology/blockfactory/issues/10 .

traversaro commented 5 years ago

PR adding some part of the array support to the FMI standard: https://github.com/modelica/fmi-standard/pull/543 .

traversaro commented 4 years ago

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.