% This function is part of the NMSM Pipeline, see file for full license.
%
% This function returns an isolated foot model with spring markers and its
% associated kinematics expressed in its seven coordinates (toe angle,
% three hindfoot rotations, three hindfoot translations).
%
% (string, string, string, string, string, string, struct, double, double,
% logical) -> (Model, Array of double, Array of double)
% Create foot model and kinematics in seven coordinates.
function [footModel, footPosition, footVelocity] = prepareModel( ...
modelName, motionFileName, hindfootBodyName, toesBodyName, ...
toesJointName, toesCoordinateName, markerNames, gridWidth, ...
gridHeight, isLeftFoot)
import org.opensim.modeling.Storage
model = Model(modelName);
time = findTimeColumn(Storage(motionFileName));
coordinatesOfInterest = findGCPFreeCoordinates(model, toesBodyName);
footPosition = makeFootKinematics(model, motionFileName, ...
coordinatesOfInterest, hindfootBodyName, toesCoordinateName);
footVelocity = calcDerivative(time, footPosition);
footModel = makeFootModel(model, toesJointName);
footModel = addSpringsToModel(footModel, markerNames, gridWidth, ...
gridHeight, hindfootBodyName, toesBodyName, isLeftFoot);
end