Skip to main content

mergeGroundContactPersonalizationRoundResults.m


% This function is part of the NMSM Pipeline, see file for full license.
%
%
%
% (struct, Array of double, struct, double) -> (struct)
% Merge the results of an optimization back into the input values.


function inputs = mergeGroundContactPersonalizationRoundResults(inputs, ...
results, params, task)
index = 1;
if (params.tasks{task}.designVariables(1))
inputs.springConstants = 1000 * results(index : index + ...
length(inputs.springConstants) - 1);
index = index + length(inputs.springConstants);
end
if (params.tasks{task}.designVariables(2))
inputs.dampingFactor = results(index);
index = index + 1;
end
if (params.tasks{task}.designVariables(3))
inputs.dynamicFrictionCoefficient = results(index);
index = index + 1;
end
if (params.tasks{task}.designVariables(4))
inputs.viscousFrictionCoefficient = results(index);
index = index + 1;
end
if (params.tasks{task}.designVariables(5))
inputs.restingSpringLength = results(index);
end
if (params.tasks{task}.designVariables(6))
% Other design variables are shared between feet, but kinematic
% B-spline coefficients are specific to a foot.
for foot = 1:length(inputs.surfaces)
bSplineCoefficientLength = length(reshape(inputs.surfaces{foot} ...
.bSplineCoefficients, 1, []));
bSplineCoefficients = results(index : index + ...
bSplineCoefficientLength - 1);
bSplineCoefficients = reshape(bSplineCoefficients, [], 7);
inputs.surfaces{foot}.bSplineCoefficients = bSplineCoefficients;
index = index + bSplineCoefficientLength;
end
end
end