Sensor Fusion

Hello!
I am using the MMR sensor and I collect the data generated by the SensorFusion module. Now, I used sensorFusion.stop(); to pause the data collection; however this is not working. The data collection is infinite. Can I pause the sensor when I pause the algorithm? How else can I pause the sensor?

Thank you very much for your answers

Comments

  • edited March 2021

    You would need to post cost but just make sure you are following these steps:

    libmetawear.mbl_mw_sensor_fusion_set_mode(s.device.board, SensorFusionMode.NDOF);
    libmetawear.mbl_mw_sensor_fusion_set_acc_range(s.device.board, SensorFusionAccRange._8G)
    libmetawear.mbl_mw_sensor_fusion_set_gyro_range(s.device.board, SensorFusionGyroRange._2000DPS)
    libmetawear.mbl_mw_sensor_fusion_write_config(s.device.board)
    signal = libmetawear.mbl_mw_sensor_fusion_get_data_signal(s.device.board, SensorFusionData.QUATERNION);
    libmetawear.mbl_mw_datasignal_subscribe(signal, None, s.callback)
    libmetawear.mbl_mw_sensor_fusion_enable_data(s.device.board, SensorFusionData.QUATERNION);
    libmetawear.mbl_mw_sensor_fusion_start(s.device.board);
    ...
    libmetawear.mbl_mw_sensor_fusion_stop(s.device.board);
    

    Another example:

    mbl_mw_sensor_fusion_set_acc_range(device.board, MBL_MW_SENSOR_FUSION_ACC_RANGE_8G)
    mbl_mw_sensor_fusion_clear_enabled_mask(device.board)
    mbl_mw_sensor_fusion_enable_data(device.board, MBL_MW_SENSOR_FUSION_DATA_LINEAR_ACC)
    mbl_mw_sensor_fusion_write_config(device.board)
    mbl_mw_sensor_fusion_start(device.board)
    ...
    mbl_mw_sensor_fusion_stop(self.device.board)
    mbl_mw_sensor_fusion_clear_enabled_mask(self.device.board)
    mbl_mw_datasignal_unsubscribe(signal)
    
  • I just wrote this and testing it in Swift for you; just replicate in Java:

        let board = device.board
        counter = 0
        let accelRange = MBL_MW_SENSOR_FUSION_ACC_RANGE_16G
        let gyroRange = MBL_MW_SENSOR_FUSION_GYRO_RANGE_2000DPS
        let sensorFusionMode = MBL_MW_SENSOR_FUSION_MODE_IMU_PLUS
        mbl_mw_sensor_fusion_set_acc_range(board, accelRange)
        mbl_mw_sensor_fusion_set_gyro_range(board, gyroRange)
        mbl_mw_sensor_fusion_set_mode(board, sensorFusionMode)
        let fusionSignal = mbl_mw_sensor_fusion_get_data_signal(board, MBL_MW_SENSOR_FUSION_DATA_LINEAR_ACC)!
        mbl_mw_datasignal_log(fusionSignal, bridge(obj: self)) { (context, logger) in
            let this: Tests = bridge(ptr: context!)
            this.fuser = logger!
            print("Started logger: ", this.fuser)
        }
        mbl_mw_logging_start(board, 0)
        mbl_mw_sensor_fusion_clear_enabled_mask(board)
        mbl_mw_sensor_fusion_enable_data(board, MBL_MW_SENSOR_FUSION_DATA_LINEAR_ACC)
        mbl_mw_sensor_fusion_write_config(board)
        mbl_mw_sensor_fusion_start(board)
        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            mbl_mw_sensor_fusion_stop(self.device.board)
            mbl_mw_sensor_fusion_clear_enabled_mask(self.device.board)
            let fusionLogger = self.fuser
            mbl_mw_logger_subscribe(fusionLogger, bridge(obj: self), { (context, dataPtr) in
                let timestamp = dataPtr!.pointee.timestamp
                let acc: MblMwCartesianFloat = dataPtr!.pointee.valueAs()
                print("acc : \(timestamp) \(acc)")
            })
            self.handlers.context = bridge(obj: self)
            self.handlers.received_progress_update = { (context, remainingEntries, totalEntries) in
                if remainingEntries == 0 {
                    print("done \(Date())")
                    let this: Tests = bridge(ptr: context!)
                    this.expectation?.fulfill()
                }
            }
            self.handlers.received_unknown_entry = { (context, id, epoch, data, length) in
                print("received_unknown_entry")
            }
            self.handlers.received_unhandled_entry = { (context, data) in
                print("received_unhandled_entry")
            }
            mbl_mw_logging_download(board, 0, &self.handlers)
            print("stopping \(Date())")
        }
    
Sign In or Register to comment.