Page 1 of 1

How to get HunatCrossleyForce Or GRF in matlab?

Posted: Mon Aug 31, 2020 4:40 am
by amini_opensim
Hi
How Can i to get the GRF force of HunatCrossleyForce in matlab?
I know following code get the muscle force but no GFR?

Model.getForceSet().get('glut_med1_r').getRecordValues(state)

Re: How to get HunatCrossleyForce Or GRF in matlab?

Posted: Mon Aug 31, 2020 1:10 pm
by nicos1993
Hello Samaneh,

Assuming you have realized to the correct state (in this example osimState), the following line should return the forces from the Hunt-Crossley model (version 3.3 at least):

force1 = osimModel.getForceSet().get('Foot_Ground_R1').getRecordValues(osimState);
fx1 = force1.get(6); % returns the ant-post GRF component if I remember rightly.

where Foot_Ground_R1 is the name of the contact sphere in the model. force1 will then be a 12x1 vector, in which the first 6 terms are the forces and moments applied by the foot to ground, second 6 terms are the reaction forces and moments. You will have to check whether the forces are reported first, or the moments, but I believe it's the forces.

Hope that helps!

Nicos

Re: How to get HunatCrossleyForce Or GRF in matlab?

Posted: Mon Aug 31, 2020 10:15 pm
by amini_opensim
Hi Nicos
thanks for replying me. I do your suggestion. but this is wrong:

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)

Please guide me

Re: How to get HunatCrossleyForce Or GRF in matlab?

Posted: Tue Sep 01, 2020 12:23 am
by nicos1993
Hello Samaneh

The issue appears to be that you have not realized the system's state to the dynamics stage (yourModel.realizeDynamics(osimState)). You need to do this before extracting the contact sphere forces.

Kind regards,

Nicos Haralabidis