Esempio n. 1
0
def begin_recording():
    bmx1 = BMX160(1, 0x68)
    bmx2 = BMX160(1, 0x69)

    bmx3 = BMX160(4, 0x68)
    bmx4 = BMX160(4, 0x69)

    f = open("../sensordata.log", 'w')

    asyncio.run(run_data_acquisition([bmx1, bmx2], f))

    f.close()
Esempio n. 2
0
def get_imu_data(bmx: BMX160, prev_time):
    accel = np.zeros(shape=(NUM_SAMPLES, 3))
    gyro = np.zeros(shape=(NUM_SAMPLES, 3))
    magn = np.zeros(shape=(NUM_SAMPLES, 3))

    time_vec = np.zeros(NUM_SAMPLES)

    cumtime = 0

    start_time = time_lib.time()
    new_time = (start_time - prev_time) * 1000

    # print("Time between runs {} ms".format(new_time))

    for i in range(NUM_SAMPLES):
        currtime = time_lib.time()
        data = bmx.get_all_data()
        finishtime = (time_lib.time()) - currtime
        cumtime += finishtime

        accel[i] = [data[6], data[7], data[8]]
        gyro[i] = [data[3], data[4], data[5]]
        magn[i] = [data[0], data[1], data[2]]

        time_vec[i] = cumtime

    samp_period = cumtime / NUM_SAMPLES

    return accel, gyro, magn, samp_period, time_vec, start_time
Esempio n. 3
0
get accelerometer data of sensor.

With the rotation of the sensor, data changes are visible.

Copyright   [DFRobot](http://www.dfrobot.com), 2016
Copyright   GNU Lesser General Public License

version  V1.0
date  2019-7-9
'''
import sys
sys.path.append('../')
import time
from DFRobot_BMX160 import BMX160

bmx = BMX160(1)

#begin return True if succeed, otherwise return False
while not bmx.begin():
    time.sleep(2)
''' 
AccelRange_2G
AccelRange_4G
AccelRange_8G
AccelRange_16G
'''
bmx.set_accel_range(bmx.AccelRange_4G)
time.sleep(0.1)


def main():
Esempio n. 4
0
import numpy as np
import pandas as pd
import abc

import os
import sys

from skinematics.imus import IMU_Base
from DFRobot_BMX160 import BMX160

sensor = BMX160(1)


class BMXSensor(IMU_Base):
    # Get Data function

    def get_data(self, in_file=None, in_data=None):
        #get data from sensor here....

        data = bmx.get_all_data()

        accel = numpy.zeros(shape=(120, 3))
        gyro = numpy.zeros(shape=(120, 3))
        magn = numpy.zeros(shape=(120, 3))

        cumtime = 0

        for i in range(120):
            currtime = time.time() * 1000
            data = bmx.get_all_data()
            cumtime += (time.time() * 1000) - currtime
Esempio n. 5
0
from DFRobot_BMX160 import BMX160
import time

# Just a tool for getting the sampling rate for the BMX sensor from the i2c port
# Average (lower bound) sampling rate determined to be ~480 samples/sec

bmx1 = BMX160(1, 0x69)

while not bmx1.begin():
    time.sleep(2)


def main():

    counter = 0
    cumtime = 0

    while True:
        currtime = time.time() * 1000
        data1 = bmx1.get_all_data()
        time.sleep(0.002)
        cumtime += (time.time() * 1000) - currtime

        counter += 1

        if counter == 100:
            avetime = cumtime / counter
            counter = 0
            cumtime = 0
            print("Current average {}".format(avetime))