#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable() imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() imu.initComplementaryFromAccel = True imu.initKalmanFromAccel = True while True: stop = datetime.now() - start start = datetime.now() deltaT = stop.microseconds / 1000000.0 print " " # print "Loop:", deltaT # print "Accel:", imu.getAccelerometerAngles() print "Gyro:", imu.getComplementaryAngles(deltaT=deltaT) print "Accelerometer (G):", imu.getAccInG() # print "Gyro:", imu.getKalmanAngles(deltaT = deltaT)
#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable(True, False, True, False, False) imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() while True: stop = datetime.now() - start start = datetime.now() deltaT = stop.microseconds/1000000.0 print " " print "Loop:", deltaT print "Accel:", imu.getAccelerometerAngles() print "Gyro:", imu.trackGyroAngles(deltaT = deltaT) sleep(0.02)
from altimu import AltIMU from time import sleep from datetime import datetime imu = AltIMU() imu.enable() imu.calibrateGyroAngles() start = datetime.now() count = 0 while count < 100: stop = datetime.now() - start start = datetime.now() deltaT = stop.microseconds / 1000000.0 print " " print "Loop:", deltaT print "Accel:", imu.getAccelerometerAngles() print "Gyro:", imu.trackGyroAngles(deltaT=deltaT) print "Kalman:", imu.getKalmanAngles(deltaT=deltaT) count += 1 sleep(0.02)
#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable() imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() while True: stop = datetime.now() - start start = datetime.now() deltaT = stop.microseconds/1000000.0 print " " print "Loop:", deltaT print "Accel:", imu.getAccelerometerAngles() print "Gyro:", imu.trackGyroAngles(deltaT = deltaT) sleep(0.02)
#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable() imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() while True: stop = datetime.now() - start start = datetime.now() deltaT = stop.microseconds/1000000.0 print(" ") print("Loop:", deltaT) print("Accel:", imu.getAccelerometerAngles()) print("Gyro:", imu.trackGyroAngles(deltaT = deltaT)) sleep(0.1)
from datetime import datetime import time import csv from altimu import AltIMU import os import math print "ReadAccGyro.py is starting" imu = AltIMU() imu.enable(True, True, True, True, True) quit = False FREQ = float(open("/home/pi/Desktop/PSLT-Subscale/FREQ.txt", 'r').read()) start = time.time() lastAccList = [0.0, 0.0, 0.0] lastGyroList = [0.0, 0.0, 0.0] lastMagList = [0.0, 0.0, 0.0] errs = 0 while (not quit): try: errs = 0 with open("/home/pi/Desktop/PSLT-Subscale/Data/AccGyroData.csv", "ab") as dataFile: data = "\n" accList = imu.getAccelerometerRaw() if (not (accList[0] == None)): data += str(accList[0] / 4098.0) + "," lastAccList[0] = accList[0]
#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable() imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() while True: stop = datetime.now() - start deltaT = stop.microseconds / 1000000.0 print " " print "Interval(s):", stop.total_seconds() #print "Interval(s):", deltaT print "Accel Angles:", imu.getAccelerometerAngles() #print "Gyro Angles:", imu.trackGyroAngles(deltaT = deltaT) #print "Rotation Rate: ", imu.getGyroRotationRates() # ok #print "Complimentary:", imu.getComplementaryAngles(deltaT = deltaT) # fixed #print "Karman:", imu.getKalmanAngles(deltaT = deltaT) # kinda fixed...
def enableSensors(): # accel accel = AltIMU() accel.enable_accelerometer() # magnet magnet = AltIMU() magnet.enable_magnetometer() # gyro gyro = AltIMU() gyro.enable_gyroscope() # altitude alti = AltIMU() alti.enable_barometer() return accel, magnet, gyro, alti
#!/usr/bin/python from datetime import datetime from time import sleep from altimu import AltIMU imu = AltIMU() imu.enable() #data = [] imu.calibrateGyroAngles() #for x in range(1000): # startTime = datetime.now() # angles = imu.trackGyroAngles(deltaT = 0.0002) #print angles start = datetime.now() while (1): stop = datetime.now() - start #start = datetime.now() deltaT = stop.microseconds / 1000000.0 print " " print "Loop:", deltaT print "Accel:", imu.getAccelerometerAngles() print "Gyro:", imu.trackGyroAngles(deltaT=deltaT) print "AngleCouple", imu.getComplementaryAngles(deltaT=deltaT) #data.append(imu.getComplementaryAngles(deltaT = deltaT)) print "KalmanAngles", imu.getKalmanAngles(deltaT=deltaT) sleep(0.1)