Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to read android sensors really fast

Tags:

Issue:-

  1. I am developing a application which needs a new acceleration datum every 5 millisecond.

My Approach:-

  1. I have created a remote service which only reads the acceleration data from SensorManager.
  2. I had also set the read rate to "DELAY FASTEST" while initialize the SensorManager.
  3. Then i use IPC to communicate too my main application to get these reading.

Problem:-

  1. If i put a log inside onSensorChange() event i receive a new sensor data every 20 ms time. But i need data every 5 ms.

Question ?

  1. Is there any better method to read the senor data faster.

  2. Is there any way i can poll the senor data rather that waiting for the event handler to trigger the event?

Please help me to find a better solution to read the data in 5 ms time or poll the acceleration data.

like image 446
Naveen Murthy Avatar asked Dec 16 '09 18:12

Naveen Murthy


People also ask

How can I see all sensors in Android?

Open the app and tap the Diagnostic button on the home screen. Tap the individual icons to run diagnostic tests on the battery, SIM card, sensors, touch screen, flashlight, camera, microphone, speaker, Bluetooth, Wi-Fi, and more. Alternatively, tap the Test all button to perform all the tests one after the other.

What is Android gyroscope?

The gyroscope measures the rate of rotation in rad/s around a device's x, y, and z axis.


2 Answers

As I understand it, the accelerometer is very noisy and not suitable for fast operations. See the GoogleTech talk on sensor fusion at http://www.youtube.com/watch?v=C7JQ7Rpwn2k for a more authorative explanation and what you can do about it. Short explanation: Use the gyro for high speed events and the acceleromenter to correct the drift.

like image 169
robinr Avatar answered Oct 14 '22 00:10

robinr


For people referencing this post today, while I think @robinr has a good point and is very true, that is not an answer, however stackoverflow wont let me comment on it directly.

For answers to the first question reference Native Activity. And. Android does not guarantee data rate, it only makes sure that you get the minimum (or maximum if you requesting too much).

The accelerometer is Not noisy, at least not today. Its just way too good at picking up EVERYTHING. So you need to use some filtering if you want a good accelerometer algorithm. If you have excellent filters, accelerometer is actually preferable to all else because it is usually a lower power sensor, has the highest supported frequency, and is most likely to be available when the screen is off(compared to other sensors).

The caveat to a forceful method of using native and extracting the highest frequency is that your device support will be limited. This is why Android doesn't support direct frequency settings.

In response to question 2; your going to have to throttle your sensor events manually by monitoring the timestamp.

like image 29
Andros Avatar answered Oct 13 '22 23:10

Andros