Adjust gain as function of position error and position