Exemplo n.º 1
0
def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
    """Decode position from a pair of even and odd position message
    (works with both airborne and surface position messages)

    Args:
        msg0 (string): even message (28 bytes hexadecimal string)
        msg1 (string): odd message (28 bytes hexadecimal string)
        t0 (int): timestamps for the even message
        t1 (int): timestamps for the odd message

    Returns:
        (float, float): (latitude, longitude) of the aircraft
    """
    tc0 = typecode(msg0)
    tc1 = typecode(msg1)

    if 5 <= tc0 <= 8 and 5 <= tc1 <= 8:
        if (not lat_ref) or (not lon_ref):
            raise RuntimeError("Surface position encountered, a reference \
                               position lat/lon required. Location of \
                               receiver can be used.")
        else:
            return surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref)

    elif 9 <= tc0 <= 18 and 9 <= tc1 <= 18:
        # Airborne position with barometric height
        return airborne_position(msg0, msg1, t0, t1)

    elif 20 <= tc0 <= 22 and 20 <= tc1 <= 22:
        # Airborne position with GNSS height
        return airborne_position(msg0, msg1, t0, t1)

    else:
        raise RuntimeError("incorrect or inconsistant message types")
Exemplo n.º 2
0
def position(msg0, msg1, t0, t1, lat_ref=None, lon_ref=None):
    """Decode surface or airborne position from a pair of even and odd
    position messages.

    Note, that to decode surface position using the position message pair,
    the reference position has to be provided.

    Args:
        msg0 (string): even message (28 hexdigits)
        msg1 (string): odd message (28 hexdigits)
        t0 (int): timestamps for the even message
        t1 (int): timestamps for the odd message
        lat_ref (float): latitude of reference position
        lon_ref (float): longitude of reference position

    Returns:
        (float, float): (latitude, longitude) of the aircraft

    """
    tc0 = typecode(msg0)
    tc1 = typecode(msg1)

    if 5 <= tc0 <= 8 and 5 <= tc1 <= 8:
        if lat_ref is None or lon_ref is None:
            raise RuntimeError(
                "Surface position encountered, a reference position"
                " lat/lon required. Location of receiver can be used."
            )
        else:
            return surface_position(msg0, msg1, t0, t1, lat_ref, lon_ref)

    elif 9 <= tc0 <= 18 and 9 <= tc1 <= 18:
        # Airborne position with barometric height
        return airborne_position(msg0, msg1, t0, t1)

    elif 20 <= tc0 <= 22 and 20 <= tc1 <= 22:
        # Airborne position with GNSS height
        return airborne_position(msg0, msg1, t0, t1)

    else:
        raise RuntimeError("Incorrect or inconsistent message types")