Hello every one
I am going to add some muscles to an openSim model in a matlab loop, i used this command to add this muscles :
osimModel.updForceSet.adoptAndAppend(mus(j));
although for a small loop it works correctly, but sometimes matlab crashed suddenly, i think it is because of over writing on a model file, how can i fix this issue?
thanks
Zohreh
over wiriting on an opensim model
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: over wiriting on an opensim model
Maybe it has to do with who owns the memory. When you append or add something to an OpenSim Model, it should be allocated on the heap and the allocated memory is managed (freed) internally by the model. When you define an object in Matlab/Python it is not allocated on the heap. Therefore, when code gets out of scope (e.g., exit a function) the muscle destructor is called. Maybe you can try cloneAndAppend to see if it works.
https://github.com/opensim-org/opensim- ... Set.h#L474
https://github.com/opensim-org/opensim- ... Set.h#L474