Proper way to "reset" for game rotation?

I have an app where if someone has been using their Frames in other apps, etc. they might have a different direction for 0. When the user clicks a "Go" button in my application, I'd like the position of their frames to calibrate to where they were looking when they tapped that button. Essentially setting that to 0.
0
Best Answers
-
[email protected] Member Posts: 111
Hi @ericdolecki,
When your app comes into the foreground, you can ask the user to reconnect. When the user reconnects, you can collect game rotation data. That should refresh. If there is a specific position they need to be in the app, may be you can do text to speech and let them know how they should be positioned, so you can collect the proper data you need.
Does this help?
n5 -
ericdolecki Member Posts: 15
Ahh. So you're saying at startup or whenever, take current readings, zero them out, and then apply those vars that were needed to zero out and apply to readings going forward. I'll try that.
It might be nice to be able to have a session.device?.resetSensors() call or something similar in the future.0 -
[email protected] Member Posts: 111
Hi @ericdolecki,
Yeah, you'll need to have 2 variables to do that. One variable takes the current position of the device, and the other variable is how the BoseAR device moves relative to the base position. You subtract those 2 variables. Thanks for the suggestion.
Nadine5
Answers
It would be nice to have a session.device?.calibrate() method - I could tell the user to look straight ahead and have them tap a button or something to re-calibrate.
Hi @ericcdolecki,
I see what you’re saying. In short, you can program your Bose AR device to re-orient itself. There is no API to recalibrate or re-orient device. It’s up to you manage the orientation. You can manage the orientation via pitch, roll, and yaw. For GameRotation, there is no calibration needed- only for absolute rotation. You can check out those details here:
https://developer.bose.com/guides/bose-ar/imu-calibration
A really helpful example is the ScenceExample. I’m not sure what your use case is or how you are managing the app, but when you double tap in the SceneViewController or press the “Reset initial orientation” button in the SettingsViewController, you call
```self?.resetOrientation()```. This function is in the SceneViewController. The baseReadings gets set to ```nil``` when that happens.
In the update() function, baseReadings is set to nil. At the moment double tap or the reset button is pressed, the current orientation of the device is taken via pitch, roll, and yaw for the baseReadings. Let’s say the baseReadings are now: ((pitch: -0.25137047167766546, roll: -0.10287041418552326, yaw: -1.9480170599941329)). At the time of double tap or reset button is pressed baseReadings == quaternion values. I.E. baseReadings.pitch == quaternion.pitch. When you subtract those values, you get 0. I.E. you get (0,0,0) for pitch, roll, and yaw. Any movement in relation to (0,0,0) gets mapped to the object in the scene by subtracting the baseReadings from the current quaternion values.
I hope this helps answer your question. Please let me know how I can clarify.
Best,
Nadine