Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

GoogleVR - Android, Camera Drift? Help!

Discussion in 'AR/VR (XR) Discussion' started by Spidlee, Apr 4, 2017.

  1. Spidlee

    Spidlee

    Joined:
    Aug 11, 2014
    Posts:
    15
    Hi Guys,

    I've got a VR app using google cardboard api. And for some reason, I would now and then experience a really bad camera drift where the engine, keeps spinning (trying to centre the camera?) and the user loses control.

    I've noticed the drift tends to be caused by maybe shaking the phone, or not using the phone upright, sometimes even from switching between VR enabled on/off.

    I'm not really sure in what direction I should even take to research this matter / resolve this. Help would be greatly appreciated!!

    Thanks guys!
     
    Dalton-Lima likes this.
  2. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    I've actually experienced something similar while developing a Daydream game. After the initial centering, there is sometimes a slow-dift of the camera while in game, which is nauseating. I'm using 5.6.0f3 with GVR 1.3.0.
     
  3. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Yeah I've also noticed slow drift in daydream, I thought Google would have cracked drift for daydream:

    All daydream ready phones have compass (i think) so GoogleVR could use that to totally remove drift, the only problem would be if users phones compass was not calibrated, perhaps that's why Google haven't implemented drift cancellation?
     
  4. Spidlee

    Spidlee

    Joined:
    Aug 11, 2014
    Posts:
    15
    Is there anything we can do to counter the drift? Any possible hacks / workarounds?
     
  5. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Yes, hack away:

    Make your GVR cam be a child of a helper object.

    This helper object is used as a pivot in Y axis of world space.

    Have this helper object slowly lerp based on compass heading signal.

    If users device does not have compass then don't do any lerp.

    Allow compass signal to settle for a few secs before reading it, use the first reading as your anchorYaw. lerp the helper to keep it at a constant yaw heading relative to the compass heading.

    Make the lerp very slow and proportional to lastFrameTime. Lerp only has to be fast enough to cancel the worst yaw, set it as low as you can get away with.

    I did this in a previous Android VR game I wrote.

    NOTE1:
    This scheme can cause worse drift problems if a user has a compass that is badly callibrated which gives erratic heading signal then a user that had relatively low drift may have worse (android compas should have low priority autocallib service running in OS bgnd but they dont!)

    NOTE2:
    Big can headphones can cause problems with this scheme, magnets screw up compass.