Moco goal for contact parameter optimisation using weights
Posted: Mon Jun 24, 2024 2:49 am
Hi everyone,
I am trying to optimise the contact model, and especially the contact radii of my contact spheres and the stiffness of the SmoothSphereHalfSpaceForce, based on GRF and kinematic data. I use MocoInverse to prescribe my kinematics and a MocoContactTrackingGoal to track my GRF data. I currently use MocoParameters to optimise both the stiffness and the contact radii but there appears to be some local minimum when the contact radii reach the upper bounds. How can I add weights to the parameter optimisation, so that they ideally diverge as little as possible from the initial value?
Here is how I set up the MocoParameters:
I tried MocoOutputGoal (or MocoInitialOutputGoal or MocoFinalOutputGoal) but I am not sure how to 'connect' setOutputPath of MocoOutputBase with either the MocoParameter or the contact geometry directly.
When I try to connect it directly with the contact geometry like this:
I get an error saying that no output called radius exists at that component, i,e.:
However, I can't seem to define a path to (or find a way to conect) the MocoParameter's output. I assume the optimised value from the MocoParameter is found at contactRadii.getPropertyByIndex(3) (i.e., the porperty_element) but how do I set it up correctly with the MocoOutputGoal?
Many thanks for your help!
Cheers,
Oliver
I am trying to optimise the contact model, and especially the contact radii of my contact spheres and the stiffness of the SmoothSphereHalfSpaceForce, based on GRF and kinematic data. I use MocoInverse to prescribe my kinematics and a MocoContactTrackingGoal to track my GRF data. I currently use MocoParameters to optimise both the stiffness and the contact radii but there appears to be some local minimum when the contact radii reach the upper bounds. How can I add weights to the parameter optimisation, so that they ideally diverge as little as possible from the initial value?
Here is how I set up the MocoParameters:
Code: Select all
% ==== Add parameters to optimise to the problem ==== %
% optimise stiffness across all contact forces
stiffnessParam = MocoParameter('contactStiffness',StdVectorString(HalfSpaceForces),'stiffness',MocoBounds(1e-5,1e6));
problem.addParameter(stiffnessParam); % append contact stiffness to problem
% optimise contact geometry radii
contactRadii = MocoParameter('contactRadii',StdVectorString(contactGeometryPathNames),'radius',MocoBounds(0.0025,0.05));
problem.addParameter(contactRadii); % append contact radii to problem
When I try to connect it directly with the contact geometry like this:
Code: Select all
% ==== Add a MocoOutputGoal to the problem ==== %
radiiGoal = MocoOutputGoal('radii');
problem.addGoal(radiiGoal);
radiiGoal.setOutputPath(append(contactGeometryPathNames(1),'|radius'));
radiiGoal.setWeight(radiiWeight);
Which makes sense as it is an attribute/property and not an output, so directly linking it to the contact geometry might not be the way forward.java.lang.RuntimeException: no Output 'radius' found for this Component.
In Object 'Digit_I_R_CS' of type ContactSphere.
Thrown at Component.h:1163 in getOutput().
However, I can't seem to define a path to (or find a way to conect) the MocoParameter's output. I assume the optimised value from the MocoParameter is found at contactRadii.getPropertyByIndex(3) (i.e., the porperty_element) but how do I set it up correctly with the MocoOutputGoal?
Many thanks for your help!
Cheers,
Oliver