Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QGyroscope readingChanged interval changes if QRotationSensor is used
Qt 6.11 is out! See what's new in the release blog

QGyroscope readingChanged interval changes if QRotationSensor is used

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 544 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved