Skip to content
Snippets Groups Projects
Commit f72e9e43 authored by ChristophTobler's avatar ChristophTobler Committed by Lorenz Meier
Browse files

pmw3901: set quality to zero if flow below threshold

parent a4a9b02f
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,7 @@
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <float.h>
#include <conversion/rotation.h>
......@@ -601,7 +602,15 @@ PMW3901::collect()
report.integration_timespan = _flow_dt_sum_usec; //microseconds
report.sensor_id = 0;
report.quality = 255;
// This sensor doesn't provide any quality metric. However if the sensor is unable to calculate the optical flow it will
// output 0 for the delta. Hence, we set the measurement to "invalid" (quality = 0) if the values are smaller than FLT_EPSILON
if (fabsf(report.pixel_flow_x_integral) < FLT_EPSILON && fabsf(report.pixel_flow_y_integral) < FLT_EPSILON) {
report.quality = 0;
} else {
report.quality = 255;
}
/* No gyro on this board */
report.gyro_x_rate_integral = NAN;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment