Skip to main content

setOsimStateBySingleFrame.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function assigns the state positions and velocities to the OpenSim
% model, for a single time frame.
%
% (struct, Model, State, Cell, number) -> (Model, State)
%


function [osimModel, osimState] = setOsimStateBySingleFrame(values, ...
osimModel, osimState, coordinateNames, indx)

osimState.setTime(values.time(indx, 1));
for k=1:size(coordinateNames,2)
if ~osimModel.getCoordinateSet.get(coordinateNames{k}).get_locked
osimModel.getCoordinateSet.get(coordinateNames{k}). ...
setValue(osimState, values.statePositions(indx, k));
osimModel.getCoordinateSet.get(coordinateNames{k}). ...
setSpeedValue(osimState, values.stateVelocities(indx, k));
end
end
osimModel.realizeVelocity(osimState);
end