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. Qt 5.12.2+ sensors can't be used for Android because of QTBUG-77423
Forum Updated to NodeBB v4.3 + New Features

Qt 5.12.2+ sensors can't be used for Android because of QTBUG-77423

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 4 Posters 674 Views 2 Watching
  • 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.
  • PowerNowP Offline
    PowerNowP Offline
    PowerNow
    wrote on last edited by PowerNow
    #1

    Hi,
    I updated from Qt 5.12.1 to 5.15.2 and found this error.
    https://bugreports.qt.io/browse/QTBUG-77423

    All versions from Qt 5.12.2 upwards are buggy regarding the QRotationReading x,y,z values. Probably the calculation from Quaternion to Euler is somewhere missing or wrong. I can test and confirm it on my app. So all of these versions are not usable for Android!

    It seem so that this bug is fixed with Qt 5.15.3 but this is a commercial lisense, I've only a very low budget and can't spend 500€/year for this bug.

    Here is written that more then 300 bugfixes will come with Qt 6.1, but this version will only appear at the end of April, this is too late for me. ​And it's not clear how stable this version will be.
    https://www.qt.io/blog/commercial-lts-qt-5.15.3-released

    Unfortunately in Qt 5.12.1 there is no Android AAB (Android App Bundles) functionality.

    Does someone has an idea what else I can do? Thanks...

    1 Reply Last reply
    0
    • KH-219DesignK Offline
      KH-219DesignK Offline
      KH-219Design
      wrote on last edited by
      #2

      Based on that QTBUG link you shared, I was able to find a related gerrit patch in the Qt gerrit, but it was abandoned:

      https://codereview.qt-project.org/c/qt/qtsensors/+/329862

      At the end of the gerrit discussion for that patch, the author states:

      I'm closing this patch in favour of 
      https://codereview.qt-project.org/c/qt/tqtc-qtsensors/+/330051
      in hopes of getting it out earlier. 
      

      ... and I just learned that:

      The Qt 5.15 LTS Commercial source codes are available in the tqtc shadow repositories and their lts branches. The lts branches have a common prefix, "tqtc/lts-". For example, "tqtc/lts-5.15".

      (source of quote: https://wiki.qt.io/Building_Qt_5_from_Git )

      This definitely matches what you (you, @PowerNow ) already stated, namely: the fix is only published into a commercial edition.

      However... I guess one option (though possibly difficult) is to apply the gerrit patch that was made public and compile your own Qt framework with that patch included.

      A similar option (but one that would avoid re-compiling the Qt framework itself) is maybe that you take the wrong x,y,z values that you already have access to... and in whatever slot or handler-function where you see these wrong {x,y,z}s, you could perhaps apply the same logic from the patch but just apply it in your own code?

      from: https://codereview.qt-project.org/c/qt/qtsensors/+/329862/6/src/plugins/sensors/android/androidrotation.cpp

      void AndroidRotation::dataReceived(const ASensorEvent &event)
      {
          // From android documentation, the rotation sensor values are:
          // values[0]: x*sin(θ/2)
          // values[1]: y*sin(θ/2)
          // values[2]: z*sin(θ/2)
          // values[3]: cos(θ/2)
      
          // The mathematics below is adapted from
          // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1644
          // and
          // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1469
          // (getRotationMatrixFromVector() followed by getOrientation())
          qreal angles[3];
          qreal q1 = qreal(event.data[0]);
          qreal q2 = qreal(event.data[1]);
          qreal q3 = qreal(event.data[2]);
          qreal q0 = qreal(event.data[3]);
      
          qreal sq_q1 = 2 * q1 * q1;
          qreal sq_q2 = 2 * q2 * q2;
          qreal sq_q3 = 2 * q3 * q3;
          qreal q1_q2 = 2 * q1 * q2;
          qreal q3_q0 = 2 * q3 * q0;
          qreal q1_q3 = 2 * q1 * q3;
          qreal q2_q0 = 2 * q2 * q0;
          qreal q2_q3 = 2 * q2 * q3;
          qreal q1_q0 = 2 * q1 * q0;
      
          angles[0] = std::atan2((q1_q2 - q3_q0), (1 - sq_q1 - sq_q3));
          angles[1] = std::asin(-(q2_q3 + q1_q0));
          angles[2] = std::atan2(-(q1_q3 - q2_q0), (1 - sq_q1 - sq_q2));
      
          qreal rz = -qRadiansToDegrees(angles[0]);
          qreal rx = -qRadiansToDegrees(angles[1]);
          qreal ry =  qRadiansToDegrees(angles[2]);
      
          if (sensor()->skipDuplicates() && qFuzzyCompare(m_reader.x(), rx) &&
                  qFuzzyCompare(m_reader.y(), ry) &&
                  qFuzzyCompare(m_reader.z(), rz)) {
              return;
          }
          m_reader.setTimestamp(uint64_t(event.timestamp / 1000));
          m_reader.setFromEuler(rx, ry, rz);
          newReadingAvailable();
      }
      

      www.219design.com
      Software | Electrical | Mechanical | Product Design

      1 Reply Last reply
      1
      • PowerNowP Offline
        PowerNowP Offline
        PowerNow
        wrote on last edited by PowerNow
        #3

        Yeah, but there is a further critical point as described in the link :

        Also the readings are become rough after the update (~2-3 readings per second), before they was much smoother (~20-30 readings per second). And dataRate doesn't help at all...
        

        I observe this also on some smartphones. With this low dataRate it's unfortunately not possible to realize smooth movements.

        1 Reply Last reply
        0
        • KH-219DesignK Offline
          KH-219DesignK Offline
          KH-219Design
          wrote on last edited by
          #4

          Wow. I don't know what else to say.

          I am forced to just agree with another comment from that bug ticket:

          Matti Vuori added a comment - 21 Feb '20 12:48

          This is a disgrace. First, a change was made that doesn't work, obviously hasn't ever worked and never will. Clearly it hasn't been tested before including it it 5.12.4. Then there's no attempt to revert it or repair it. Or even discuss it.

          https://bugreports.qt.io/browse/QTBUG-77423?focusedCommentId=499207&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-499207

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          1 Reply Last reply
          1
          • P Offline
            P Offline
            PeterT
            wrote on last edited by
            #5

            Hi All,

            Any news regarding this issue? Is that fixed in Qt 6?
            Any intentions for an API extension with quaternion or rotation matrices usage? (Euler angles are not suitable for motion tracking anyway...)

            Thanks,
            Peter

            JKSHJ 1 Reply Last reply
            0
            • P PeterT

              Hi All,

              Any news regarding this issue? Is that fixed in Qt 6?
              Any intentions for an API extension with quaternion or rotation matrices usage? (Euler angles are not suitable for motion tracking anyway...)

              Thanks,
              Peter

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @PeterT said in Qt 5.12.2+ sensors can't be used for Android because of QTBUG-77423:

              Any news regarding this issue? Is that fixed in Qt 6?

              Yes, it was fixed inQt 6.2.0: https://codereview.qt-project.org/c/qt/qtsensors/+/349022

              Any intentions for an API extension with quaternion or rotation matrices usage? (Euler angles are not suitable for motion tracking anyway...)

              I don't know, but have a look at the issue tracker: https://bugreports.qt.io/ If it hasn't been suggested yet, feel free to do so.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              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