-
-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sensors_plus): iOS calibrated magnetometer #812
Conversation
Added necessary Android, iOS, and web API for magnetometer sensor. Adds new `MagnetometerEvent` class (and fixes small typo in constructor of other `FooEvent` classes). Adds new `Stream<MagnetometerEvent>` called `magnetometerEvents`.
This reverts commit 8778d6c.
- Adds necessary Android, iOS, and web API for magnetometer sensor. - Adds new `MagnetometerEvent` class. - Adds new `Stream<MagnetometerEvent>` called `magnetometerEvents`. (This commit compared to an earlier one reverts any changes that were made that were unrelated to added magnetometer support.)
"Contructs" -> "Constructs" & "premission" -> "permission"
Attempting to pass PR tests.
As described in #781 the current implementation of **magnetometer** sensor data acquisition for iOS does not use calibrated values evaluated by iOS's `DeviceMotion` sensor, but rather the raw samples straight from the sensor. As the **user acceleration** implementation already employs this *calibrated* `DeviceMotion` sensor, it seems like an appropriate solution to acquiring compensated magnetometer data as well. `melos run format` made changes to a huge number of files across all packages. I discarded all changes outside of `packages\sensors_plus\`. The focus of this PR is the magnetometer implementation at the end of `sensors_plus\sensors_plus\ios\Classes\FLTSensorsPlusPlugin.m`.
Force-push amended some formatting and analysis discrepancies between local |
I have realized it would have been cleaner to create a brand-new branch instead of updating my last development branch--less commits. I am still learning! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Zabadam LGTM, any chance you can fix the merge conflicts?
@Zabadam Maybe you have missed last message, but could you fix merge conflicts in this PR? |
Oh, I definitely missed that! I could indeed do as requested, but I must note that the original Issue raised that this PR was meant to rectify was allegedly not fixed by this PR. That said, these changes are probably still in the best interest of the package, as they match other similar implementations of iOS sensor data with Flutter (i.e. using |
While prior merge conflict was resolved via github.com, this push ran true melos format command. Abbreviations were made to comment to accommodate the smaller formatted space.
At long last, this PR is truly ready. Thank you for your patience. Side-note: I do have more hopes/visions for this package. Other similar packages have more features but less platform support. |
I am checking this PR locally and it doesn't build for me, the errors I get are:
(seems that CI iOS build job didn't catch this up, so we need to review that as well) |
Thank you so much for helping me test and verify. I am especially grateful as I really have no means to check these fixes myself.
This portion of code receives a warning, but the work was done before this PR. [Note 1] To the best that I can ascertain through my research, it seems in 2021 an XCode/iOS update started flagging empty parameter lists. What makes this an "old-style function?"
I was initially stumped but I think it is pretty easy. I believe As a benefit, pondering this led me to better understand how these sensors are activated and fused in iOS. Today I realized the different [Note 1]: This bug allowed me to catch something else: a missing reference to [Note 2]: I read an excellent comment on StackOverflow about the different ways to obtain magnetometer data in iOS.
An interesting find. As Ultimately it depends on what the user actually intends to do with the geomagnetic data. Stud finder? Probably Furthermore how these values compare to Android's implementation is mystery to me. |
Also altering reference frame from `XArbitraryCorrectedZVertical` to `XMagneticNorthZVertical` which may or may not impact the effectiveness of the magnetometer calibration.
taking a look at this at the moment, I want to give it a quick run on my phone but I have to deal with some iOS shenanigans with updates and so :) I merged the current main branch because we incorporated ios specific build steps to catch any compilation issues |
alright, I was able to give it a run and saw no issue, so I see no reason to not to merge and release. Thanks for your work! |
Description
iOS: Corrects magnetometer implementation, returning calibrated values from
DeviceMotion
sensor rather than raw sensor samples.As the user acceleration implementation already employs this calibrated
DeviceMotion
sensor, it seems like an appropriate solution to acquiring compensated magnetometer data as well.melos run format
made changes to a huge number of files across all packages. I discarded all changes outside ofpackages\sensors_plus\
.The focus of this PR is the magnetometer implementation at the end of
sensors_plus\sensors_plus\ios\Classes\FLTSensorsPlusPlugin.m
.I kindly request verification of this proposed solution, specifically as I have no means to test it myself without an iOS device, and also because I am uncertain of my Objective-C code.
Related Issues
#781
Magnetometer values are offChecklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
).This will ensure a smooth and quick review process.
pubspec.yaml
andCHANGELOG.md
.///
).flutter analyze
) does not report any problems on my PR [forsensors_plus
].Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?