streaming from both acc and gyr

I saw in the python tutorial that there is a written code for streaming data from the acc. is there an option to stream from both acc and gyr simultaneously?

I have very basic knowledge in writing code, but need it for some home assignment.
thanks.

Comments

  • Yes, this is possible and you can go through our tutorials and example code.

    However, if you are not comfortable with coding, you can achieve the same thing with our MetaBase App on the app stores.

  • In the Python SDK, there is example code like stream_acc_gyro.py, which is supposed to stream acc and gyro data from sensors in real time. @rotemg2

    In the original code, the following lines are commented out. They are there to set range and sampling rate for acc and gyro, If I am not wrong.

    #libmetawear.mbl_mw_acc_set_odr(s.device.board, 100.0)
    #libmetawear.mbl_mw_acc_set_range(s.device.board, 16.0)
    #libmetawear.mbl_mw_acc_write_acceleration_config(s.device.board)
    
    #libmetawear.mbl_mw_gyro_bmi160_set_range(s.device.board, 2000.0);
    #libmetawear.mbl_mw_gyro_bmi160_set_odr(s.device.board, 25.0);
    #libmetawear.mbl_mw_gyro_bmi160_write_config(s.device.board);
    

    My problem is I can only see data from acc. What is wrong here? @Laura

  • You can uncomment those lines. Remember it's just example code so you are expected to tweak it to your needs.

    Make sure you subscribe to both signals and that you turn on the bmi.

  • Laura,

    I believe the original code does subscribe to both signals and turn on the BMI.

    acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(s.device.board)
    libmetawear.mbl_mw_datasignal_subscribe(acc, None, s.callback)
    
    gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(s.device.board)
    libmetawear.mbl_mw_datasignal_subscribe(gyro, None, s.callback)
    
    libmetawear.mbl_mw_acc_enable_acceleration_sampling(s.device.board)
    libmetawear.mbl_mw_acc_start(s.device.board)
    
    libmetawear.mbl_mw_gyro_bmi160_enable_rotation_sampling(s.device.board)
    libmetawear.mbl_mw_gyro_bmi160_start(s.device.board)
    

    The problem that I have is I only see acc data in data_handler if I enable both acc and gyro.
    Why is it so?

    My second question is if I subscribe to both, how do I differentiate acc from gyro in data_handler function?

    Thx.

  • Well there's a few issues.
    1. First you need to make sure that the total frequency is <100Hz. Currently You might have set the acc to 100Hz so the gyro data won't come through. Fix that first.
    2. Second, make sure there is a handler for the data callback for both the gyro and acc:
    libmetawear.mbl_mw_datasignal_subscribe(acc, None, s.callback)
    libmetawear.mbl_mw_datasignal_subscribe(gyro, None, s.callback)
    The callback handles the data. The example uses the same callback but you can separate them if you want so that you can print a different output for the gyro versus the acc.

  • edited January 2021
    1. In the memory capacity calculator page, the sensor is able to support 800Hz data rate max. It is not true?
    2. You said total < 100Hz; does it mean if I enable both acc and gyro, their total data rate must be < 100Hz. So 50 Hz each is the maximum MMR can provide?
    3. If I only enable one reading either acc or gyro, is MMR able to deliver 800Hz data rate?
    4. There are 2 modes of getting the data: (1) real time streaming, and (2) log first then download. I guess for very high data rate like 800Hz, is the 2nd mode better in teams of data loss? Because for downloading, you don't need to transmit 800 readings per second if Bluetooth is not running its max speed.
    1. 800Hz logging. 100Hz streaming.
    2. Yes, you should know this from our tutorials already.
    3. Again, only if you are logging. Please go through our tutorials, they explain this in detail.
    4. LOGGING: 800HZ. STREAMING: 100HZ (BLUETOOTH CAN'T SUPPORT FASTER).
  • edited January 2021

    @Laura,

    I read from another thread saying JavaScript is better and more reliable that Python for working with MetaWear. What is your opinion? I have just started working with MMR. Most likely I will be working in Ubuntu.
    I have downloaded and built C++ SDK; however there is no sample app.

    For the tutorials, you mean this one (https://mbientlab.com/tutorials/index.html), isn't it? I could not fine the part that specifies the logging and streaming data rate limit (800 & 100).

Sign In or Register to comment.