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

Current status of tunable parameters #42

Open diegoferigo opened 5 years ago

diegoferigo commented 5 years ago

Despite the code generated with Simulink Coder supports tunable parameters, the ones coming from the block masks are not accessible. Refer to the Operation selected from the drop-down menu of the SignalMath block of the example:

https://github.com/robotology/blockfactory/blob/a05e6d0d192274ebe4f4fae57d8987c9dfa3cde0/example/matlab/AutogenerationExample_grt_rtw/AutogenerationExample.cpp#L104-L107

In line 105 it is hardcoded, and cannot be changed.

Instead, for what concern parameters that come from the workspace (and constants present in the Simulink Model are analogous), they are stored in a static struct:

https://github.com/robotology/blockfactory/blob/a05e6d0d192274ebe4f4fae57d8987c9dfa3cde0/example/matlab/AutogenerationExample_grt_rtw/AutogenerationExample.h#L75-L80

https://github.com/robotology/blockfactory/blob/a05e6d0d192274ebe4f4fae57d8987c9dfa3cde0/example/matlab/AutogenerationExample_grt_rtw/AutogenerationExample.cpp#L390-L400

Despite they can be changed during runtime (the symbol is static), it's basically impossible to know what is the index of the parameter you want to access. In this case there's only one, but if there were more, the cpp will contain a curly braces initialization for all of them. It would be great having a way to access these parameters e.g. by name (and I mean string, not name of the variable like P_AutogenerationExample_T_.Constant_Value in this case), but the approach used by the coder does not allow it.

cc @traversaro

diegoferigo commented 5 years ago

Also related to https://github.com/robotology/whole-body-controllers/issues/26

traversaro commented 5 years ago

Are we generating the C API to access the parameters, as described in https://github.com/Kvixen/Simulix#exporting-your-model-from-simulink ? Relevant matlab docs: https://it.mathworks.com/help/rtw/ug/data-interchange-using-the-c-api.html .

diegoferigo commented 5 years ago

I remember I tried them but I had no luck even with them.