def get_accelerometer_cooked(self): """Read in the value from the accelerometer and return as degrees""" rv = read_accelerometer() yaw = rv['values']['yaw'] pitch = rv['values']['pitch'] roll = rv['values']['roll'] scalar = math.sqrt((yaw*yaw)+(pitch*pitch)+(roll*roll)) yaw_cooked = math.degrees(math.acos(yaw/scalar)) if (yaw < 0): yaw_cooked = 0 - yaw_cooked pitch_cooked = math.degrees(math.acos(pitch/scalar)) if (pitch < 0): pitch_cooked = 0 - pitch_cooked roll_cooked = math.degrees(math.acos(roll/scalar)) if (roll < 0): roll_cooked = 0 - roll_cooked return { "values": {"yaw": yaw_cooked, "pitch": pitch_cooked, "roll": roll_cooked} }
def get_accelerometer_cooked(self): """Read in the value from the accelerometer and return as degrees""" rv = read_accelerometer() yaw = rv['values']['yaw'] pitch = rv['values']['pitch'] roll = rv['values']['roll'] scalar = math.sqrt((yaw * yaw) + (pitch * pitch) + (roll * roll)) yaw_cooked = math.degrees(math.acos(yaw / scalar)) if (yaw < 0): yaw_cooked = 0 - yaw_cooked pitch_cooked = math.degrees(math.acos(pitch / scalar)) if (pitch < 0): pitch_cooked = 0 - pitch_cooked roll_cooked = math.degrees(math.acos(roll / scalar)) if (roll < 0): roll_cooked = 0 - roll_cooked return { "values": { "yaw": yaw_cooked, "pitch": pitch_cooked, "roll": roll_cooked } }
def get_accelerometer_raw(self): """Read in the value from the accelerometer and return it as a dictionary""" values = read_accelerometer() return values