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

Implement support for stateful systems #8

Open traversaro opened 5 years ago

traversaro commented 5 years ago

This is probably a long term goal, but for now let's collect some possible basic steps:

traversaro commented 5 years ago

For the discrete state, it is also important to specify the sample time of the period update connected to the discrete state update. See https://it.mathworks.com/help/simulink/sfg/sample-times-cpp.html#f4-33929 for a description of this concept in the Simulink docs, and https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_leaf_system.html#a262f71637a37127840acefca3bda8897 for the related API in Drake's System API.

traversaro commented 5 years ago

For the discrete state, it is also important to specify the sample time of the period update connected to the discrete state update.

Related to that, for properly describing this in FMUs it is necessary to wait for FMI 3. See https://github.com/modelica/fmi-standard/issues/353 and http://www.ep.liu.se/ecp/132/057/ecp17132507.pdf .

traversaro commented 5 years ago

Still related to stateful systems, it is relevant to mention that simStateCompliance should be properly set in Simulink: https://github.com/robotology/blockfactory/blob/f8a363e595fb748d313f3785f5a94d831a3ee796/sources/Simulink/src/BlockFactory.cpp#L175 . At the moment, it is set to USE_CUSTOM_SIM_STATE. This means (see https://it.mathworks.com/help/simulink/sfg/s-function-compliance-with-the-simstate.html) that the S-Function "has mdlGetSimState and mdlSetSimState methods", that are not implemented in the existing BlockFactory S-Function.

diegoferigo commented 5 years ago

That part of S-Function code is a very old heritage (from first versions of WBI-Toolbox I think). All of them would need a refreshing, not only this one.

diegoferigo commented 4 years ago

cc @fjandrad