def METHOD_NAME(mocapState: nimble.MarkerMocapOptimizationState):
    sum = torch.zeros(1)
    for t in range(len(mocapState.posesAtTimesteps)):
        ground_error = nimble.get_lowest_point(
            osim.skeleton, mocapState.posesAtTimesteps[t],
            mocapState.bodyScales)
        # just make sure we never penetrate the ground
        ground_error = ground_error.clamp(max=0.0)
        sum += torch.square(ground_error)
    return sum