From ab4e10dc268b85a3bf1d48df72f06478bf52b4a2 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 21 Jun 2022 13:45:59 -0400 Subject: [PATCH] paa3905: update scaling from datasheet --- src/drivers/optical_flow/paa3905/PAA3905.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/drivers/optical_flow/paa3905/PAA3905.cpp b/src/drivers/optical_flow/paa3905/PAA3905.cpp index ede8687c8d..cd87391c84 100644 --- a/src/drivers/optical_flow/paa3905/PAA3905.cpp +++ b/src/drivers/optical_flow/paa3905/PAA3905.cpp @@ -603,8 +603,15 @@ void PAA3905::RunImpl() // rotate measurements in yaw from sensor frame to body frame const matrix::Vector3f pixel_flow_rotated = _rotation * matrix::Vector3f{(float)delta_x_raw, (float)delta_y_raw, 0.f}; - report.pixel_flow[0] = pixel_flow_rotated(0) / 500.0f; // proportional factor + convert from pixels to radians - report.pixel_flow[1] = pixel_flow_rotated(1) / 500.0f; // proportional factor + convert from pixels to radians + // datasheet provides 11.914 CPI (count per inch) scaling per meter of height + static constexpr float PIXART_RESOLUTION = 11.914f; // counts per inch (CPI) per meter (from surface) + static constexpr float INCHES_PER_METER = 39.3701f; + + // CPI/m -> radians + static constexpr float SCALE = 1.f / (PIXART_RESOLUTION * INCHES_PER_METER); + + report.pixel_flow[0] = pixel_flow_rotated(0) * SCALE; + report.pixel_flow[1] = pixel_flow_rotated(1) * SCALE; } report.timestamp = hrt_absolute_time();