% This function is part of the NMSM Pipeline, see file for full license.
%
% Compute the heuristic value of the inner optimization for kinematic
% calibration
%
% (Model, MarkersReference, struct) -> (number)
% Computes the heuristic value of the output of the inner optimization
function error = computeInnerOptimizationHeuristic(model, ...
markersReference, params)
import org.opensim.modeling.*
trialIKSolver = InverseKinematicsSolver(model, ...
markersReference, SimTKArrayCoordinateReference());
applyParametersToIKSolver(trialIKSolver, params);
error = computeInverseKinematicsSquaredError(model, trialIKSolver, ...
markersReference, params);
trialIKSolver = libpointer;
desiredError = valueOrAlternate(params, "desiredError", 0.01);
error = error / desiredError;
end