Skip to main content

calcTrackingOptimizationPathConstraint.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the path constraint for tracking optimization.
%
% (struct, struct, struct) -> (2D matrix)
% Returns path constraint


function path = calcTrackingOptimizationPathConstraint(values, modeledValues, ...
params)
path = [];
for i = 1:length(params.path)
constraintTerm = params.path{i};
if constraintTerm.isEnabled
switch constraintTerm.type
case "root_segment_residual_load"
path = cat(2, path, ...
calcRootSegmentResidualsPathConstraints(...
constraintTerm.load, ...
params.inverseDynamicMomentLabels, ...
modeledValues.inverseDynamicMoments));
case "muscle_model_moment_consistency"
path = cat(2, path, ...
calcMuscleActuatedMomentsPathConstraints(params, ...
modeledValues, constraintTerm.load));
case "torque_model_moment_consistency"
path = cat(2, path, ...
calcTorqueActuatedMomentsPathConstraints(params, ...
modeledValues, values.controlTorques, constraintTerm.load));
otherwise
throw(MException('', ['Constraint term type ' ...
constraintTerm.type ' does not exist for this tool.']))
end
end
end
path = scaleToBounds(path, params.maxPath, params.minPath);
end