import ctypes

ICD1553_VELOCITY_FEET_LSB = 3.81470E-06
GC_K_FEETS_TO_METERS = 0.3048
ICD1553_VELOCITY_METERS_LSB = ICD1553_VELOCITY_FEET_LSB * GC_K_FEETS_TO_METERS

class Velocity(ctypes.Union):
    _fields_ = [
        ("raw", ctypes.c_int32),
        ("x_vel", ctypes.c_int32),
        ("y_vel", ctypes.c_int32),
        ("z_vel", ctypes.c_int32),
                ]

    def get(self):
        return self.raw * ICD1553_VELOCITY_METERS_LSB

    def set(self, value):
        self.raw = int(value / ICD1553_VELOCITY_METERS_LSB)