def __init__(self): self.g = [0, 0, 1] try: self.ch = Spatial() except RuntimeError as e: print "FailAccel" self.stopped = True self.dynAccel = [0, 0, 0] self.previousDynAccel = [0, 0, 0] self.velocity = [0, 0, 0] self.previousVelocity = [0, 0, 0] self.distance = [0, 0, 0] self.prevTime = time.time() self.initTime = time.time() self.q = [0, 0, 0, 0] self.gyroOffset = [0, 0, 0] self.F = open( "/home/pi/MLRobot/Data2/AccelRawDyn" + time.strftime("%e:%H:%M:%S", time.localtime(time.time())), "w") line = "##########Next Run######### Trial " + str( trialNumber) + "\nTime,Ax,Ay,Az,Gx,Gy,Gz, DynX, DynY, DynZ\n" self.F.write(line) self.ch.setOnSpatialDataHandler(self.AccelerationChangeHandler) self.ch.openWaitForAttachment(5000) self.ch.setDataInterval(int(samplingTime)) self.ch.zeroGyro()
def __init__(self): self.ch = Spatial() super(SpatialDevice, self).__init__(self.ch) self.last_angles = [0.0, 0.0, 0.0] self.compass_bearing_filter = [] self.bearing_filter_size = 2 self.compass_bearing = 0
def __init__(self): # read info from vehicle spatial0 = Spatial() spatial0.setOnSpatialDataHandler(self.onSpatialData) spatial0.openWaitForAttachment(5000) # arm vehicle to see position print('Gyro Armed') # - Read the actual attitude: Roll, Pitch, and Yaw self.UpdateGyro() self.StartingGyro = self.Gyro print('Orientation: ', self.getStartingGyro()) # - Read the actual position North, East, and Down self.UpdatePosition() self.StartingPosition = self.Position print('Position: ', self.getStartingPosition()) # - Read the actual depth: time.sleep(3) print("Starting gyro: ", self.StartingGyro)
import sys import time import csv import math import array from Phidget22.Devices.Spatial import * from Phidget22.PhidgetException import * from Phidget22.Phidget import * from Phidget22.Net import * from cmath import * #from SpatialTry import * lastAngles = [0, 0, 0] try: ch = Spatial() except RuntimeError as e: print("Runtime Exception %s" % e.details) print("Press Enter to Exit...\n") readin = sys.stdin.read(1) exit(1) def SpatialAttached(e): try: attached = e attached.resetMagnetometerCorrectionParameters() attached.setMagnetometerCorrectionParameters( 0.36341, 0.09927, 0.11774, -0.07688, 2.66012, 2.56018, 3.03476, 0.01156, -0.07656, 0.00600, 0.06844, -0.05628, 0.07447) print("\nAttach Event Detected (Information Below)")
# Event Manager Definitions ######################################################################### tiempo = [] ac0 = [] ac1 = [] ac2 = [] gr0 = [] gr1 = [] gr2 = [] mg0 = [] mg1 = [] mg2 = [] try: Space = Spatial() except RuntimeError as e: print("Runtime Exception %s" % e.details) print("Press Enter to Exit...\n") readin = sys.stdin.read(1) exit(1) ########################### Spatial Setup def SpatialAttached(e): try: attached = e print("\nAttach Event Detected (Information Below)") print("===========================================") print("Library Version: %s" % attached.getLibraryVersion())