Periodicity constraint for GRFs and ground contact moments

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
POST REPLY
User avatar
Kayla Pariser
Posts: 17
Joined: Mon Jul 30, 2018 10:35 am

Periodicity constraint for GRFs and ground contact moments

Post by Kayla Pariser » Thu Feb 29, 2024 1:55 pm

Hi,
One more quick question today! Thank you for your help!

I ran a 3D muscle-driven walking tracking simulation for one full gait cycle where I track muscle activations (note: I ignore activation dynamics for all muscles), experimental ground reaction forces, and experimental states and set a periodicity constraint for all states and controls. Overall, the simulation did a pretty good job tracking muscle activations and states (except for the arms, subtalar, and toes - but these states had small weights). However, the ground reaction forces and moments in some of the directions were highly non-periodic which does not seem realistic. Is there a way to set a periodicity constraint for ground reaction forces and moments with Moco?

Thank you,
Kayla

User avatar
Ross Miller
Posts: 373
Joined: Tue Sep 22, 2009 2:02 pm

Re: Periodicity constraint for GRFs and ground contact moments

Post by Ross Miller » Thu Feb 29, 2024 2:03 pm

Hi Kayla,

If the model's GRF are from the usual foot-ground contact elements, the states being periodic should also result in periodic GRF.

Did you set all the generalized speeds (e.g. joint angular velocities) to be periodic too?

Below is the code I use to get states and controls that are periodic over a stride, which also results in periodic GRF.

Code: Select all

% All states are periodic except pelvis anterior-posterior translation
for i = 1:model.getNumStateVariables()
    currentStateName = string(model.getStateVariableNames().getitem(i-1));
    if (~contains(currentStateName,'pelvis_tx/value'))
       periodicityGoal.addStatePair(MocoPeriodicityGoalPair(currentStateName));
    end
end

% All controls are periodic
for i = 1:model.getNumControls()
    currentControlName = string(problem.createRep().createControlInfoNames().get(i-1));
    periodicityGoal.addControlPair(MocoPeriodicityGoalPair(currentControlName));
end
Ross

User avatar
Kayla Pariser
Posts: 17
Joined: Mon Jul 30, 2018 10:35 am

Re: Periodicity constraint for GRFs and ground contact moments

Post by Kayla Pariser » Thu Feb 29, 2024 2:50 pm

Hi Ross,
Thank you! I actually used that code to set up my periodicity constraints since I had found it in a previous forum post. Thank you for being so willing to share your code to help all of us in the community out!

Looking back at my data, I found an error with how I translated the output GR moment to be about a new point to compare about the equivalent point that our reference GR moments were calculated about. Looking back at the direct Moco output it was periodic. Guess I was too quick to post on this one.

Thank you for the clarification! It does make sense that periodicity in states and controls should result in periodic GRFs and GR moments.

User avatar
Ross Miller
Posts: 373
Joined: Tue Sep 22, 2009 2:02 pm

Re: Periodicity constraint for GRFs and ground contact moments

Post by Ross Miller » Fri Mar 01, 2024 3:22 am

Glad the codes are helpful!

I don't normally track the GR moments, just the forces. My rationale is if the tracking of the GRF and of the kinematics are both good, and if the model itself is good, then the CoP should look good too (a gauge of validity). But if you want to make sure the model's CoP is good then tracking the moments directly should do that.

Ross

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

Re: Periodicity constraint for GRFs and ground contact moments

Post by Nicholas Bianco » Fri Mar 08, 2024 11:03 am

Hi Kayla,

The new Moco features in the OpenSim 4.5 release enable constraining the GRFs to be periodic. There's new Outputs for SmoothSphereHalfSpaceForce that you can use with MocoOutputPeriodicityGoal.

That being said, I would still recommend Ross suggestion to just constrain the states to be periodic, since the contact forces are directly a function of the model's kinematic state.

Best,
Nick

POST REPLY