Absolute Orientation via Unity Plug In

Absolute Orientation via Unity Plug In

edited 04/05/2019 - 11:46 in Bose AR SDK for Unity
Michael@Bose[email protected] Member Posts: 66

To obtain absolute orientation using the Bose AR Unity plug in, please navigate to the following code example:

https://github.com/BoseWCTC/BoseWearable-Unity/blob/master/Unity/Assets/Bose/Wearable/Scripts/DragAndDrop/RotationMatcher.cs

In that example, please refer to the RotationMatcher component, which is used inside of the BasicDemo. 

You can set the RotationMatcher to "Absolute", which just passes the value straight to the object being rotated.

If Euler Angles are desired, you may simply reference frame.rotation.value.eulerAngles instead to get a Vector3 instead of a Quaternion.


Comments

  • bcjordanbcjordan Member Posts: 2
    Just to clarify, this is for absolute orientation/rotation, right?

    I'm wondering—is there any utility for getting an absolute X/Y/Z transform position by combining GPS and the accelerometer's relative translation over time somehow?
  • Michael@Bose[email protected] Member Posts: 66
    Absolute orientation, yes. I incorrectly used the  word "position" - it's definitely *not* absolute position. Thanks for the catch!

    I am unsure if there are any utilities for combining GPS and the accelerometer's relative position to get an absolute X/Y/Z transform.

    However, I am aware that many mobile applications, such as Google Maps and Pokemon Go! etc. do use that combination of sensors to do something similar, and so there may very well be existing tools that could be adapted to simply use the accelerometer and other sensor data from the Bose AR device instead of the phone, in combination with the phone's own GPS to do this.

    In any event, there is certainly precedent.
  • bigmousebigmouse Member Posts: 6
    Feels that the Absolute rotation is constantly off comparing to the legacy Unity plugin code on Github.
    Legacy plugin seems can re-calibrate and do a correction afterwards.
    Playing with Basic demo, when the Absolute rotation is off initially, it will not correct itself.
  • bigmousebigmouse Member Posts: 6
    I figured out that in the latest Unity plugin, there is a DefaultRotationSource const in WearableConstants, which is by default SixDof, need to be set to NineDof, in order to include megnetometer as the rotation sensor.
  • Michael@Bose[email protected] Member Posts: 66
    Hi @bigmouse - thank you for bringing this to our attention and posting your solution! This will help us and other developers make sure we better call out, document and make use of changes such as this.

    Cheers,

    Michael @ Bose
  • clubfrillsclubfrills Member Posts: 5
    @bcjordan I'm trying to do a similar transform but for indoor spaces, which makes GPS unreliable.

    My first thought was to combine a dead reckoning system to the accelerometer, and combine that with the rotation data to get a distance variable.

    This would be done by creating a pedometer out of the accelerometer's Z value -- I was considering looping a check every 300ms or so where if accelerometerZ is greater than a certain value, count this as a "step". If another reading is greater before 300ms has passed, do not count it as a step (this would be based on the average time it takes for someone to take another step to avoid logging too many steps).

    You'd then combine this with the rotation to log a relative distance moved in a direction.

    For my issues, the Unity documentation doesn't really have much info on calling the accelerometer functions, I'm just going off the RotationMatcher script right now. Is there any reference I'm missing here? 
  • Filip@Bose[email protected] Member Posts: 43
    Hey @clubfrills check out this simple script that is very similar to the RotationMatcher

    This should help you visualize and pull the accelerometer data,
    Cheers!
  • prehensileprehensile Member Posts: 11
    I'm trying something similar - I'd like to use linear acceleration to attempt to do dead reckoning to nudge a user / player's position in a virtual space.

    I just tried your AccelerationMatcher script, @[email protected] - unless I'm doing something wrong, it looks a lot like the GameObject's XYZ position is being affected by the rotational acceleration of the Frames, rather than their linear acceleration. If I move the Frames in a straight line left / right / forward / backward I don't see much movement of the GameObject, but if I rotate the yaw/pitch/roll, I see a corresponding linear acceleration of the GameObject.

    I'll do some more tests next week - is it possible that some data is getting transposed somewhere in the SDK? The docs here state that a Bose AR device's accelerometer is linear, so I would have expected @[email protected]'s script to produce recognisable linear accelerations of a GameObject from corresponding linear accelerations of the Frames!
  • Filip@Bose[email protected] Member Posts: 43
    Hey @prehensile that's a great question!

    One of the main issues with getting raw accelerometer data from our sensors, is that you will get a constant of gravity -9.8 in Y.

    That example script takes the last frame and current frame and outputs the difference filtering out the gravity pull.

    Try working with the raw frame.acceleration and let me know what you find.

    Hope this helps,
    Cheers!
  • edited 07/31/2019 - 13:20
    prehensileprehensile Member Posts: 11
    thx for your advice, @[email protected]!

    One of the main issues with getting raw accelerometer data from our sensors, is that you will get a constant of gravity -9.8 in Y.
    That example script takes the last frame and current frame and outputs the difference filtering out the gravity pull.
    Yeah, I actually modified your script a bit and added bools to toggle matching along X/Y/Z axes. If a given axis bool is false, then that component of the newAcceleration vector gets set to 0. I did this to 'turn off' matching on the Y axis, since I'm not really interested in altitude changes of the user's head - just lateral motion forward/backward/left/right.

    Try working with the raw frame.acceleration and let me know what you find.

    I tried this a bit today, with inconclusive results - although I did realise that turning the Frames appears to generate a linear acceleration because when you turn them sideways / downwards, gravity starts pulling them along whatever axis you happen to have pointed downwards :)

    I'm going to give it another try soon, but I think for our purposes we might just give up and use pedometer and heading if we can't figure out how to do anything useful with the accelerometer.
  • Michael@Bose[email protected] Member Posts: 66
    Hi @prehensile - I'll tell you this, if you figure out a way to essentially create a virtual pedometer using just the accelerometer on board Bose AR devices, including QC 35 IIs, Frames and the new 700s, then you will have solved a major problem not just for Bose AR developers but a lot of folks who have worked with mobile accelerometers for years - it's one of the reasons smartphone-based VR such as Gear VR, Google Daydream, Cardboard and others have only ever supported 3-DOF (3 degrees of freedom) without the use of extra attachments or some hardcore computer vision leveraging the cameras. It's also a reason indoor positioning systems are such a tough nut to crack. Wishing you happy hunting on this front!

    Also, if using pedometer from the phone with heading from the Bose AR devices gets you to the solution you're looking for, please don't hesitate to reply to this thread - that would be an impressive and useful breakthrough as well. 

    Michael @ Bose
  • prehensileprehensile Member Posts: 11
    Heh, OK @[email protected], point taken :) I'm new to VR/AR development, so naively assumed that a linear accelerometer was all it would take! I can see that the wrinkles I was starting to find are the tip of a very old and complex iceberg that I think I'll just leave alone!

    We're adjusting our expectations and amending our prototype to work within the tolerances of GPS.
Sign In or Register to comment.