Skip to content
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

Better align Orientation reference frames across platforms #451

Open
jkaufman opened this issue Jun 29, 2023 · 1 comment
Open

Better align Orientation reference frames across platforms #451

jkaufman opened this issue Jun 29, 2023 · 1 comment

Comments

@jkaufman
Copy link

jkaufman commented Jun 29, 2023

Describe the bug
The reference frame for Orientation on iOS does not always match that on Android because React-Native-Sensors does not explicitly configure CoreMotion to return attitude readings relative to the ground plane and magnetic north.

Expected behavior
A consistent reference frame for Orientation values across platforms, or at least reference frames that both integrate gyroscope and magnetometer data.

Additional context
On Android, React-Native-Sensors pulls values from getOrientation() on SensorManager. According to the API docs, the reference frame is relative to magnetic north and gravity.

On iOS, React-native-Sensors pulls values from attitude from CMMotionManager.deviceMotion(). According to the API docs, the default reference frame is xArbitraryZVertical. However, CMMotionManager can be configured to use xMagneticNorthZVertical by passing it to startDeviceMotionUpdatesToQueue:… in RNSensorsOrientation.m (docs). Availability can be checked with isMagnetometerAvailable() or availableattitudereferenceframes(). While setting this reference frame requires a magnetometer, the same requirement applies to the current Android implementation of Orientation.

I'd be happy to submit a patch but wanted to get feedback on the proposal, first.

@jkaufman
Copy link
Author

jkaufman commented Aug 2, 2023

We migrated to expo-sensors, which accepted a patch to accomplish the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant