Example #1
0
        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)
    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)

T_muestreo = 50  # 20 mediciones por segundo