How to get HunatCrossleyForce Or GRF in matlab?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

How to get HunatCrossleyForce Or GRF in matlab?

Post by Samane Amini » Mon Aug 31, 2020 4:40 am

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)

Tags:

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: How to get HunatCrossleyForce Or GRF in matlab?

Post by Nicos Haralabidis » Mon Aug 31, 2020 1:10 pm

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

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: How to get HunatCrossleyForce Or GRF in matlab?

Post by Samane Amini » Mon Aug 31, 2020 10:15 pm

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

User avatar
Nicos Haralabidis
Posts: 196
Joined: Tue Aug 16, 2016 1:46 am

Re: How to get HunatCrossleyForce Or GRF in matlab?

Post by Nicos Haralabidis » Tue Sep 01, 2020 12:23 am

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

POST REPLY