Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current status of tunable parameters #42

Open
diegoferigo opened this issue Feb 7, 2019 · 3 comments
Open

Current status of tunable parameters #42

diegoferigo opened this issue Feb 7, 2019 · 3 comments

Comments

@diegoferigo
Copy link
Member

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:

params.storeParameter<std::string>(
"Addition",
blockfactory::core::ParameterMetadata(
blockfactory::core::ParameterType::STRING, 2.0, 1.0, 1.0, "Operation"));

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:

struct P_AutogenerationExample_T_
{
real_T Constant_Value[5]; /* Expression: [1 2 3 4 5]
* Referenced by: '<Root>/Constant'
*/
};

AutogenerationExampleModelClass::AutogenerationExampleModelClass()
{
static const P_AutogenerationExample_T AutogenerationExample_P_temp = {
/* Expression: [1 2 3 4 5]
* Referenced by: '<Root>/Constant'
*/
{1.0, 2.0, 3.0, 4.0, 5.0}}; /* Modifiable parameters */
/* Initialize tunable parameters */
AutogenerationExample_P = AutogenerationExample_P_temp;
}

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
Copy link
Member Author

Also related to robotology/whole-body-controllers#26

@traversaro
Copy link
Member

traversaro commented Feb 7, 2019

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
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants