Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uneven number of samples between Accelerometer, Gyro and Magnetometer on Android

I am developing an Android app that records the inertial data on a smartphone to then further processes it. Different Android devices have different behaviors depending on the firmware interfacing the inertial sensors to Android and that's crystal clear. One thing I cannot answer myself though is, how come only the moto g 2nd gen yet showed that when the app is recording I have significantly different numbers of sensors samples?

For example, few second of recording and I see:

  • ~6000 samples for the gyro

  • ~5200 samples for the acc

  • ~2000 samples for the magnetometer

Assume as well that the activity I am recording affects all sensors at all time and hence I'd expect the onSensorChange function to be called evenly. That happens for every other smartphone I tried (5 or 6 different ones).

Any suggestions how come the magnetos mostly seem to not change values as often as the other sensors in order for the onSensorChange to record it?

The obvious answer is because of the firmware, but do you have any idea how to mitigate the effect I am seeing?

Thanks folks!

like image 796
eykiriku Avatar asked Oct 31 '22 10:10

eykiriku


1 Answers

This question is really old, but I figured I'd answer it for the community's sake:

I work as an app developer at a startup that specializes in sensor processing on smartphones. We have a couple 2nd Gen Moto G's and we've found that they do a really bad job of giving uniform sampling rates both for one sensor as well as across sensors.

To mitigate the problems, we write a whole row of samples at once with the most recent data, every time we get a sample from the accelerometer. If a new sample hasn't come in on any other sensors since the last accelerometer sample, the same values get printed twice.

ie.)

Accel (3-axis) | Gyro (3-axis)
0,0,0|0,0,0
<new accelerometer sample>
1,1,1|0,0,0
<5 gyro samples and 1 accelerometer>
2,2,2|5,5,5
...

Anyways, hope this helps someone!

TLDR; The 2nd Gen Moto G has inconsistent sampling rates both for one sensor and across multiple sensors.

like image 140
Martin_xs6 Avatar answered Nov 15 '22 04:11

Martin_xs6