Depending on which sensors you're working with (e.g. Acceleration + Magnetic Field), I've had sensitivity issues in the past. The composite sensors (the suitable one in this case might be RotationVector) produce a much better output, especially for azimuth, in that they integrate several of the sensor measurements together.
AZIMUTH reading too sensitive on Sony Xperia phone updated with android OS 4.3 even with low pass filter
-
18-10-2022 - |
문제
I am troubled with the too sensitive sensor reading issue with SONY Xperia phone loaded with android OS 4.3 .
My compass orientation and azimuth reading has no issue at all with Samsung Note 3 or S3 galaxy even without low pass filter algorithm .
When loaded to the SONY xperia phone Z series , the compass kept spinning non-stop even when I have applied the low pass filter algorithm ,something I could not understand was it due to recent os update 4.3 or the sensor in sony phone was just far too sensitive?
I have even apply a seek bar to enable the value of ALPHA to be adjusted varies from 1 to 0 and that still does not help at all .
protected float[] lowPass( float[] input, float[] output ) { if ( output == null ) return input;
for ( int i=0; i<input.length; i++ ) {
output[i] = output[i] + ALPHA * (input[i] - output[i]);
}
return output;
}
Any help or comment are very much appreciated.
해결책
다른 팁
Thanks for the feedback ,
I do apply the suggested default acceleration + magnetic filed , and then the usual get orientation to obtain the azimuth , the funny thing is it works on all the samsung phone which I guess they properly apply some form of algorithm using the Invensense sensor , whereas in sony phone , such algorithm may be different or not presence .I will try the rotationvector to see if this solve the issue or not especially I also noticed the magnetic reading is also a bit strange on the sony phone on horizontal plane.
App will ensure tgat the phone is to be place in horizontal position before taking reading as such I think gyroscope input may not be needed, although this may be a solution to help to improve the raw sensor data processing as long as it works on SONY.
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
//valuesAccelerometer = (float[]) event.values.clone();
valuesAccelerometer = lowPass(event.values.clone(), valuesAccelerometer);
/*
* for (int i=0;i<3;i++){ valuesAccelerometer[i]=event.values[i] ;
*
* }
*/
break;
case Sensor.TYPE_MAGNETIC_FIELD:
//valuesMagneticField = (float[]) event.values.clone();
valuesMagneticField = lowPass(event.values.clone(), valuesMagneticField);
/*
* for (int i=0;i<3;i++){ valuesMagneticField[i]=event.values[i];
*
* }
*/
break;
}
if (valuesAccelerometer != null & valuesMagneticField != null) {
boolean success = SensorManager.getRotationMatrix(matrixR, matrixI,
valuesAccelerometer, valuesMagneticField);
// txt_read.setText(String.valueOf(success));
if (success) {
SensorManager.getOrientation(matrixR, matrixValues);
azimuth = Math.toDegrees(matrixValues[0]);
// azimuth=matrixValues[0];
float vaz = new Float(azimuth);
// float degree = Math.round(event.values[0]);
pitch = Math.toDegrees(matrixValues[1]);
roll = Math.toDegrees(matrixValues[2]);
for (int i = 0; i < 3; i++) {
valuesMagneticField[i] = event.values[i];
}