Android magnetometer sample rate improvement / jitter reduction

I would like to ask for some help regarding the sampling rate and jitter on the magnetometer. I am working on a project with some people who use a magnetic field measurement application with high speed. Despite the fact that we developed an algorithm to solve the jitter problem and other problems that we encountered, we would like to somehow improve the estimation of the sample and, if necessary, try to reduce the jitter of the sample. Improving the sampling rate will allow us to achieve better results for our application. We use the Samsung Nexus S, and in accordance with our tests, we observe that the sampling rate is from 15 ms to 20 ms, and sometimes peaks around 50 ms (this happens between consecutive events).

We came up with different approaches in order to try to develop a solution to these problems, but without any success. Firstly, we thought about modifying the device driver for the current magnetometer (AK8973), but soon we realized that the bottleneck could not be there, since the device driver directly implements the correct sensor operating modes, reads data and respects the sensor hardware time limits. As a second alternative, we developed a small code using the Android NDK to obtain samples for comparing the time obtained between successive events, that is, between samples, with code developed at the Java level. Unfortunately, the result was almost the same. As a final alternative, we are currently trying to understand how events are handled by the API and passed in Java. However, if there is a bottleneck, we will try to change the code to solve the problems. However, we are not sure if the bottleneck is in the underlying hardware or software API.

The code we used for the NDK is based on an example provided by the Android documentation (NativeActivity) and some other examples that we came across with googling (google groups and other articles). The articles we found are pretty interesting ( Custom Sample, Sensor Sample Performance ). Despite the fact that it is reported that native sampling can improve performance, in our case this does not seem to be happening.

We would like to know if a higher sampling rate can be obtained at all, or if someone has already developed a solution. Is a software or hardware bottleneck? The articles mentioned above mention that a user library (FreeMotion) can provide better results as a replacement for the original sensor library, since it works directly with drivers. Has anyone used this library before and, if so, could you provide us with your results?

+4
source share
1 answer

Using another Samsung Galaxy Nexus smartphone, we decided to collect more samples of magnetometer data and conduct statistical analysis and compare the results obtained with the Samsung Nexus S. This time we used Android v4.1.2. Again, we noticed that the speed with which we can collect data does not improve significantly when comparing the NDK and SDK API with both smartphones, using values ​​from ASensor_getMinDelay() and SENSOR_DELAY_FASTEST , respectively, which gives maximum performance. However, reducing jitter is very important for both smartphones with the NDK API, regardless of the approach used: polling or callback. The survey, in general, provides little or no better results and should be more intense with the CPU.

The hardware of the Samsung Galaxy Nexus is far superior, and thus, it is possible to fine-tune the desired frequency of events, of course, that the bids exceed ASensor_getMinDelay() . However, for Samsung Nexus S it was impossible; at lower rates, the target speed is not met, and samples are acquired at an even lower rate. When several sensors are activated, the overall jitter reduction is greater than when using only one sensor.

+1
source

Source: https://habr.com/ru/post/1435968/


All Articles