Hi,
I'm trying to compute the maximum torque developped by the elbow during isometric flexion with a simplified model with only one muscle (BIClong). I'm trying to get the same values as computed in the Opensim GUI in plot Menu which is a maximum moment for an angle of almost 90 degrees with a value of 28 N.m. However I'm unable to find such value with my model (max torque=1.6N.m....!!!) and can't find the mistake. I put all the files in attachments and I'm using Cmake and Visual Studio.
Thanks for your help.
Maximum torque developped by elbow
- YAMEN AL HABASH
- Posts: 7
- Joined: Tue May 21, 2019 5:22 am
Maximum torque developped by elbow
- Attachments
-
- main.cpp
- (553 Bytes) Downloaded 16 times
-
- isometric_v2.h
- (114 Bytes) Downloaded 16 times
-
- isometric_v2.cpp
- (2.28 KiB) Downloaded 18 times
Tags:
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: Maximum torque developped by elbow
On line 61 of isometric_v2.cpp, you are computing the moment arm given the final state only. Instead, I think you want to compute the moment arm at each instant throughout the simulation and find the maximum. You could try using a StatesTrajectoryReporter (https://simtk.org/api_docs/opensim/api_ ... orter.html) to collect the states during the simulation, then step through the states to find the maximum moment arm.
- YAMEN AL HABASH
- Posts: 7
- Joined: Tue May 21, 2019 5:22 am
Re: Maximum torque developped by elbow
Hi,
Thank you for your help. I tried the method you suggested using a StatesTrajectoryReporter, however it doesn't seem to recognise the maximum state selected. here is the error returned:
Angle value :90
Updating Model file from 20303 to latest format...
Loaded model arm26 from file Arm26.osim
ControllerSet 'Controllers' was renamed and is being reset to 'controllerset'.
ComponentSet 'MiscComponents' was renamed and is being reset to 'componentset'.
Exception caught in Thelen2003Muscle::calcMuscleDynamicsInfo
of BIClong
Exception caught in Thelen2003Muscle::calcMuscleLengthInfo
of BIClong
SimTK Exception thrown at state.cpp:981:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date with respect to one of its explicit prerequisites.
(Required condition 'm_isUpToDateWithPrerequisites' was not met.)
The maximum moment found is : 1
Angle : 90
I also tried another method: the simulate() function can return the final state of the simulation so I stored it and tried to get the fiber force of this final state (I want the final state because it should be the higher one as we set an activation that is at it's maximum at the end of the simulate with the brain). It doesn't worker either and shows the following error:
Angle value :90
Updating Model file from 20303 to latest format...
Loaded model arm26 from file Arm26.osim
ControllerSet 'Controllers' was renamed and is being reset to 'controllerset'.
ComponentSet 'MiscComponents' was renamed and is being reset to 'componentset'.
SimTK Exception thrown at state.cpp:964:
Expected stage to be at least Instance in getCacheEntry but current stage was Model
The maximum moment found is : 1
Angle : 90
I attached the first method in iso1.cpp and the second one in iso2.cpp.
Thank's
Thank you for your help. I tried the method you suggested using a StatesTrajectoryReporter, however it doesn't seem to recognise the maximum state selected. here is the error returned:
Angle value :90
Updating Model file from 20303 to latest format...
Loaded model arm26 from file Arm26.osim
ControllerSet 'Controllers' was renamed and is being reset to 'controllerset'.
ComponentSet 'MiscComponents' was renamed and is being reset to 'componentset'.
Exception caught in Thelen2003Muscle::calcMuscleDynamicsInfo
of BIClong
Exception caught in Thelen2003Muscle::calcMuscleLengthInfo
of BIClong
SimTK Exception thrown at state.cpp:981:
Error detected by Simbody method getCacheEntry: State Cache entry was out of date with respect to one of its explicit prerequisites.
(Required condition 'm_isUpToDateWithPrerequisites' was not met.)
The maximum moment found is : 1
Angle : 90
I also tried another method: the simulate() function can return the final state of the simulation so I stored it and tried to get the fiber force of this final state (I want the final state because it should be the higher one as we set an activation that is at it's maximum at the end of the simulate with the brain). It doesn't worker either and shows the following error:
Angle value :90
Updating Model file from 20303 to latest format...
Loaded model arm26 from file Arm26.osim
ControllerSet 'Controllers' was renamed and is being reset to 'controllerset'.
ComponentSet 'MiscComponents' was renamed and is being reset to 'componentset'.
SimTK Exception thrown at state.cpp:964:
Expected stage to be at least Instance in getCacheEntry but current stage was Model
The maximum moment found is : 1
Angle : 90
I attached the first method in iso1.cpp and the second one in iso2.cpp.
Thank's
- YAMEN AL HABASH
- Posts: 7
- Joined: Tue May 21, 2019 5:22 am
Re: Maximum torque developped by elbow
I think there is a problem with the getFiberForce() function . Therefore, I tried to get this value from the calcMuscleDynamicsInfo() function of Thelen2003Muscle. However, the function is unaccessible. I tried to force the conversion of Muscle to Thelen2003Muscle in this command:
const OpenSim::Thelen2003Muscle bicLong = osimModel.getMuscles().get("BIClong");
It doesn't seem to have this type of conversion
If someone has any idea of how to get the fiber force through this function
Thanks
const OpenSim::Thelen2003Muscle bicLong = osimModel.getMuscles().get("BIClong");
It doesn't seem to have this type of conversion
If someone has any idea of how to get the fiber force through this function
Thanks
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: Maximum torque developped by elbow
getFiberForce() is a method in the Muscle class (https://simtk.org/api_docs/opensim/api_ ... baa3d7f314). You should be able to do something like this:If someone has any idea of how to get the fiber force through this function
Code: Select all
myMuscle = model.getMuscles().get("BIClong");
myFiberForce = myMuscle.getFiberForce(myState);
Looks like you're missing an "&" after "OpenSim::Thelen2003Muscle" -- you want to create a reference to the muscle, not a new instance.const OpenSim::Thelen2003Muscle bicLong = osimModel.getMuscles().get("BIClong");
- YAMEN AL HABASH
- Posts: 7
- Joined: Tue May 21, 2019 5:22 am
Re: Maximum torque developped by elbow
This is also how I used the method of getFiberForce(), however it does not work and returns the errors I presented in the post of Thu Jun 20, 2019 12:44 am . This is why I tried to use calcMuscleDynamicsInfo() from the ThelenMuscle2003 which I could not make it work.
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: Maximum torque developped by elbow
The getFiberForce() method is used within the API. Here are a few examples:
- testStatesTrajectory.cpp, line 243: https://github.com/opensim-org/opensim- ... y.cpp#L243
- MuscleAnalysis.cpp, line 559: https://github.com/opensim-org/opensim- ... s.cpp#L559
- testMuscleMetabolicsProbes.cpp, line 428: https://github.com/opensim-org/opensim- ... s.cpp#L428
- testStatesTrajectory.cpp, line 243: https://github.com/opensim-org/opensim- ... y.cpp#L243
- MuscleAnalysis.cpp, line 559: https://github.com/opensim-org/opensim- ... s.cpp#L559
- testMuscleMetabolicsProbes.cpp, line 428: https://github.com/opensim-org/opensim- ... s.cpp#L428