import math


def to_pi_mpi_range(angle):
    """
    Puts an angle in the -pi, pi range
    """
    if angle > math.pi:
        return angle - math.pi
    elif angle < - math.pi:
        return math.pi + angle
    else:
        return angle