Browse Source

AP_Compass: reject outlier data in IST8310 data by detecting >14bit data

master
Tom Pittenger 8 years ago committed by Andrew Tridgell
parent
commit
c0691afc1f
  1. 15
      libraries/AP_Compass/AP_Compass_IST8310.cpp

15
libraries/AP_Compass/AP_Compass_IST8310.cpp

@ -176,13 +176,22 @@ void AP_Compass_IST8310::timer() @@ -176,13 +176,22 @@ void AP_Compass_IST8310::timer()
return;
}
_last_measurement_usec = now;
start_conversion();
auto x = static_cast<int16_t>(le16toh(buffer.rx));
auto y = static_cast<int16_t>(le16toh(buffer.ry));
auto z = static_cast<int16_t>(le16toh(buffer.rz));
start_conversion();
// buffer data is 14bits. Check for invalid data and drop packet
if (x > 8191 || x < -8192 ||
y > 8191 || y < -8192 ||
z > 8191 || z < -8192) {
return;
}
_last_measurement_usec = now;
// flip Z to conform to right-hand rule convention
z = -z;

Loading…
Cancel
Save