px4flow : publish sensor limits over uORB

This commit is contained in:
Mohammed Kabir 2018-05-19 11:22:03 -04:00 committed by Lorenz Meier
parent 230d6c5aa2
commit 32a7097018
1 changed files with 38 additions and 1 deletions

View File

@ -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;