Пример #1
0
    else:
        dynAccel = round(acceleration[1] - gy, 5) * 9.8
        velocityX = integrate.cumtrapz(
            (prevDynAccel, dynAccel), dx=0.03) + velocityX
        velocityX = velocityX[0]
        distance = integrate.cumtrapz(
            (prevVelocity, velocityX), dx=0.03) + distance
        prevDynAccel = dynAccel
        prevVelocity = velocityX
        distance = distance[0]
        print dynAccel, velocityX, distance, timestamp


try:
    ch.setOnAttachHandler(AccelerometerAttached)
    ch.setOnDetachHandler(AccelerometerDetached)
    ch.setOnErrorHandler(ErrorEvent)
    ch.setOnSpatialDataHandler(AccelerationChangeHandler)
    print("Waiting for the Phidget Accelerometer Object to be attached...")
    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...")

ch.setDataInterval(30)
time.sleep(15)
try:
    ch.close()
Пример #2
0
            yawAngle += compassBearingFilter[l][2]

        yawAngle /= Count
        pitchAngle /= Count
        rollAngle /= Count

        compassBearing = yawAngle * (180.0 / math.pi)
    #   print("Bearing after: %.2f" % compassBearing)

    except:
        print()


try:
    ch.setOnAttachHandler(SpatialAttached)
    ch.setOnDetachHandler(SpatialDetached)
    ch.setOnErrorHandler(ErrorEvent)
    ch.setOnSpatialDataHandler(calculateCompassBearing)

    print("Waiting for the Phidget Spatial Object to be attached...")
    file = open("dir.txt", "a")
    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)
    ac1.append(acceleration[1])
    ac2.append(acceleration[2])
    gr0.append(angularRate[0])
    gr1.append(angularRate[1])
    gr2.append(angularRate[2])
    mg0.append(fieldStrength[0])
    mg1.append(fieldStrength[1])
    mg2.append(fieldStrength[2])


# Programa Principal
#########################################################################

try:
    Space.setOnAttachHandler(SpatialAttached)
    Space.setOnDetachHandler(SpatialDetached)
    Space.setOnErrorHandler(ErrorEvent)
    Space.setOnSpatialDataHandler(SpatialDataHandler)
    #########################################################################
    print("Waiting for the Phidget Spatial Object to be attached...")
    Space.openWaitForAttachment(5000)
    print("Spatial attached")
    #########################################################################
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)