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)
How to get HunatCrossleyForce Or GRF in matlab?
- Samane Amini
- Posts: 100
- Joined: Sun Jan 12, 2020 3:48 am
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: How to get HunatCrossleyForce Or GRF in matlab?
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
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
- Samane Amini
- Posts: 100
- Joined: Sun Jan 12, 2020 3:48 am
Re: How to get HunatCrossleyForce Or GRF in matlab?
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
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
- Nicos Haralabidis
- Posts: 188
- Joined: Tue Aug 16, 2016 1:46 am
Re: How to get HunatCrossleyForce Or GRF in matlab?
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
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