From 32a70970187c021d3b00a78c220d9ea11c1976f5 Mon Sep 17 00:00:00 2001 From: Mohammed Kabir Date: Sat, 19 May 2018 11:22:03 -0400 Subject: [PATCH] px4flow : publish sensor limits over uORB --- src/drivers/px4flow/px4flow.cpp | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index beeba53d45..317cfbc801 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -143,7 +143,11 @@ private: perf_counter_t _comms_errors; unsigned _conversion_interval; + enum Rotation _sensor_rotation; + float _sensor_min_range; + float _sensor_max_range; + float _sensor_max_flow_rate; /** * Test whether the device supported by the driver is present at a @@ -267,7 +271,6 @@ PX4FLOW::init() /* get yaw rotation from sensor frame to body frame */ param_t rot = param_find("SENS_FLOW_ROT"); - /* only set it if the parameter exists */ if (rot != PARAM_INVALID) { int32_t val = 6; // the recommended installation for the flow sensor is with the Y sensor axis forward param_get(rot, &val); @@ -275,6 +278,34 @@ PX4FLOW::init() _sensor_rotation = (enum Rotation)val; } + /* get operational limits of the sensor */ + param_t hmin = param_find("SENS_FLOW_MINHGT"); + + if (hmin != PARAM_INVALID) { + float val = 0.7; + param_get(hmin, &val); + + _sensor_min_range = val; + } + + param_t hmax = param_find("SENS_FLOW_MAXHGT"); + + if (hmax != PARAM_INVALID) { + float val = 3.0; + param_get(hmax, &val); + + _sensor_max_range = val; + } + + param_t ratemax = param_find("SENS_FLOW_MAXR"); + + if (ratemax != PARAM_INVALID) { + float val = 2.5; + param_get(ratemax, &val); + + _sensor_max_flow_rate = val; + } + return ret; } @@ -536,6 +567,12 @@ PX4FLOW::collect() report.sensor_id = 0; + report.max_flow_rate = _sensor_max_flow_rate; + + report.min_ground_distance = _sensor_min_range; + + report.max_ground_distance = _sensor_max_range; + /* rotate measurements in yaw from sensor frame to body frame according to parameter SENS_FLOW_ROT */ float zeroval = 0.0f;