Contact Geometry Parameter Optimisation

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
Andrea Braschi
Posts: 14
Joined: Thu Mar 11, 2021 2:42 am

Contact Geometry Parameter Optimisation

Post by Andrea Braschi » Tue Sep 03, 2024 2:28 am

Hi all,

I have a questiong regarding Contact Geometry parameter optimisation using the SmoothSphereHalfSpaceForce.

I was wondering if a MocoContactTrackingGoal is required to optimise the contact parameters (ie stiffness and damping) in a MocoStudy ?

At the moment, I am trying to run a contact parameter optimisation only using a MocoMarkerTrackingGoal and a MocoControlGoal, while trying to minimise the pelvis residuals (as shown in the exampleMocoTrack.py file) and providing the ground reaction forces via the ModOpAddExternalLoads method, but I get the following error:

Code: Select all

[error] IO.OpenInputFile(const string&,openmode mode): failed to open external_force.mot.
I must say that the contact parameters that I am optimising for aren't related to the foot-ground interface, but rather to a contact that occurs at the shoulder level.

I get a warning that says to check whether the file exists or not, but the file clearly exists and as soon as I stop adding the contact parameters to the problem, the problem runs with no issues (therefore, finding the file).

I hope I was clear enough for you to understand. Any help will be very much appreciated.

All the best,
Andrea

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

Re: Contact Geometry Parameter Optimisation

Post by Nicholas Bianco » Tue Sep 03, 2024 10:14 am

Hi Andrea,
I was wondering if a MocoContactTrackingGoal is required to optimise the contact parameters (ie stiffness and damping) in a MocoStudy ?
No, you do not need MocoContactTrackingGoal to optimize contact parameters. You can optimize model properties as parameters using MocoParameter.

and providing the ground reaction force ... ads method

If you are trying to optimize foot-ground contact parameters, then you do not want to use ModOpAddExternalLoads, since this will apply experimental loads to the model directly. However, you will need to be able to load this file as an input to MocoContactTrackingGoal. Have you checked that the file is in your working directory?

Best,
Nick

User avatar
Andrea Braschi
Posts: 14
Joined: Thu Mar 11, 2021 2:42 am

Re: Contact Geometry Parameter Optimisation

Post by Andrea Braschi » Thu Sep 19, 2024 4:23 am

Hi Nick,

many thanks for getting back to mem and apologies if it took me a long time to pick this back up.

So, just to give you a better idea of what I am doing:

I am prescribing the ground reaction forces via the ModOpAddExternalLoads method, providing a an .xml file that directs to a .mot file that contains the GRF traces. And yes, I have checked that the file is in the working directory and, in fact, the file is found when I am not adding a parameter to the problem. I'll explain in more details:

I would like to optimise (or, at least try) for the contact parameters of a Sphere to Halfspace contact model that is located at the shoulder level. However, I do not have a reliable experimental force that I can use within the MocoContactTrackingGoal which is why I am not using it. The goals that I am using to optimise the parameters are: MocoMarkerTrackingGoal and MocoControlGoal. Therefore, I am pretty much using the kinematics to optimise while prescribing GRFs at the feet.

The funny thing is that when I follow the parameter registration procedure, therefore creating a MocoParameter and adding it to the problem (ie problem.addParameter), the problem reaches the following point:

Code: Select all

This is Ipopt version 3.12.8, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
Number of nonzeros in equality constraint Jacobian...:  5092993
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:        0
and the I get the following error:

Code: Select all

[error] IO.OpenInputFile(const string&,openmode mode): failed to open external_force.mot.
from which follow warnings as such:

Code: Select all

Error in Function::operator() for 'cost_marker_tracking_goal_integrand'
which, I guess, come from the lack of an external force file.

My doubt arises from the fact that as soon as I comment out all the problem.addParameter lines, all of a sudden, I don't have the same issue and the optimisation starts, with the file that gets found again.

I hope a provided more details this time around and apologies if it's too long of a post.

All the best,
Andrea

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

Re: Contact Geometry Parameter Optimisation

Post by Nicholas Bianco » Thu Sep 19, 2024 8:58 am

Hi Andrea,

It would be helpful if you posted a minimal reproducible example of your issue and the full log output of the errors you are receiving.
I would like to optimise (or, at least try) for the contact parameters of a Sphere to Halfspace contact model that is located at the shoulder level.
I'm not really sure what you're trying to accomplish here. The SmoothSphereHalfSpaceForce is really intended for foot-ground contact. Not sure if it is related to your issues, but just trying to understand what you are trying to accomplish.

-NIck

POST REPLY