QGyroscope readingChanged interval changes if QRotationSensor is used
Unsolved
Mobile and Embedded
-
Hi,
I found a very strange behaviour.
The interval at which the readings will change (updated) depends on the types of sensor I use in my application!
Take a look at the following Code snipped:SensorModuleV3::SensorModuleV3(QObject *parent) : QThread(parent) { pAccelerometer = new QAccelerometer(this); pGyroscope = new QGyroscope(this); pRotationSensor = new QRotationSensor(this); pAccelerometer->stop(); pGyroscope->stop(); pRotationSensor->stop(); pAccelerometer->setAlwaysOn(true); pAccelerometer->setActive(true); pAccelerometer->setAxesOrientationMode(QSensor::FixedOrientation); pAccelerometer->setSkipDuplicates(false); pAccelerometer->setAccelerationMode(QAccelerometer::Combined); pGyroscope->setAlwaysOn(true); pGyroscope->setActive(true); pGyroscope->setAxesOrientationMode(QSensor::FixedOrientation); pGyroscope->setSkipDuplicates(false); pAccelerometer->start(); pGyroscope->start(); //pRotationSensor->start(); // Uncomment and gyroscope interval will change! } SensorModuleV3::~SensorModuleV3() { pAccelerometer->stop(); pGyroscope->stop(); delete pAccelerometer; delete pGyroscope; delete pRotationSensor; } void SensorModuleV3::slotTest() { qint64 timestampEnd = QDateTime::currentMSecsSinceEpoch() + 1000; quint64 lastGyroPreciseTimestamp; quint64 lastAccelerometerPreciseTimestamp; while (QDateTime::currentMSecsSinceEpoch() < timestampEnd) { quint64 currentGyroPreciseTimestamp = pGyroscope->reading()->timestamp(); quint64 gyroTimeDiff = currentGyroPreciseTimestamp - lastGyroPreciseTimestamp; if (gyroTimeDiff > 0) { qDebug() << "gyro precise diff:" << gyroTimeDiff; lastGyroPreciseTimestamp = currentGyroPreciseTimestamp; } quint64 currentAccelerometerPreciseTimestamp = pAccelerometer->reading()->timestamp(); quint64 accelTimeDiff = currentAccelerometerPreciseTimestamp - lastAccelerometerPreciseTimestamp; if (accelTimeDiff > 0) { qDebug() << "accel precise diff:" << accelTimeDiff; lastAccelerometerPreciseTimestamp = currentAccelerometerPreciseTimestamp; } } }
On my device (Samsung S4 mini) I get values around about 22 ms for "accelTimeDiff" and "gyroTimeDiff". If I uncomment the line "pRotationSensor->start();" the value for "gyroTimeDiff" will change to around about 6 ms!
Can someone try to reproduce this on another device?
Can someone tell me why this is happening?