Making arms parallel to the ground

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
Hojin Song
Posts: 74
Joined: Wed Jul 08, 2020 9:46 am

Making arms parallel to the ground

Post by Hojin Song » Tue Apr 23, 2024 3:00 am

Hello MOCO experts!

I'm trying to simulate a squat while we make arms straight parallel to the ground throughout the movement. I was thinking of using MocoOutputConstraint to constrain a point on a hand's rotations in three axes (while elbows and wrists are fixed to straight), but I remember that in older post of mine, Moco doesn't support SimTK::Rotation type outputs in MocoOutputConstraint. I would like to ask whether we are able to use rotation outputs in Moco's path constraints now?

If not, I'd be grateful if I can hear an alternate option to achieve the same goal. The image below is an illustration of what I would like to achieve. Thank you :D
arm_straight.png
arm_straight.png (110.2 KiB) Viewed 1892 times

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

Re: Making arms parallel to the ground

Post by Nicholas Bianco » Tue Apr 23, 2024 9:52 am

Hi Hojin,

You could use MocoOrientationTrackingGoal to track a constant parallel orientation between the arms and the ground. You can provide reference tracking data via a table of SimTK::Rotation or SimTK::Quaternion values, or a StatesTrajectory representing a model pose with the arms in the orientation you desire.

-Nick

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

Re: Making arms parallel to the ground

Post by Ross Miller » Wed Apr 24, 2024 11:28 am

Hi Hojin,

I've used the Goal Nick mentioned to minimize the deviations of the torso in global frame, it worked well. You could try that Goal with a high weight and see if it makes the deviations of the arms small enough for your purpose.

If you want the deviations to be literally zero, I think you'd have to use kinematic constraints in the .osim model itself, similar to what is done to define patella motions as prescribed functions of the knee angle. To get the arms to be always parallel to the ground, the kinematic constraint would have to make the shoulder angles functions of both the pelvis and lumbar angles (assuming pelvis is your model's "base" segment) and I'm not sure if that's possible, the patella is the only example of kinematic constraints I'm familiar with in OpenSim models and it's only a function of a single coordinate in the model.

I've run many Moco simulations with the kinematic constraints of the patellas in the problem and it works fine. It's been a while since I troubleshot this part of the model, but I use the following solver settings that I think tell Moco to pay attention to this constraint (maybe Nick can confirm; I searched but couldn't find the old thread on this):

Code: Select all

solver.set_enforce_constraint_derivatives(true);
solver.set_enforce_path_constraint_midpoints(true);
There's another setting that can be used:

Code: Select all

solver.set_lagrange_multiplier_weight(weight_goes_here);
but I didn't get good results with it.

Ross

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

Re: Making arms parallel to the ground

Post by Nicholas Bianco » Wed Apr 24, 2024 1:45 pm

Enforcing constraint derivatives is true by default, and you should only need to enforce path constraints at midpoints in special cases (e.g., enforcing a MocoControlBoundConstraint in MocoInverse).

That being said, OpenSim doesn't yet support a kinematic constraint to enforce a particular orientation.

POST REPLY