segment power analysis

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Tue Mar 21, 2023 4:52 pm

Thanks Nick. I will try it down the line.

But until then, the challenge to me would be converting the forces from all contact surfaces on the feet to a single vector in the "virtual force platform" file. I already managed to get the sum of all force vectors (X,Y,Z) but not yet the position of the GRF vector in lab space.

If someone can share a tip or advice, that would be wonderful. With that, I think is creating a version of the model where the contact forces are removed from the ForceSet, and them follow the normal procedures in OpenSim documentation.

What you think?

Best regards.

User avatar
Nicholas Bianco
Posts: 1045
Joined: Thu Oct 04, 2012 8:09 pm

Re: segment power analysis

Post by Nicholas Bianco » Wed Mar 22, 2023 10:38 am

Hi Carlos,

I recently added changes to 'createExternalLoadsTableForGait' to compute center of pressure locations: https://github.com/opensim-org/opensim- ... s.cpp#L321.

You could recreate this for your pipeline to get the position of the GRF vector in the lab space.

-Nick

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Wed Mar 22, 2023 6:23 pm

Great!!!

I will start with that. Thanks a lot for the help.

I will get back here with some results (fingers crossed) or more doubts :lol:

Best regards.

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Wed Mar 20, 2024 5:12 pm

Hello Nick and everyone.

I saw that the OpenSim 4.5 had enhancements in Moco as well.

https://simtk-confluence.stanford.edu:8 ... =130187315
The utility function createExternalLoadsTableForGait() now outputs center of pressure locations for foot-ground contact force elements.
So, does it mean I can run it, get the resultant contact force for each foot, and load it to IAA in OpenSim?

(fingers crossed emoji).

Best regards.

User avatar
Nicholas Bianco
Posts: 1045
Joined: Thu Oct 04, 2012 8:09 pm

Re: segment power analysis

Post by Nicholas Bianco » Thu Mar 21, 2024 3:37 pm

Hi Carlos,

I realized recently that while the COPs are now included, I don't think I'm computing the "vertical" torque that you would normally expect; I'm just returned the summed contact sphere torques. (Adding the COPs was mainly for visualization purposes, I should have include the vertical torque while I was at it -- my bad!)

But it should be relatively easy to recreate the calculations based on the source code for this utility and modify them to get exactly what you need for IAA. If you want to give that a shot I could port it back into the OpenSim utility.

-Nick

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Thu Mar 21, 2024 5:18 pm

Hello Nick,

Let's give it a try, for sure! I'm currently in "writing mode", so I will get back to this soon (I hope).

And don't worry. I just can say "Thank you Moco Team" for all that you guys had been doing. It is the main tool for my research, and as years went by, each new version solved something I needed :D .

I will keep updating this thread with my results and doubts.

Best regards.

User avatar
Nicholas Bianco
Posts: 1045
Joined: Thu Oct 04, 2012 8:09 pm

Re: segment power analysis

Post by Nicholas Bianco » Fri Mar 22, 2024 11:55 am

Sounds good, Carlos! Glad to hear Moco has been a reliable research tool for you :)

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Fri Sep 13, 2024 12:15 am

Hello Nick,

My simulations are soon over, and I need to implement IAA right now (I have no more excuses for delaying this task :lol: ).

I realized I could have access to createExternalLoadsTableForGait main variables with the ForceReporter. It gives me the Forces and Torques for Spheres and HalfPlane. I hadn't the courage to update to OpenSim 4.5 yet (I think I was an early adopter of OpenSim 4.4)

I wonder more about the difference between the measurements in Sphere and HalfPlane frames. The forces are opposites, but the torques are not; here are some graphs.
diffForce.png
diffForce.png (14.63 KiB) Viewed 291 times
diffTorque.png
diffTorque.png (20.59 KiB) Viewed 291 times
So, if I treat the HalfPlane data as a force plate, I should add the Sphere torque to the calculation of the COP since the plane exerts this torque in the Sphere (I suppose) and the Sphere exerts the same torque in the Halfplane. But if I do that, the COP will not be under the Sphere. If I do as your code, the COP is correctly placed. Here is a picture of its place with a single HalfPlane/Sphere pair.
Cop.png
Cop.png (113.53 KiB) Viewed 291 times
Moreover, if I treat the HalfPlane data as a force plate, the twisting torque under the Sphere would require COP information and forces. Again, it is not equal to the Sphere torque in the Y direction (twist had very low values).
diffTwist.png
diffTwist.png (12.55 KiB) Viewed 291 times
Finally, by comparing the data, the method createExternalLoadsTableForGait should change.

What do you think? How are the multiple Sphere and HalfPlane forces related?

Best regards.

User avatar
Nicholas Bianco
Posts: 1045
Joined: Thu Oct 04, 2012 8:09 pm

Re: segment power analysis

Post by Nicholas Bianco » Tue Sep 17, 2024 2:03 pm

Hi Carlos,

I think you want to only want to use the half-plane forces and torques for you GRF and COP calculation. You don't want to mix half-plane and sphere forces, since they should be equal and opposite (i.e., you only want one or the other). It's better to use the half-plane values since you know that all the forces and torque are both 1) expressed in the ground frame and 2) applied to / are about the origin.

Best,
Nick

User avatar
Carlos Gonçalves
Posts: 135
Joined: Wed Jun 08, 2016 4:56 am

Re: segment power analysis

Post by Carlos Gonçalves » Tue Sep 17, 2024 5:24 pm

Great!

And... It worked!!!!

For everyone interested in IAA analysis with OpenSim API after a Moco simulation, here are my top tips:
  • Create a ForceReporter file of your simulation
  • Keep just a "virtual forceplate" for each foot (API crashes if you don't)
  • Remember to disable your contact forces in your model
Thanks a lot for the support, Nick, and everyone in the Moco team and forum. It's not every day that I solve a problem that started around 2022. :lol:

POST REPLY