tags:

views:

655

answers:

4

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.

A: 

Hi Did you manage to read out the sensors fast? Do you have an application on Market? I also want to be able to just log values from the sensors as fast as possible and I have not found any good application so far so I'm thinking of doing an application myself but if you have one it's maybe better to get/buy that one. Regards Patrik

yes i managed to read the sensor data at 5 ms, but not through the SensorManager api provided by android. I know my hardware dirvers and all the ioctl exposed by driver, so i wrote a simple .c file with all the api to read the sensor data directly from the sensor driver and genrate .so from it. Then i use this .so file in my android appication to read the sensor values. This will make the application hardware dependent, but that's not a issue to me.
Naveen Murthy
That sounds interesting. Could you tell us more about how you did this or share the source code? I have an application that could possibly profit from this.
pableu
A: 

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.

+3  A: 

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.

robinr
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.
Naveen Murthy