Different weighting factors for each axis?

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
Grace M
Posts: 27
Joined: Thu Jul 28, 2016 11:11 am

Different weighting factors for each axis?

Post by Grace M » Wed Jun 29, 2022 10:03 pm

Hi there,

I was wondering if it would be possible to have different weighting factors for tracking goals in the x/y/z axes? In my case when tracking IMU signals I am having more success with a 2D model tracking signals with the OpenSim z axis components set to 0, so am considering whether reducing the weight on tracking these components could assist with obtaining a converged solution in 3D.
Is this something that could be added as a custom goal or potentially developed for a future release? Or would it be difficult to implement with the signals being wrapped in a TimeSeriesTableVec3? I imagine the same concept could also be applied to GRF/joint reaction/marker tracking if it was feasible.

Thanks!
Grace

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

Re: Different weighting factors for each axis?

Post by Ross Miller » Thu Jun 30, 2022 9:04 am

Hi Grace,

You can do this for GRF with MocoContactTrackingGoal, I do it like this:

Code: Select all

contactTracking1 = MocoContactTrackingGoal('name for this goal',weightForThisGoal)
...
contactTracking1.setProjection('vector');
contactTracking1.setProjectionVector(Vec3(0, 1, 0));
This tells this particular contact tracking goal to track just the vertical GRF component with weight weightForThisGoal. You can create other separate contact tracking goals with different weights for other components.

For motion-tracking, with MocoTrack and MocoStateTrackingGoal I think you can only track model states, e.g. generalized coordinates and speeds. I haven't used MocoOrientationFrameTrackingGoal much but it might be able to do what you described.

https://simtk.org/api_docs/opensim/api_ ... gGoal.html

Hope this helps,
Ross

User avatar
Grace M
Posts: 27
Joined: Thu Jul 28, 2016 11:11 am

Re: Different weighting factors for each axis?

Post by Grace M » Sun Jul 03, 2022 6:07 pm

Thanks Ross, yes I don't think that is an option for IMU signal related goals but would be very useful for GRF tracking!

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

Re: Different weighting factors for each axis?

Post by Nicholas Bianco » Sun Jul 03, 2022 7:05 pm

Hi Grace, Ross,

No, there isn't an "projection" option for the IMU tracking goals. I realize now that we should have made this an option for all tracking goals with 3D data by default. But it's an easy enough addition. It won't make it into 4.4 since that's already in beta, but if you need a custom build for your project we can do that too.

-Nick

User avatar
Grace M
Posts: 27
Joined: Thu Jul 28, 2016 11:11 am

Re: Different weighting factors for each axis?

Post by Grace M » Tue Jul 05, 2022 7:41 pm

That sounds great thanks Nick, I don't think this should be crucial for my project at this point but will let you know if that changes, or if you do implement this in a future build/update please let me know!

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

Re: Different weighting factors for each axis?

Post by Nicholas Bianco » Thu Jul 07, 2022 10:55 am

Sounds good! I'll create a GitHub issue for now and let you know when we get around to updating these goals.

-Nick

POST REPLY