How to add new state value

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Yuta Shimane
Posts: 5
Joined: Wed May 09, 2018 4:14 pm

How to add new state value

Post by Yuta Shimane » Mon Dec 02, 2019 2:39 am

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

Tags:

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: How to add new state value

Post by Thomas Uchida » Mon Dec 02, 2019 9:49 am

The methods setZ() and updZ() do not create state variables- they just provide access to the variables that already exist (if any).
If you know how to add or define new valuables to the state, please help me.
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.

User avatar
Yuta Shimane
Posts: 5
Joined: Wed May 09, 2018 4:14 pm

Re: How to add new state value

Post by Yuta Shimane » Mon Dec 02, 2019 10:42 pm

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

POST REPLY