omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Motion broken on iOS 12.2?

    Pythonista
    3
    7
    3424
    Loading More Posts
    • 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.
    • njm
      njm last edited by

      Hello everyone. I’m a long time lurker and thanks for all your posts. I’m developing a gps app and it appears motion on iOS 12.2 gives random results. My testflight and Pythonista versions work fine at 12.1. Google helped me find chatter on other sites saying that the privacy settings for motion are now being enforced the way location settings are.
      Is anyone else having a problem? Workarounds?

      1 Reply Last reply Reply Quote 0
      • njm
        njm last edited by njm

        As a work around, using the yaw component from motion.get_attitude works. Apple calibrates it with the magnetometer some how. Acceleration, attitude and gravity all seem to be unchanged. The attached code works in both 12.1 and 12.2.

        mag_test.py

        Screenshots in the gist show the magnetometer results for 12.1 at N,E,S and W.
        For 12.2 the magnetometer results appear to be random.

        The device orientation comes from ui.WebView (Thanks @JonB https://forum.omz-software.com/topic/997/get-current-screen-or-orientation-width).

        In portrait mode when the screen is held high (or low) enough to be face down, yaw and roll flip 180deg. This can be detected by the sign of a gravity component. The original Swift example (https://medium.com/swiftly-swift/how-to-build-a-compass-app-in-swift-2b6647ae25e8) uses a CoreMotion component not easily obtained by Pythonista to flag a face down orientation.

        edit: By face down I mean past vertical. The pitch component must be in the range [+90,-90]

        cvp mikael 2 Replies Last reply Reply Quote 0
        • cvp
          cvp @njm last edited by

          @njm Link https://github.com/njmcn/Pythonista/blob/master/mag_test.py gives error 404 😢

          1 Reply Last reply Reply Quote 0
          • mikael
            mikael @njm last edited by

            @njm, repository not public?

            1 Reply Last reply Reply Quote 1
            • njm
              njm last edited by

              repository now public

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @njm last edited by cvp

                @njm test this

                from objc_util import *
                
                UIDevice = ObjCClass('UIDevice').currentDevice()
                print(UIDevice.orientation())
                # https://developer.apple.com/documentation/uikit/uideviceorientation?language=objc
                # 6 = UIDeviceOrientationFaceDown
                

                If it prints 6, your iDevice is face down

                1 Reply Last reply Reply Quote 0
                • njm
                  njm last edited by njm

                  Thanks @cvp
                  I gave it a try. Here is a simple comparison of UIDevice.orientation to motion.get_attitude:
                  facedown.py

                  The 6 only comes up when completely upside down. The transition from flat to "vertical" happens near a pitch or roll of 30deg. Still not as reliable as the gravity term and ui.WebView

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors