Esempio n. 1
0
    file.write("--------------------------------------------")
    #file.write("\n")

    ch.openWaitForAttachment(5000)

except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(1)
    exit(1)

print("Gathering data for 10 seconds...")
time.sleep(10)

try:
    ch.close()
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(2)
    exit(1)
print("Closed Spatial device")
exit(0)
"""

for value in compassBearingFilter:
                    if angles[i] > lastAngles[i]:
                        value[i] += 360 * math.pi / 180.0 
                    else:
                        value[i] -= 360 * math.pi / 180.0 
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(1)
    exit(1)

# Definir el tiempo de muestro del acelerometro (En ms)

T_muestreo = 50  # 20 mediciones por segundo
Space.setDataInterval(T_muestreo)

# Muestrear 5 segundos
time.sleep(5)

try:
    Space.close()

except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(1)
    exit(1)
print("Closed Spatial Device")

# Convetir los vectores a arreglos de numpy para hacer los calculos mas eficientes

ac0_np = np.array(ac0)  #*9.80665
ac1_np = np.array(ac1)  #*9.80665
ac2_np = np.array(ac2)  #*9.80665
t_seg = np.array(tiempo) / 1000