import math


def get_bearing(compass_device):
    """Return the vehicle's heading in radians.
    When thw world's +ve x is on the left and +ve y is on top, angle is 0.
    Angle increases clockwise."""
    if compass_device is not None:
        compass_data = compass_device.getValues()
        radians = math.atan2(compass_data[2], -compass_data[0])
        while radians > math.pi:
            radians -= 2*math.pi
        while radians < -math.pi:
            radians += 2*math.pi
    else:
        radians = 0.0
    return radians