trouble running getRecordValues in matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Afshin Samani
Posts: 6
Joined: Thu Jun 04, 2020 3:21 am

trouble running getRecordValues in matlab

Post by Afshin Samani » Fri May 28, 2021 8:47 am

Hi,

I tried something like the following code in matlab and faced an error (matlab environment has been configured before and I could run a number of other methods):

import org.opensim.modeling.*
EnvModel = Model('Modelfile');
state = EnvModel.initSystem(); % I also tried with initializeState with the same error message
force = EnvModel.getForceSet.get(0);
values = force.getRecordValues(state);

Then I get the following error:

Java exception occurred:
java.lang.RuntimeException: SimTK Exception thrown at GeneralContactSubsystem.cpp:131:
Expected stage to be at least Dynamics in GeneralContactSubsystemImpl::getContacts() but current stage was Velocity

at org.opensim.modeling.opensimSimulationJNI.Force_getRecordValues(Native Method)

at org.opensim.modeling.Force.getRecordValues(Force.java:121)

Any hint on what could be wrong?

Best regards,
Afshin

Tags:

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: trouble running getRecordValues in matlab

Post by Ayman Habib » Fri May 28, 2021 9:25 am

Hi Afshin,

When you call initSystem, the state is realized only to a specific stage (Position), so quantities that depend on position can be extracted directly, computing and reporting force values requires realization to a higher stage so you'll need to call the proper realize...() method first. This is documented in the doxygen documentation of OpenSim::Model class here
https://simtk.org/api_docs/opensim/api_ ... Model.html

Hope this helps,
-Ayman

POST REPLY