How to constrain the position of a hand during predicting?

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

How to constrain the position of a hand during predicting?

Post by Simon Jeng » Sat Feb 20, 2021 7:10 am

Hi,

I'm predicting a motion that a standing skeletal model squats and reaches a box on the ground. I need to make sure that the hands are in the same position as the box at the final time. Which constraint in Moco should I apply? It would be appreciated if anyone can give me some advice.

Best wishes,
Simon
Last edited by Simon Jeng on Tue Jun 01, 2021 9:03 am, edited 1 time in total.

User avatar
Aaron Fox
Posts: 289
Joined: Sun Aug 06, 2017 10:54 pm

Re: How to constrain the position of a hand during predicting?

Post by Aaron Fox » Sun Feb 21, 2021 5:53 pm

Hi Simon,

I ran some reaching simulations and used the marker end position goal to guide hand placement. I learnt a couple of things from this too. Originally I thought using a single marker on the tip of the middle finger would work fine, however given the three dimensional nature of the problem, the model could achieve this in a variety of ways (i.e. with the hand supinated vs. pronated, wrist flexed vs. extended etc.). In the end I decided to set up a series of markers (e.g. one on the finger, one on the top of the wrist, one each on the styloid processes) and program them to end up in relevant positions so that the hand ended up in the appropriate pronated position over the reach target. I figured you could do something similar by mapping points on the hand to appropriate positions on the box.

If taking this approach you'll need to figure out a good balance of weights for your goals. For example, if you heavily weight the hand position goal over a kinematic or energetic goal of the squat - the model may sacrifice some of the performance for that goal vs. where the hand needs to be (which I suppose could in fact be realistic for squatting like this).

Aaron

User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

Re: How to constrain the position of a hand during predicting?

Post by Simon Jeng » Mon Feb 22, 2021 12:19 am

Hi Aaron,

Thanks for your reply, that is very helpful. I have read your paper and found that you had used MocoMarkerFinalGoal to achieve this.
" A. S. Fox, J. Bonacci, S. D. Gill, and R. S. Page, "Simulating the effect of glenohumeral capsulorrhaphy on kinematics and muscle function," Journal of Orthopaedic Research, 2020, doi: 10.1002/jor.24908."

Your paper is a good reference for my research.

Thanks~

Simon

User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

Re: How to constrain the position of a hand during predicting?

Post by Simon Jeng » Tue Jun 01, 2021 3:02 am

Hi all,

Thanks to Aaron's advice but I still have a question. My model is a multi-objective function model, which already has two goals. I'm not quite clear how to choose a set of reasonable weighting coefficients if I add this goal.

In addition, is there any new way to constrain the hand position without introducing a new goal?

Looking forward to some suggestions :D

Simon

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

Re: How to constrain the position of a hand during predicting?

Post by Nicholas Bianco » Tue Jun 01, 2021 9:25 am

Hi Simon,

You could implement a custom kinematic constraint or MocoGoal to constrain the final position of the hand. However, this would almost certain be much more time consuming than using MocoMarkerFinalGoal. Since you wish to use this cost term more like a constraint, you could choose a large weight (relative to the other cost weights) so that the final hand position is always met.

-Nick

User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

Re: How to constrain the position of a hand during predicting?

Post by Simon Jeng » Thu Jun 03, 2021 8:12 am

Hi Nick,

I have tried to set some large weights to MocoMarkerFinalGoal (100,200,...,1000 vs. other cost weights only 1), but the resulting objective function value of each goal changed irregularly. I could not figure out which weight is a better choice. Any suggestion about this?

In addition, is it possible to set it as a path constraint (MocoPathConstraint)? If it is, how to do it?

Simon

User avatar
Aaron Fox
Posts: 289
Joined: Sun Aug 06, 2017 10:54 pm

Re: How to constrain the position of a hand during predicting?

Post by Aaron Fox » Fri Jun 04, 2021 12:10 am

Hi Simon,

In the paper referred to in earlier posts I had multiple goals for different markers around the hand/wrist. I did this as I wanted the hand/wrist in a specific position (e.g. supinated), so I used a series of markers that could only all achieve their specific goals by being in that position. I didn't weight these that high - I believe I had these at a weight of 5, and then the control goal might have been a 1 (you could check the SimTK page associated with that study for the code).

It will obviously differ with various models but I didn't seem to need to experiment too much with those weightings to get the desired position.

Aaron

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

Re: How to constrain the position of a hand during predicting?

Post by Nicholas Bianco » Sun Jun 06, 2021 11:13 am

Hi Simon,

Like Aaron suggests, you should use a weight only as large as needed to meet the final hand condition. I'm not sure what you mean by the objective changing irregularly, but the final objective value is somewhat irrelevant as long as the final position is met.

MocoPathConstraint applies a constraint across the entire time trajectory, so this won't work for your application.

-Nick

User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

Re: How to constrain the position of a hand during predicting?

Post by Simon Jeng » Mon Jun 07, 2021 8:14 am

Hi Aaron & Nick,

Thanks for reply. I understand your meanings, I also think so previously. I fixed the other goal(control goal) weight as 1 and set different weights to MarkerFinalGoal. I found that the different weights may change the joint kinematics(the first figure), although the hand achieve the desired position within a satisfactory deviation. In this figure, most of the joint angle trajectories seem coincide, but there is an exception(the green line, the weight is 600). How should we explain this exception?

I also check the objective value (the second figure), the control goal value in the weight 600 deviates a lot from that in other weights. Again, I ensure in this case the hand is quite close to the desired position.

This exception really confuse me a lot. So Aaron, does something similar happen in your model? Why did you set the weight as 5 rather than 10,15 or 20? Would the other weights of MarkerFinalGoal change the shoulder kinematics in your study?

Best wishes,
Simon
Attachments
Knee angle.png
Knee angle.png (23.86 KiB) Viewed 1253 times
objValue.png
objValue.png (65.68 KiB) Viewed 1253 times
Last edited by Simon Jeng on Mon Jun 07, 2021 6:23 pm, edited 2 times in total.

User avatar
Simon Jeng
Posts: 87
Joined: Fri Sep 07, 2018 8:26 pm

Re: How to constrain the position of a hand during predicting?

Post by Simon Jeng » Mon Jun 07, 2021 9:07 am

In my study of the reaching movement, I want to test whether two goals(J1,J2) would predict a more realistic movement than only J2. My initial idea is just fixing the weight of J2 and including J1 to see what happened. But you know, we have to involve in another goal(MocoMarkerFinalGoal) to ensure the hand can reach the desired position. We must fix the weight of it prior to including J1.

I drew a conclusion that two goals perform better than only J2. Then my tutor asked me, "why did you set the weight of MocoMarkerFinalGoal as 200 instead of 300? Would your conclusion remain the same under other weights? I'm not sure you can test all the possibilities".

I do not know how to reply to him scientifically. :cry:

POST REPLY