def stabilizeSteeringAngle(curr_steering_angle, new_steering_angle, num_of_lane_lines, max_angle_deviation_two_lines=2, max_angle_deviation_one_lane=1):
    '\n    Using last steering angle to stabilize the steering angle\n    This can be improved to use last N angles, etc\n    if new angle is too different from current angle, only turn by max_angle_deviation degrees\n    '
    if (num_of_lane_lines == 1):
        max_angle_deviation = max_angle_deviation_one_lane
    else:
        max_angle_deviation = max_angle_deviation_two_lines
    angle_deviation = (new_steering_angle - curr_steering_angle)
    if (abs(angle_deviation) > max_angle_deviation):
        stabilized_steering_angle = int((curr_steering_angle + ((max_angle_deviation * angle_deviation) / abs(angle_deviation))))
    else:
        stabilized_steering_angle = new_steering_angle
    return stabilized_steering_angle
Using last steering angle to stabilize the steering angle
This can be improved to use last N angles, etc
if new angle is too different from current angle, only turn by max_angle_deviation degrees
def stabilizeSteeringAngle(curr_steering_angle, new_steering_angle, num_of_lane_lines, max_angle_deviation_two_lines=2, max_angle_deviation_one_lane=1):
    '\n    Using last steering angle to stabilize the steering angle\n    This can be improved to use last N angles, etc\n    if new angle is too different from current angle, only turn by max_angle_deviation degrees\n    '
    if (num_of_lane_lines == 1):
        max_angle_deviation = max_angle_deviation_one_lane
    else:
        max_angle_deviation = max_angle_deviation_two_lines
    angle_deviation = (new_steering_angle - curr_steering_angle)
    if (abs(angle_deviation) > max_angle_deviation):
        stabilized_steering_angle = int((curr_steering_angle + ((max_angle_deviation * angle_deviation) / abs(angle_deviation))))
    else:
        stabilized_steering_angle = new_steering_angle
    return stabilized_steering_angle