Effect set_sample_delay in data rate

I am connecting two MetaWearR boards using python api and it has been working ok(ish) so far.

I have a calibration routine which uses sensorfusion (corrected) acc/gyro data, and the normal operation mode uses quaternion data. When entering calibration mode, I just change the sensorfusion notification callbacks, removing quaternion one and setting acc/gyro ones. When going back to normal mode, I just do the opposite.
But that caused the gyro data to stream for about 1-2 seconds and then it stops streaming (acc data keeps coming). 
So I changed to use the normal (not sensorfusion) acc/gyro when in calibration, and re-enable sensorfusion when going back to normal mode. 

https://pastebin.com/KuvHKM0A here is the code used for the mode change. You can see that I commented the set_sample_delay call, which was set to 20ms for a data rate of 50Hz. Using that, besides eventual segmentation faults when going from calibration to normal mode, the data rates were 50Hz for the first board I connected and 35Hz for the second. Now with that line commented, both sensors stream at 100Hz. How can it be?

Comments

  • BTW, in order to get the 100Hz, the first time that I connect to the two boards, data arrives at 66Hz and some lag (less than 500ms). 
    Then, if I reconnect (just calling disconnect() and connect() for each board) while the program is running, then it goes up to 100Hz without any lag.
  • You'll need to setup your code to handle high frequency streaming:
  • edited September 2017
    Does this apply to sensorfusion? Because when I refer to "data", I mean sensor fusion data. I am already making the call to:

    board.settings.set_connection_parameters(7.5, 7.5, 0, 6000)

    However, the question was not about "how to stream data higher than 100hz", but more a two-fold question:
    1) If I use set_sample_delay (with two boards) with 20ms (50Hz), I get 50Hz for the 1st board and 37Hz for the 2nd board.
    2) If I remove set_sample_delay (with two boards), I get 66Hz for both boards and some lag, and after reconnect to the first board, I get 100Hz for both boards and no lag.

    EDIT: Question 2 is somewhat solved. It is some weird interaction with pyopengl (which I am using). If I initialize the pygame+opengl window "before" connecting to the boards, the 66hz+lag problem dissapears. I don't know why, though...
  • The connection parameters settings apply when streaming from multiple devices.  Since you are already modifying the connection parameters, that point is moot.

    Can you get 50Hz from each board if you are running your Python code without the opengl portion?
This discussion has been closed.