forked from Archive/PX4-Autopilot
Make the equal value threshold configurable
This commit is contained in:
parent
00dbffe11d
commit
75520641a5
|
@ -57,6 +57,7 @@ DataValidator::DataValidator(DataValidator *prev_sibling) :
|
|||
_value{0.0f},
|
||||
_vibe{0.0f},
|
||||
_value_equal_count(0),
|
||||
_value_equal_count_threshold(VALUE_EQUAL_COUNT_DEFAULT),
|
||||
_sibling(prev_sibling)
|
||||
{
|
||||
|
||||
|
@ -136,7 +137,7 @@ DataValidator::confidence(uint64_t timestamp)
|
|||
ret = 0.0f;
|
||||
|
||||
/* we got the exact same sensor value N times in a row */
|
||||
} else if (_value_equal_count > VALUE_EQUAL_COUNT_MAX) {
|
||||
} else if (_value_equal_count > _value_equal_count_threshold) {
|
||||
_error_mask |= ERROR_FLAG_STALE_DATA;
|
||||
ret = 0.0f;
|
||||
|
||||
|
|
|
@ -138,6 +138,13 @@ public:
|
|||
*/
|
||||
void set_timeout(uint32_t timeout_interval_us) { _timeout_interval = timeout_interval_us; }
|
||||
|
||||
/**
|
||||
* Set the equal count threshold
|
||||
*
|
||||
* @param threshold The number of equal values before considering the sensor stale
|
||||
*/
|
||||
void set_equal_value_threshold(uint32_t threshold) { _value_equal_count_threshold = threshold; }
|
||||
|
||||
/**
|
||||
* Get the timeout value
|
||||
*
|
||||
|
@ -170,10 +177,11 @@ private:
|
|||
float _value[dimensions]; /**< last value */
|
||||
float _vibe[dimensions]; /**< vibration level, in sensor unit */
|
||||
float _value_equal_count; /**< equal values in a row */
|
||||
float _value_equal_count_threshold; /**< when to consider an equal count as a problem */
|
||||
DataValidator *_sibling; /**< sibling in the group */
|
||||
static const constexpr unsigned NORETURN_ERRCOUNT = 10000; /**< if the error count reaches this value, return sensor as invalid */
|
||||
static const constexpr float ERROR_DENSITY_WINDOW = 100.0f; /**< window in measurement counts for errors */
|
||||
static const constexpr unsigned VALUE_EQUAL_COUNT_MAX = 100; /**< if the sensor value is the same (accumulated also between axes) this many times, flag it */
|
||||
static const constexpr unsigned VALUE_EQUAL_COUNT_DEFAULT = 100; /**< if the sensor value is the same (accumulated also between axes) this many times, flag it */
|
||||
|
||||
/* we don't want this class to be copied */
|
||||
DataValidator(const DataValidator&) = delete;
|
||||
|
|
|
@ -91,6 +91,18 @@ DataValidatorGroup::set_timeout(uint32_t timeout_interval_us)
|
|||
_timeout_interval_us = timeout_interval_us;
|
||||
}
|
||||
|
||||
void
|
||||
DataValidatorGroup::set_equal_value_threshold(uint32_t threshold)
|
||||
{
|
||||
DataValidator *next = _first;
|
||||
|
||||
while (next != nullptr) {
|
||||
next->set_equal_value_threshold(threshold);
|
||||
next = next->sibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DataValidatorGroup::put(unsigned index, uint64_t timestamp, float val[3], uint64_t error_count, int priority)
|
||||
{
|
||||
|
|
|
@ -118,12 +118,20 @@ public:
|
|||
void print();
|
||||
|
||||
/**
|
||||
* Set the timeout value
|
||||
* Set the timeout value for the whole group
|
||||
*
|
||||
* @param timeout_interval_us The timeout interval in microseconds
|
||||
*/
|
||||
void set_timeout(uint32_t timeout_interval_us);
|
||||
|
||||
/**
|
||||
* Set the equal count threshold for the whole group
|
||||
*
|
||||
* @param threshold The number of equal values before considering the sensor stale
|
||||
*/
|
||||
void set_equal_value_threshold(uint32_t threshold);
|
||||
|
||||
|
||||
private:
|
||||
DataValidator *_first; /**< sibling in the group */
|
||||
uint32_t _timeout_interval_us; /**< currently set timeout */
|
||||
|
|
Loading…
Reference in New Issue