-
Notifications
You must be signed in to change notification settings - Fork 43
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
Set control parameters from Simulink block #26
Comments
This is a challenging problem and finding a clean solution will not be easy. Let's focus on the gains since they are the more complex structure of our controllers. Simulink models need to find the gains stored into the workspace, otherwise the values couldn't be accessed by blocks directly (e.g. Gain) and neither by blocks implementing a Matlab function. We cannot avoid this. Generally speaking we can store values in 3 ways:
It would be nice finding a way to have a single point where these values can be stored, accessible from either simulink and the autogenerated code. I see the following problems:
@gabrielenava @S-Dafarra @traversaro @DanielePucci Do you have any other idea? I just came up with option 4, and it is what I like more. It is the more general and (of course) also the one that in my opinion needs more investigation time. |
Probably I have not fully understood how the parameters are parsed inside the autogenerated code. Anyway, maybe we can hit two pigeons with a stone if we use a matlab script which fills a I think it is necessary to have a separate script to generate the Assuming then to have the autogenerated code inside a |
Another possibility could be also to save the matlab workspace directly and use |
I started working on this task and would like to reach soon a basic support for parametric controllers. Particularly, I want to add the support of performing gain tuning even from the automatically generated code. These kind of parameters are now stored in a My idea is to move these parameters in a new
It should not be too difficult. The only downside I see here is that we need to add a single block for every parameter we want to read. Furthermore, only numeric parameters will be supported. For what concern the automatically generated code, the support will come for free since this new parameters block will be treated as all the other ones. |
cc @traversaro |
@gabrielenava can you check with our Simulink users that this is reasonable and not too much cumbersome? General comment: |
I spoke with @gabrielenava @S-Dafarra @FabioBergonti and we reached the following conclusions:
In this way, gain tuning from the autogenerated code is still possible without having Matlab / Simulink. The gain tuning is performed on the cc @traversaro @DanielePucci @aikolina @Yeshasvitvs |
Cool. A few comments:
|
Yes, my idea is to run the script as a pre-run callback and place the
Instead of running directly the
If I understood what you mean, since the script is executed before the controller starts, all the logic would be applied. The line you reported is read only once, right @gabrielenava?
I don't have extensive experience with octave, but I assumed that simple calculations as this case would represent trivial scripts that should not be affected by the challenges you mentioned. Anyway, CI is always a good idea. |
Yes, this line is read only once. |
@gabrielenava so where is the logic for gain scheduling handled? |
Gain scheduling is performed only during the |
Perfect, so it should work fine with the proposed method, right? |
If I understood correctly it should work, as we do not update the gain matrices real time, but rather we load since the beginning all the gains for all the states of the state machine, and there is a switch inside Simulink that select the correct gain matrices according to the state. |
The draft of the SSP standard is available at https://ssp-standard.org/publications/SSP10RC1/SystemStructureAndParameterization10RC1.pdf . The relevant section is section 6, System Structure Parameter Values (SSV). |
I checked the draft, and apparently 1.0 will not support vector/matrix parameters, so it is quite useless at the moment for our use case. I guess vector parameters will come with version 1.1, currently planned for the end of 2019/beginning of 2020 (see slide 12 of https://ssp-standard.org/publications/2018_American_Modelica_Conference/2018_Usermeeting_SSP-StatusandPlans.pdf). |
the activity is not going to be addressed in the near future, closing the issue for now |
Currently, the control parameters such as gains and regularization terms are stored in matlab functions like this one.
The autogenerated C++ code from Simulink ( https://github.com/robotology-playground/autogenerated-whole-body-controllers) will have hard-coded gains that cannot be modified without editing the source code.
Therefore it may be useful to change the way Simulink loads these parameters, namely there should be a Simulink block that reads these values from a configuration file, that can be read both from the Simulink code and from the autogenerated c++ code.
cc @diegoferigo
The text was updated successfully, but these errors were encountered: