Streaming Accelerometer and Gyroscope data simultaneously
Hi I am wondering if there is somewhere an example to combine the streaming of acc and gyro into one timestamp. I have the MetaMotionR and I am looking for the equivalent of this function but with both the sensors (so I am able to print(acceleration.x) and print(gyroscope.x) simultaneously in the same function):
@IBAction func accelerometerBMI160StartStreamPressed(_ sender: Any) {
accelerometerBMI160StartStream.isEnabled = false
accelerometerBMI160StopStream.isEnabled = true
accelerometerBMI160StartLog.isEnabled = false
accelerometerBMI160StopLog.isEnabled = false
updateAccelerometerBMI160Settings()
accelerometerBMI160Data.removeAll()
let signal = mbl_mw_acc_bosch_get_acceleration_data_signal(device.board)!
mbl_mw_datasignal_subscribe(signal, bridge(obj: self)) {(context, obj) in
let acceleration: MblMwCartesianFloat = obj!.pointee.valueAs()
let _self: DeviceDetailViewController = bridge(ptr: context!)
DispatchQueue.main.async {
_self.accelerometerBMI160Graph.addX(Double(acceleration.x), y: Double(acceleration.y), z: Double(acceleration.z))
}
_self.accelerometerBMI160Data.append((obj!.pointee.epoch, acceleration))
print(acceleration.x)
}
}
mbl_mw_acc_enable_acceleration_sampling(device.board)
mbl_mw_acc_start(device.board)
streamingCleanup[signal] = {
mbl_mw_acc_stop(self.device.board)
mbl_mw_acc_disable_acceleration_sampling(self.device.board)
mbl_mw_datasignal_unsubscribe(signal)
}
}
Thanks for any tips and help!
Comments
Please see the fuser in our tutorials. This is what it does.
Thanks Laura! This works fine Do you know how I can sample acc. and gyro. both on 10Hz frequency? Or if there is a resampling option?
Yes, our APIs allow you to change the sampling frequency, just follow the tutorials.