Esempio n. 1
0
def initialize():
    """Creates and initializes the IMU object
    Returns an IMU object
    """

    # Create IMU object
    imu = IMU()  # To select a specific I2C port, use IMU(n). Default is 1.
    imu.initialize()

    # Enable accelerometer, magnetometer, gyroscope
    imu.enable_accel()
    imu.enable_mag()
    imu.enable_gyro()

    # Change IMU buffer mode to Bypass
    # TODO: Try other modes as well
    imu.accel_mode(0b001)
    imu.gyro_mode(0b001)

    # Specify ranges for accelerometer, magnetometer and gyroscope
    # Accelerometer Options: "2G", "4G", "6G", "8G", "16G"
    # Magnetometer Options: "2GAUSS", "4GAUSS", "8GAUSS", "12GAUSS"
    # Gyroscope Options: "245DPS", "500DPS", "2000DPS"

    imu.accel_range("16G")
    imu.mag_range("2GAUSS")
    imu.gyro_range("2000DPS")

    return imu
Esempio n. 2
0
def readGyroAngles():
    # Read the gyroscope    
    imu=IMU()    # Default IC2 port 1
    imu.gyro_range("245DPS")    
    imu.read_gyro()
    angles = qM.getEuler()
    return Angles
Esempio n. 3
0
      def imu(self):

        imu = IMU()  # To select a specific I2C port, use IMU(n). Default is 1.

        imu.initialize()

        # Enable accelerometer, magnetometer, gyroscope
        imu.enable_accel()
        imu.enable_mag()
        imu.enable_gyro()
        print imu.read_accel()
        print imu.ax, imu.ay, imu.az
        return imu
def sensor_reader ():
    jaylen_data = IMU()
    jaylen_data.initialize()

    #enable sensors here
    jaylen_data.enable_accel()
    jaylen_data.enable_gyro()
    
    #declaring the range of the accelerometer
    jaylen_data.accel_range("8G")

    jaylen_data.read_accel()
    jaylen_data.read_gyro()

    ax = jaylen_data.ax
    ay = jaylen_data.ay
    az = jaylen_data.az

    gx = jaylen_data.gx
    gy = jaylen_data.gy
    gz = jaylen_data.gz

    return ax, ay, az
Esempio n. 5
0
WAITSECS = 0.02
NUMDATAPOINTS = 100
DIRECTORY = "gesture_data"

# Create Directory for file if does not exist
if not os.path.exists(DIRECTORY):
    os.makedirs(DIRECTORY)

# Print Program Header
print("\
=======================================\n\
STARTING GESTURE RECORDING TOOL\n\
=======================================")

# Create IMU object
imu = IMU()  # To select a specific I2C port, use IMU(n). Default is 1.

# Initialize IMU
imu.initialize()

# Enable accel, mag, gyro, and temperature
imu.enable_accel()
imu.enable_mag()
imu.enable_gyro()
imu.enable_temp()

# Set range on accel, mag, and gyro

# Specify Options: "2G", "4G", "6G", "8G", "16G"
imu.accel_range("2G")  # leave blank for default of "2G"
Esempio n. 6
0
def initialize():
    imu = IMU()
    imu.initialize()
    imu.enable_gyro()
    imu.gyro_range("2000DPS")
    return imu
Esempio n. 7
0
from SF_9DOF import IMU 
import requests
import json 
#create IMU object 
imu = IMU()

#Initialize IMU
imu.initialize()

imu.enable_accel()

imu.read_accel()
accel_data = imu.ax
print str(accel_data)
print "accel data"
payload  = {'firstName':'Kehlin',
                'lastName':'Sizzaaane',
                'accelData':str(accel_data)}

r=requests.post('https://contact-list-kehlin.herokuapp.com/contacts',json=payload)