Skip to main content

calcTrackingCoordinateIntegrand.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the difference between the experimental and
% predicted joint angles for the specified coordinate.
%
% (struct, Array of number, 2D matrix, Array of string) -> (Array of number)
%


function cost = calcTrackingCoordinateIntegrand(auxdata, time, ...
statePositions, coordinateName)

indx = find(strcmp(convertCharsToStrings(auxdata.coordinateNames), ...
coordinateName));
if auxdata.splineJointAngles.dim > 1
experimentalJointAngles = fnval(auxdata.splineJointAngles, time)';
else
experimentalJointAngles = fnval(auxdata.splineJointAngles, time);
end

cost = calcTrackingCostArrayTerm(experimentalJointAngles, ...
statePositions, indx);
end