question

Amazon Customer avatar image
Amazon Customer asked

Kindle Fire HD 7" - accelerometer problems

Hi, I'm trying to get the accelerometer data from the Fire HD 7". The code looks like: float[] orientation = new float[3]; synchronized (this) { switch (ev.sensor.getType()) { case Sensor.TYPE_MAGNETIC_FIELD: mMagneticValues = ev.values.clone(); break; case Sensor.TYPE_ACCELEROMETER: mAccelerometerValues = ev.values.clone(); break; } if (mMagneticValues != null && mAccelerometerValues != null) { float[] R = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; boolean success = SensorManager.getRotationMatrix(R, null, mAccelerometerValues, mMagneticValues); if (success) { SensorManager.getOrientation(R, orientation); float tiltX = (float) Math.toDegrees(orientation[0]); float tiltY = (float) Math.toDegrees(orientation[1]); float tiltZ = (float) Math.toDegrees(orientation[2]); I get both magnetic field and accelerometer events, but the magnetic field values all seem to be zero, so the getRotationMatrix always returns failure. Any ideas on how you are meant to get usable accelerometer tilt data on the Kindle Fire HD 7"?
fire tablet
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anshul@Amazon avatar image
Anshul@Amazon answered
That's a very good question. We are looking into this and will get back to you once we have an update.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anshul@Amazon avatar image
Anshul@Amazon answered
The Kindle HD 7" does not have a magnetic sensor. You can use the raw accelerometer sensor to get the tilt. Please apply some filtering on the raw event to get more reliable readings. Here is some sample code taken from the platform for determining tilts. private static final float RADIANS_TO_DEGREES = (float) (180 / Math.PI); @Override public void onSensorChanged(SensorEvent event) { // The vector given in the SensorEvent points straight up (towards the sky) under ideal // conditions (the phone is not accelerating). I'll call this up vector elsewhere. float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; final float magnitude = (float) Math.sqrt(x * x + y * y + z * z); // Calculate the tilt angle. // This is the angle between the up vector and the x-y plane (the plane of // the screen) in a range of [-90, 90] degrees. // -90 degrees: screen horizontal and facing the ground (overhead) // 0 degrees: screen vertical // 90 degrees: screen horizontal and facing the sky (on table) final int tiltAngle = (int) Math.round( Math.asin(z / magnitude) * RADIANS_TO_DEGREES); // Calculate the orientation angle. // This is the angle between the x-y projection of the up vector onto // the +y-axis, increasing clockwise in a range of [0, 360] degrees. int orientationAngle = (int) Math.round( -Math.atan2(-x, y) * RADIANS_TO_DEGREES); } } Hope this solves your problem.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Amazon Customer avatar image
Amazon Customer answered
Hi, I was aware that using the orientation sensor is a way of getting tilt, but I believe the code I am using is what Google recommend for Android Developers. I have to write code which works on a range of devices and the Fire HD is claiming it has a magnetic sensor: Using : Sensor mag = mSensorManager .getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); The FireHD isn't returning null, in fact it is returning: mag.mName = MPL magnetic field msg.mVendor = Invensense So it is claiming to generic code that it has a sensor, which is confirmed by the fact it actually sends the magnetic field events (as zeros). If the Fire HD doesn't have a magnetic sensor, then this needs to be fixed so it doesn't claim to have a sensor, or supporting it will be a nightmare... it already claims it has a GPS too...
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anshul@Amazon avatar image
Anshul@Amazon answered
Thank you for the post. We are aware of the magnetic sensor issue. This is been actively worked on.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bob H. avatar image
Bob H. answered
Hi, Thanks for at least being aware of the problem, but is there a fix on the way? This is very frustrating and does affect a fair amount of apps that are unplayable with this issue. It also would be a good idea to let customer service know of the issue as they sent me a new Fire HD (but of course it had the same issue). I have tried various ways to ask about the issue, but no one seems to know who should be the expert (and most don't even know what I am talking about).
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Anshul@Amazon avatar image
Anshul@Amazon answered
The magnetic sensor issue has been fixed and released in December last year. Querying for a magnetic sensor now correctly returns "null".
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.