Packing data of multiple sensors

Hello everyone.
I am wondering how I should pack data of multiple sensors i.e. gyroscope & accelerometer.
I intend to sample both at 100 Hz.
Somehow when I streamed gyro data (and only gyro) at 100 Hz without any changes in the settings, I had a lower freq regarding the timestamps, and reducing the max connection interval to 7.5ms solved that issue.
Now I want to stream both gyro and acc and I want them to be packed together. For now, I call the accelerometer and the gyro objects to stream using addRouteAsync inside my board.connectAsync() but the packs I receive are either gyro or acc (which is expected). Now I think there might be a better way to pack data so that each pack has samples of gyro and acc but I honestly do not get the logic of the "sensor fusion" that you talk about often on this topic (I am new to Android).
Can you please support me with some explanation over the correct form of coding regarding my purpose?
Thanks in advance

Comments

  • edited February 23

    Sensor fusion is just a kalman filter. It will take the output of the acc, gyro, and mag and turn it into euler or quaternions.
    It doesn't sound like that's what you want thought. It looks like you want raw data.

    The issue is that Bluetooth isn't very fast so 100Hz acc + 100Hz gyro is outside the limits of BLE.

    We do have two things you should try out:

    1) We have a mode that allows you to pack 3 data points into 1 ble packet for one sensor (this would be for acc OR gyro, this doesn't combine them). It's called the packed mode.
    You could do a packed mode acc and a packed mode gyro and see if you get all your data that way.

    2) We have a fuser mode that allows you to put 1 acc data point and 1 gyro data point into a single ble packet.

  • Thanks for your response, Laura.
    Yes, I need raw data for further analysis is an activity recognition system.
    About the 1st option that you mentioned, I am already doing so. Meaning that I get the packed data of acc and the packed data of gyro. the problem is that the received packets are not necessarily gyro/acc on every other packet and I sometimes get 2 (or even 3) packets of packed acc consecutively. That makes things complicated when trying to rebuild a real-time set of acc and gyro data.
    About your second suggestion, that sounds exactly like what I'm looking for, Yet I have not been able to find anything yet... So how can I access this fuser mode that you mentioned? That seems like something different from sensor fusion of the API because there is no mode of sensor fusion alike our topic as far as I know.
    Thanks again for the great support.

  • Just look at the fuser in our dataprocessor tutorials
    Also sensor fusion might work better for you, it's how we made MetaRom.

  • I tried to implement fuser exactly as mentioned in the doc for SDK 3.7
    I defined a function as follows and I made sure to call it after I have configured and started sensors. But it seems that there is something wrong with the buffer method because I don't get any of the logs inside my onSuccessTask. I have configured both sensors at 100 Hz.

    // Inside onServiceConnected I have configured the modules accelerometer and gyroscope ...
    
    /* Inside onCreate I am enabling the modules. Also I am calling
     the fuseImuData function inside onCreate to make sure that modules
     are already active. After I press a start button, the following code runs */
    
    
    accelerometer.acceleration().start();
    gyroscope.angularVelocity().start();
    accelerometer.start();
    gyroscope.start();
    fuseImuData(accelerometer, gyroscope);
    
    
    public void fuseImuData(Accelerometer accelerometer, GyroBmi160 gyroscope){
            gyroscope.angularVelocity().addRouteAsync(source -> {
                source.buffer().name("gyro-buffer");
                Log.i(TAG,"Gyro buffered");
            }).onSuccessTask(ignored -> accelerometer.acceleration().addRouteAsync(source ->
                source.fuse("gyro-buffer").limit(10).stream((data, env) -> {
            Data[] values = data.value(Data[].class);
            // accelerometer is the source input, index 0
            // gyro name is first input, index 1
            Log.i(TAG,"Fusing completed");
            Log.i(TAG,"IMU Data: "+values[0].value(Acceleration.class).toString()+" "+
                    values[1].value(AngularVelocity.class).toString());
    })));}
    

    I don't get the "Fusing completed" Log so the buffering has not been successful. Can you please help me with this?

Sign In or Register to comment.