20

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.

4
  • 19
    +1 for correctly using the singular "datum." Dec 16, 2009 at 18:46
  • What are you trying to do? Also, are you sure that there aren't any hardware limitations?
    – Tom R
    Dec 30, 2009 at 14:50
  • There is no harware limitation because from the hardware i can read the acceleration datum every 1 ms. Jan 23, 2010 at 6:15
  • What are the IOCTLs implemented in your driver? Does it wait for a IOCTL from the userspace and in response to that then polls the accelerometer hardware? Nov 2, 2010 at 4:50

5 Answers 5

8

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.

3
  • 3
    Thanks for the reply and link. As i have have earlier posted i have solved this issue by writing a small .c file and read from the driver directly(I know the driver level code because its written by us). and then create a .so file from that .c file and use it my android application using jni. This will make the android application hardware dependent but thats not a issue for me. Thanks for the link once again It was usefull. Aug 24, 2010 at 17:25
  • 1
    @Naveen Murthy From curiosity, what speed did you get with your hardware dependent solution ?
    – m_vitaly
    Aug 29, 2012 at 6:47
  • 1
    @VitalyPolonetsky I was polling for sensor data every 5ms and i was getting new value every time. Aug 29, 2012 at 14:36
4

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.

0

Regarding the speed of the Android SensorManager, I would be more inclined to suspect the speed of the Android file I/O that is generating your log. You might try a benchmark of your sensor read code without writing to the log. Something like logging the current time in milliseconds, then doing 1,000,000 sensor reads, then logging the current time again. You might still have to use the C version to get the data, but at least you'll know definitively where the bottleneck lies.

0

There are a few issues I can see with this. The first is that you are most likely going to bog down the whole rest of the system if you try to force polling of sensor data that fast. If all you are doing is polling sensors that may be ok, but if you want any kind of user interaction, I am not sure that's going to work. Also, why do you need data that fast? If you're interacting with people there is no way there going to notice a lag of even 100ms.

2
  • 1
    It's about finding patterns in the data. Higher resolution allows better pattern matching.
    – Christian
    Nov 4, 2010 at 12:10
  • 1
    I want to make a application like free fall detection, which doesn't have any user interaction. It would be a service running in background. That's the reason i want to read the acceleration datum so fast. And as Chritian said higher resolution means better pattern matching. Nov 9, 2010 at 4:58
0

have you resolved your problem? i have a similar project, to get sample at least every 10 ms (about 100 Hz), here. But, nothing change in samples that i got, even when i set setEventRate = 10 milisec.

So i think there is any hardware limitation since i've read BMA220 datasheet (my sensor hardware) only provides 62,5 Hz for Orientation Sub-mode.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.