import math


def wrap_to_pi(angle):
    """
    Wrap the given angle to pi: -pi <= angle <= pi.

    :param angle: float, Angle to wrap in rads
    :return: float, Wrapped angle
    """
    while angle > math.pi:
        angle -= 2 * math.pi
    while angle < -math.pi:
        angle += 2 * math.pi
    return angle