Hi, everyone.
I'm creating controller for simulation in MATLAB now. I want to store valuable for controller the state to use integrator. I used following function to store, however, value was not stored in Z which is auxiliary continuous state variables, because Z is empty matrix.
osimState.setZ(Vector(1, a)); or osimState.updZ().set(1, a);
Should I define subsystem to store valuable for controller?
If you know how to add or define new valuables to the state, please help me.
Best regards.
-yuta
How to add new state value
- Yuta Shimane
- Posts: 5
- Joined: Wed May 09, 2018 4:14 pm
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: How to add new state value
The methods setZ() and updZ() do not create state variables- they just provide access to the variables that already exist (if any).
If your controller needs to define its own state variables, you can write a new Component (in C++) that extends the Controller class. You would define a new state variable in extendAddToSystem(). Please see the "Writing your own Component" section of the API Guide: https://simtk.org/api_docs/opensim/api_ ... components. If you decide to pursue this strategy, the ControllerExample code might be a good starting point: https://github.com/opensim-org/opensim- ... lerExample.If you know how to add or define new valuables to the state, please help me.
- Yuta Shimane
- Posts: 5
- Joined: Wed May 09, 2018 4:14 pm
Re: How to add new state value
Dear, Thomas.
Thank you for your reply and suggestion.
I understood I can't add state variables by using the functions in MATLAB. I will learn and do as your suggestion.
Best regards
-Yuta
Thank you for your reply and suggestion.
I understood I can't add state variables by using the functions in MATLAB. I will learn and do as your suggestion.
Best regards
-Yuta