예제 #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
예제 #2
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
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
예제 #4
0
# 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" 

# Specify Options: "2GAUSS", "4GAUSS", "8GAUSS", "12GAUSS"
imu.mag_range("2GAUSS")     # leave blank for default of "2GAUSS"

# Specify Options: "245DPS", "500DPS", "2000DPS" 
imu.gyro_range("245DPS")    # leave blank for default of "245DPS"

# Loop and read accel, mag, and gyro

class Offset_Gyro:
    def __init__(self):
         imu.read_gyro()
         self.gx = imu.gx
         self.gy = imu.gy
         self.gz = imu.gz
예제 #5
0
# 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"

# Specify Options: "2GAUSS", "4GAUSS", "8GAUSS", "12GAUSS"
imu.mag_range("2GAUSS")  # leave blank for default of "2GAUSS"

# Specify Options: "245DPS", "500DPS", "2000DPS"
imu.gyro_range("245DPS")  # leave blank for default of "245DPS"


def recordData(x):
    tstamp = strftime("_%Y-%m-%d_%H%M%S", gmtime())
    file = DIRECTORY + '/' + str(x) + tstamp + ".txt"
    fd = open(file, 'w')

    # Loop and read accel, mag, and gyro
    for i in range(NUMDATAPOINTS):
예제 #6
0
    import gobject as GObject

from SF_9DOF import IMU
import time
import json
import numpy as np

imu = IMU()

imu.initialize()
imu.enable_accel()
imu.enable_mag()
imu.enable_gyro()
imu.enable_temp()

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


class Offset_Gyro:
    def __init__(self):
        imu.read_gyro()
        self.gx = imu.gx
        self.gy = imu.gy
        self.gz = imu.gz


gyro_offset = Offset_Gyro()

예제 #7
0
from SF_9DOF import IMU
import time
import json
import numpy as np
import math

imu = IMU()

imu.initialize()
imu.enable_accel()
imu.enable_mag()
imu.enable_gyro()
imu.enable_temp()

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

class Accel_Readings:
     def __init__(self):
          imu.read_accel()
          self.ax = imu.ax
          self.ay = imu.ay
          self.az = imu.az
          self.R = math.sqrt(math.pow(self.ax, 2) + math.pow(self.ay, 2) + math.pow(self.az, 2))

class Accel_Readings_Norm:
     def __init__(self, accel):
          self.axn = accel.ax/accel.R
          self.ayn = accel.ay/accel.R
예제 #8
0
import time
import requests
import sys
import select
from SF_9DOF import IMU
#create IMU object
imu = IMU()

#Initialize IMU
imu.initialize()

imu.enable_accel()

imu.read_accel()

imu.accel_range("16G")
accel_x = []
accel_y = []
accel_z = []

#t_end = time.time() + 1
#while(imu.ax.size < 700):
accel_x.append(imu.ax)
accel_y.append(imu.ay)
accel_z.append(imu.az)


def start_checker():
    if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
        c = sys.stdin.read(1)
        return c