4

In Android Documentation is specified the third parameter as

float[] gravity 

then is specifies

[0 0 g] = R * gravity (g = magnitude of gravity)

Now, in most of the examples online I can see everyone sending accelerometer values to getRotationMatrix, but, Isn't suppose that I should send only gravity values?

For example, if the mobile phone has the gravity sensor, Should I send it raw output to getRotationMatrix? If it hasn't one, Should I send accelerometer values? Should I extract non gravity components first? (as accelerometer values are Acceleration minus G).

Will the use of gravity sensor values be more reliable than using accelerometer values in mobile phones that have that sensor?

Thanks in advance! Guillermo.

polonskyg
  • 4,269
  • 9
  • 41
  • 93

1 Answers1

1

I think the reason you only see examples using the accelerometer values is because the gravity sensor was only launched in API 9 and also because most phones might not give this values separated from the accelerometer values, or dont have the sensor, etc, etc..

Another reason would be because in most of the cases the result tend to be the same, since what the accelerometer sensor outputs is the device linear acceleration plus gravity, but most of the time the phone will be standing still or even moving at a constant velocity, thus the device acceleration will be zero.

From the setRotationMatrix Android Docs:

The matrices returned by this function are meaningful only when the device is not free-falling and it is not close to the magnetic north. If the device is accelerating, or placed into a strong magnetic field, the returned matrices may be inaccurate.

Now, you're asking if the gravity data would me more reliable? Well, there is nothing like testing, but I suppose it wouldn't make much difference and it really depends on which application you want. Also, obtaining the simple gravity values is not trivial and it requires filtering, so you could end up with noisy results.

MobileCushion
  • 7,065
  • 7
  • 42
  • 62
  • Regarding the second reason, if I want to get the rotation matrix I assume the user is rotating the device and not in a constant velocity, thus it should have acceleration, right? Am I missing something? getRotationMatrix() only says that acceleration should be sent as parameter but it doesn't specify which acceleration, kind of weakness in the documentation... Getting Gravity values is easy as there is a Gravity sensor (in the case one have a cellphone with it). Thanks for you answer! – polonskyg Feb 02 '12 at 19:17
  • I am not sure how the Gravity sensor values are obtained, but I seriously doubt there is another sensor in the device. Maybe the values are obtained from the accelerometer sensor as it is says in the documentation, I am speculating though. – MobileCushion Feb 03 '12 at 11:12
  • I think it's a fuse sensor, but it might have different filters applied, like kalman filter retrieving better results. That's why I'm asking, but I don't know. – polonskyg Feb 03 '12 at 13:08