From 3b3752b753c09a587646505dd89f1d6b2de888f6 Mon Sep 17 00:00:00 2001 From: AnnaDaiZH <32288802+AnnaDaiZH@users.noreply.github.com> Date: Tue, 8 Jan 2019 20:25:39 +0100 Subject: [PATCH] pmw3901 increase publish rate and max_ground_distance (#11066) * increase pmw3901 publish rate and max_ground_distance * set work queue to high priority --- src/drivers/pmw3901/pmw3901.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/drivers/pmw3901/pmw3901.cpp b/src/drivers/pmw3901/pmw3901.cpp index 26a425faa2..5b68b57ec0 100644 --- a/src/drivers/pmw3901/pmw3901.cpp +++ b/src/drivers/pmw3901/pmw3901.cpp @@ -140,6 +140,8 @@ private: int _class_instance; int _orb_class_instance; + const uint64_t _collect_time = 15000; // usecs, optical flow data publish rate + orb_advert_t _optical_flow_pub; orb_advert_t _subsystem_pub; @@ -575,7 +577,8 @@ PMW3901::collect() _flow_sum_x += delta_x_raw; _flow_sum_y += delta_y_raw; - if (_flow_dt_sum_usec < 45000) { + // returns if the collect time has not been reached + if (_flow_dt_sum_usec < _collect_time) { return ret; } @@ -617,7 +620,7 @@ PMW3901::collect() // set (conservative) specs according to datasheet report.max_flow_rate = 5.0f; // Datasheet: 7.4 rad/s report.min_ground_distance = 0.1f; // Datasheet: 80mm - report.max_ground_distance = 5.0f; // Datasheet: infinity + report.max_ground_distance = 30.0f; // Datasheet: infinity _flow_dt_sum_usec = 0; _flow_sum_x = 0; @@ -679,7 +682,7 @@ PMW3901::start() _reports->flush(); /* schedule a cycle to start things */ - work_queue(LPWORK, &_work, (worker_t)&PMW3901::cycle_trampoline, this, USEC2TICK(PMW3901_US)); + work_queue(HPWORK, &_work, (worker_t)&PMW3901::cycle_trampoline, this, USEC2TICK(PMW3901_US)); /* notify about state change */ struct subsystem_info_s info = {}; @@ -718,7 +721,7 @@ PMW3901::cycle() collect(); /* schedule a fresh cycle call when the measurement is done */ - work_queue(LPWORK, + work_queue(HPWORK, &_work, (worker_t)&PMW3901::cycle_trampoline, this,