Skip to main content

calcTorqueActuatedMomentsPathConstraints.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the difference between the inverse dynamic
% moments and the torque based control for the specified coordinate.
% Applicable only if the model is torque driven.
%
% (struct, struct, 2D matrix, Array of string) -> (Array of number)
%


function pathTerm = calcTorqueActuatedMomentsPathConstraints(params, ...
modeledValues, controlTorques, loadName)

loadName = erase(loadName, '_moment');
loadName = erase(loadName, '_force');
indx1 = find(cellfun(@isequal, params.coordinateNames, ...
repmat({loadName}, 1, length(params.coordinateNames))));
indx2 = find(strcmp(params.controlTorqueNames, loadName));
pathTerm = modeledValues.inverseDynamicMoments(:, indx1) - ...
controlTorques(:, indx2);
end