Google Cardboard VR sensors
Asked Answered
D

3

17

I'm using the Google Cardboard (its HeadTracker class) to detect certain things about device rotation in an AR application. It works very well.

However, on some devices, it doesn't work (nothing happens). I assume this is because they don't have the necessary sensors. My questions:

1) I want to detect at runtime whether the current device supports the HeadTracker, i.e. it has the necessary sensors available. For this, I need to know which sensors are used by HeadTracker, so that I can query if those sensors are present. What are these sensors?

2) Is there a way to specify the necessary sensors in AndroidManifest? As far as I can see, there is no way. Therefore, if a user downloads my app, the app will have to inform the user at runtime that his device is not supported. This is not nice. Any thoughts?

Denmark answered 7/11, 2014 at 1:25 Comment(3)
i am doing this type of task..but not getting success.. can you assist me..? i have done, create a VR-surface and set image in it before. but i want this image work with head movement. how can i do this..Crash
I assume you already have uses-feature android:glEsVersion="0x00020000" in your manifest? Can you elaborate on "nothing happens"? You mean you do not get any accelerometer data?Commercialize
Yes, there were no data.Denmark
R
17

Google cardboard's website has a device compatibility list: It seems somewhat incomplete, so I tried taking a look into Cardboard.jar's source code. HeadTracker.java seems to have the following logic:

SensorManager sensorManager = (SensorManager)HeadTracker.this.mContext.getSystemService("sensor");

for (int sensorType : HeadTracker.INPUT_SENSORS) {
  Sensor sensor = sensorManager.getDefaultSensor(sensorType);
  sensorManager.registerListener(HeadTracker.this.mSensorEventListener, sensor, 0, handler);
}

With INPUT_SENSORS defined in the same file as

{TYPE_ACCELEROMETER, TYPE_GYROSCOPE};

I'm not sure if HeadTracker can work on phones with only one of those sensors. My guess is that both are necessary.

your app can require certain censors in order to run (or even be visible on the android market) with the following lines in your manifest:

<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true" />

you can also check if the sensors are available to your app at runtime using SensorManager's public Sensor getDefaultSensor (int type) function.

Rea answered 15/11, 2014 at 12:49 Comment(3)
It helped a lot, thank you. Sorry that I missed the bounty deadline (I was away yesterday), so it seems to have been auto-awarded by the system.Denmark
Though it listens to accelerometer however get predicted gl matrix seems to used last gyro values which will be always zero if device is no having gyro. let me know if you got cardboard app working only with accelero meterMicrocircuit
you posted wrong link on compatibility list. Where i could find this list?Poff
R
7

The google Cardboard headset won't work with just the accelerometer, it needs the gyro.

The accelerometer can detect forces applied to the phone. That includes reading the Earth's gravitational pull, so the phone can estimate where "down" is. But the accelerometer can't tell you percisely what your orientation in 3d space is, it can only approximate that basing on the forces it read.

That's far too low accuracy for VR, so that's why you need a gyroscope.

If you are dead set on making it work on your non-gyro phone, you can write a piece of your own code approximating phone orientation basing on accelerometer data, but keep in mind it will be very far from a really satisfying VR experience.

Recess answered 9/3, 2015 at 10:6 Comment(0)
D
0

Use Fibrum SDK if you want your game working with no gyro phones

for example try

Space X Hunter VR :

https://play.google.com/store/apps/details?id=com.creation3d.spacexhuntervr

VR Bowl :

https://play.google.com/store/apps/details?id=com.creation3d.vrbowl

and the games from Fibrum

Damali answered 17/3, 2016 at 1:44 Comment(1)
Welcome to Stack Overflow! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.Bowrah

© 2022 - 2024 — McMap. All rights reserved.