<commit_before><commit_msg>adding sensor class for IMU<commit_after>from Adafruit_BNO055 import BNO055
import logging
import sys
import time

# Create and configure the BNO sensor connection.  Make sure only ONE of the
# below 'bno = ...' lines is uncommented:
# Raspberry Pi configuration with serial UART and RST connected to GPIO 18:
bno = BNO055.BNO055(serial_port='/dev/ttyAMA0', rst=18)


# BeagleBone Black configuration with default I2C connection (SCL=P9_19, SDA=P9_20),
# and RST connected to pin P9_12:
# bno = BNO055.BNO055(rst='P9_12')

# if not bno.begin():
#   raise RuntimeError('Failed to initialize BNO055! Check the Sensor DUMBASS')

class IMU(object):
    bno.begin()

    def imu_get_data(self):

        heading, roll, pitch = bno.read_euler()
        gyro_x, gyro_y, gyro_z = bno.read_gyroscope()
        accel_x, accel_y, accel_z = bno.read_accelerometer()
        LinAccel_x, LinAccel_y, LinAccel_z = bno.read_linear_accelerometer()
        temp = bno.read_temp()
        return {'Heading': heading, 'Roll': roll, 'Pitch': pitch, 'Gyro-X': gyro_x, 'Gyro-Y': gyro_y, 'Gyro-Z': gyro_z,
                'Acceleration-X': accel_x, 'Acceleration-Y': accel_y, 'Acceleration-Z': accel_z,
                'Linear Acceleration-X': LinAccel_x, 'Linear Acceleration-Y': LinAccel_y, 'Linear Acceleration-Z': LinAccel_z,
                'Temp' : temp}

    def get_calibration(self):
        cal_array = bno.get_calibration()
        return cal_array

    def reset_calibration(self):
        cal_array_original = self.get_calibration()
        bno.set_calibration(bno.get_calibration())
        return cal_array_original

    def set_calibration(self, data):
        bno.set_calibration(data)
        return
{'fraction_non_alphanumeric': 0.1063953488372093, 'fraction_numerical': 0.022674418604651164, 'mean_word_length': 3.5170603674540684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7575328', 'n_tokens_mistral': 647, 'n_tokens_neox': 595, 'n_words': 147}