Differance between data from MetaBase app and real-time streaming

Hi, I am trying to acquire the data from both, accelerometer and gyroscope in 50Hz sampling rate.
First I have tried to do that using the app, and later using this code.
The results received were different, and I am trying to find the cause.
Is there anything here that 'pops up'?

Thanks!

class Sensor:
def init(self, mac=None):
if mac is None:
self.__mac = None
self._discover()
else:
self.__mac = mac

    self.device = MetaWear(self.__mac)

def start_activity(self):
    acc_data = []
    gyr_data = []

    def _data_handler_acc(ctx, data):

        current_time = datetime.now()
        current_time = str(current_time.time())
        obj = parse_value(data)
        print(f'acc data: {obj}')

        acc_data.append([current_time, obj.x, obj.y, obj.z])

    def _data_handler_gyr(ctx, data=15):

        current_time = datetime.now()
        current_time = str(current_time.time())
        obj = parse_value(data)
        print(f'gyr data: {obj}')
        gyr_data.append([current_time, obj.x, obj.y, obj.z])


    callback_gyr = FnVoid_VoidP_DataP(_data_handler_gyr)
    callback_acc = FnVoid_VoidP_DataP(_data_handler_acc)

    libmetawear.mbl_mw_acc_set_odr(self.device.board, 50.0)
    libmetawear.mbl_mw_acc_set_range(self.device.board, 16.0)
    libmetawear.mbl_mw_acc_write_acceleration_config(self.device.board)


    libmetawear.mbl_mw_gyro_bmi160_set_odr(self.device.board, GyroBmi160Odr._50Hz)
    libmetawear.mbl_mw_gyro_bmi160_set_range(self.device.board, GyroBmi160Range._2000dps)
    libmetawear.mbl_mw_gyro_bmi160_write_config(self.device.board)


    acc_signal = libmetawear.mbl_mw_acc_get_acceleration_data_signal(self.device.board)
    libmetawear.mbl_mw_datasignal_subscribe(acc_signal, None, callback_acc)

    gyr_signal = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board)
    libmetawear.mbl_mw_datasignal_subscribe(gyr_signal, None, callback_gyr)

    libmetawear.mbl_mw_acc_enable_acceleration_sampling(self.device.board)
    libmetawear.mbl_mw_acc_start(self.device.board)

    libmetawear.mbl_mw_gyro_bmi160_enable_rotation_sampling(self.device.board)
    libmetawear.mbl_mw_gyro_bmi160_start(self.device.board)

    print('starting 1 minutes recording')
    sleep(60)
    print('stopping recording')


    libmetawear.mbl_mw_acc_stop(self.device.board)
    libmetawear.mbl_mw_acc_disable_acceleration_sampling(self.device.board)

    libmetawear.mbl_mw_gyro_bmi160_stop(self.device.board)
    libmetawear.mbl_mw_gyro_bmi160_disable_rotation_sampling(self.device.board)


    acc_signal = libmetawear.mbl_mw_acc_get_acceleration_data_signal(self.device.board)
    libmetawear.mbl_mw_datasignal_unsubscribe(acc_signal)

    gyr_signal = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board)
    libmetawear.mbl_mw_datasignal_unsubscribe(gyr_signal)
    libmetawear.mbl_mw_debug_disconnect(self.device.board)

Comments

  • Make sure this is. actually working:
    libmetawear.mbl_mw_acc_set_odr(self.device.board, 50.0)
    libmetawear.mbl_mw_acc_set_range(self.device.board, 16.0)

  • according to the signal's length, the sampling rate is actually 50Hz

  • Ok, your setup looks good. I don't see anything wrong with it.

Sign In or Register to comment.