问题
I have been using a Samsung Galaxy S3 to work on an app that uses the barometer estimate the user's altitude. I use SensorManager.getAltitude(p0, p), and set p0 equal to the sea-level pressure reported at the nearest airport. I set p equal to the value returned by the barometer.
Unfortunately, the altitude returned is systematically 20 meters or so higher than what it actually is. I'm certain that the barometer is returning pressure values that are too low, so SensorManager.getAltitude is returning a higher altitude. I've even driven to an airport from which I have gotten the sea-level pressures and laid my phone level with the runway, to prove this point.
When checking the accuracy of the barometer (with the accuracy field of the SensorEvent), it returns a value of zero, which means "the sensor cannot be trusted" or "calibration is needed" (https://developer.android.com/reference/android/hardware/SensorManager.html#SENSOR_STATUS_UNRELIABLE).
Specifically, my questions are:
Is this normal? I don't have another device with a barometer, so I can't check. How does the phone determine it's sensor "cannot be trusted"?
Is there any way to calibrate the sensor? Ideally, I could check the accuracy of a user's barometer, and then calibrate it (assuming I knew how much the barometric values were off by).
回答1:
The method I use for calibrating is to adjust P0 to get the altitude to match the known altitude at the calibration point. I use various methods to get the known altitude but the most automatic is to get a gps position and then use one of the online services to look up the altitude.
With this sort of methodology I don't have to worry too much about the barometer absolute accuracy. if the pressure always reads high by 0.5% that is not really relevant. So long as I can get relatively stable readings when stationary I am happy. I apply various bits of filtering especially when calculating cumulative ascent and descent numbers which I believe are the most important stats I gather for my users.
来源:https://stackoverflow.com/questions/17871735/android-how-does-one-deal-with-inaccurate-baromters