import ctypes
import math

ICD1553_ATTITUDE_RATE_SC_LSB = 1.22070E-04
GC_K_PI = math.pi
ICD1553_ATTITUDE_RATE_RAD_LSB = ICD1553_ATTITUDE_RATE_SC_LSB * GC_K_PI

class AttitudeRate(ctypes.Union):
    _fields_ = [
        ("raw", ctypes.c_int16),
        ("roll_rate", ctypes.c_int16),
        ("pitch_rate", ctypes.c_int16),
        ("yaw_rate", ctypes.c_int16),
        ]

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

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