MocoFrameDistanceConstraint

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
mohadeseh shafie
Posts: 16
Joined: Fri Feb 19, 2021 4:39 pm

MocoFrameDistanceConstraint

Post by mohadeseh shafie » Wed Nov 15, 2023 3:52 am

Hi all,
I want to adjust the distance from the heel of one foot to the toe of the other while walking in the MOCO. My goal is to generate a trajectory by adjusting the step length. Can I use the MocoFrameDistanceConstraint() function to set the distance in the x direction? Because I considered it as follows and the MATLAB code gives an error.
Thank you.

distanceConstraint = MocoFrameDistanceConstraint();
distanceConstraint.setName('distance');
distanceConstraint.addFramePair(MocoFrameDistanceConstraintPair('/bodyset/toes_r', '/bodyset/heel_l', .15, .3));
distanceConstraint.addFramePair(MocoFrameDistanceConstraintPair('/bodyset/toes_l', '/bodyset/heel_r', .15, .3));
projectionVector = [1, 0, 0];
distanceConstraint.setProjectionVector(projectionVector);
problem.addPathConstraint(distanceConstraint);


Error:
Check for incorrect argument data type or missing argument in call to function 'setProjectionVector'.
distanceConstraint.setProjectionVector(projectionVector);

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

Re: MocoFrameDistanceConstraint

Post by Ross Miller » Wed Nov 15, 2023 6:02 am

Hi Mohadeseh,

I think the projection vector has to be specified using Vec3, and you probably also need to specify the type of projection, e.g.:

Code: Select all

distanceConstraint.setProjecVector(Vec3(1,0,0));
distanceConstraint.setProjection(string); % this string can be 'none', 'plane', or 'vector'
If your goal is to simulate different step lengths, I think MocoFrameDistanceConstraint may not be the best way of doing that. This constraint will make it so that the origins of the left and right foot frames can never go closer than 0.15 meters and never further than 0.30 meters, which is not realistic for walking. To simulate different prescribed step lengths I would use MocoAverageSpeedGoal to set the speed then manipulate the step length by specifying different step durations (e.g. track.set_final_time(value_of_tfinal) if using MocoTrack).

Ross

POST REPLY