Need to read android sensors really fast

前端 未结 5 1385
臣服心动
臣服心动 2021-02-05 07:55

Issue:-

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

My Approach:-

相关标签:
5条回答
  • 2021-02-05 08:10

    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.

    0 讨论(0)
  • 2021-02-05 08:12

    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 讨论(0)
  • 2021-02-05 08:13

    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 讨论(0)
  • 2021-02-05 08:18

    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.

    0 讨论(0)
  • 2021-02-05 08:20

    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 讨论(0)
提交回复
热议问题