validation: remove unused vibration metric

This commit is contained in:
Daniel Agar 2020-02-03 12:28:55 -05:00
parent e52e2b88ed
commit ed260c4f1d
6 changed files with 0 additions and 138 deletions

View File

@ -84,8 +84,6 @@ void DataValidator::put(uint64_t timestamp, const float val[dimensions], uint64_
}
}
_vibe[i] = _vibe[i] * 0.99f + 0.01f * fabsf(val[i] - _lp[i]);
// XXX replace with better filter, make it auto-tune to update rate
_lp[i] = _lp[i] * 0.99f + 0.01f * val[i];

View File

@ -125,12 +125,6 @@ public:
*/
float *rms() { return _rms; }
/**
* Get the vibration offset
* @return the stored vibration offset
*/
float *vibration_offset() { return _vibe; }
/**
* Print the validator value
*
@ -186,7 +180,6 @@ private:
float _M2[dimensions]{}; /**< RMS component value */
float _rms[dimensions]{}; /**< root mean square error */
float _value[dimensions]{}; /**< last value */
float _vibe[dimensions]{}; /**< vibration level, in sensor unit */
unsigned _value_equal_count{0}; /**< equal values in a row */
unsigned _value_equal_count_threshold{

View File

@ -214,52 +214,6 @@ float *DataValidatorGroup::get_best(uint64_t timestamp, int *index) {
return (best) ? best->value() : nullptr;
}
float DataValidatorGroup::get_vibration_factor(uint64_t timestamp) {
DataValidator *next = _first;
float vibe = 0.0f;
/* find the best RMS value of a non-timed out sensor */
while (next != nullptr) {
if (next->confidence(timestamp) > 0.5f) {
float *rms = next->rms();
for (unsigned j = 0; j < 3; j++) {
if (rms[j] > vibe) {
vibe = rms[j];
}
}
}
next = next->sibling();
}
return vibe;
}
float DataValidatorGroup::get_vibration_offset(uint64_t timestamp, int axis) {
DataValidator *next = _first;
float vibe = -1.0f;
/* find the best vibration value of a non-timed out sensor */
while (next != nullptr) {
if (next->confidence(timestamp) > 0.5f) {
float *vibration_offset = next->vibration_offset();
if (vibe < 0.0f || vibration_offset[axis] < vibe) {
vibe = vibration_offset[axis];
}
}
next = next->sibling();
}
return vibe;
}
void DataValidatorGroup::print() {
ECL_INFO("validator: best: %d, prev best: %d, failsafe: %s (%u events)", _curr_best, _prev_best,

View File

@ -75,20 +75,6 @@ public:
*/
float *get_best(uint64_t timestamp, int *index);
/**
* Get the RMS / vibration factor
*
* @return float value representing the RMS, which a valid indicator for vibration
*/
float get_vibration_factor(uint64_t timestamp);
/**
* Get the vibration offset in the sensor unit
*
* @return float value representing the vibration offset
*/
float get_vibration_offset(uint64_t timestamp, int axis);
/**
* Get the number of failover events
*

View File

@ -80,11 +80,7 @@ void test_init()
//verify that calling print doesn't crash tests
validator->print();
float *vibe_offset = validator->vibration_offset();
assert(0.0f == vibe_offset[0]);
delete validator; //force delete
}
void test_put()
@ -129,7 +125,6 @@ void test_put()
assert(DataValidator::ERROR_FLAG_TIMEOUT == (DataValidator::ERROR_FLAG_TIMEOUT & validator->state()));
delete validator; //force delete
}
/**
@ -160,7 +155,6 @@ void test_stale_detector()
assert(DataValidator::ERROR_FLAG_STALE_DATA == (DataValidator::ERROR_FLAG_STALE_DATA & state));
delete validator; //force delete
}
/**
@ -188,13 +182,7 @@ void test_rms_calculation()
(double)diff, (double)diff_frac);
assert(diff_frac < 0.03f);
float *vibe_offset = validator->vibration_offset();
float vibe_diff = fabsf(0.01005f - vibe_offset[0]); //TODO calculate this vibration value
printf("vibe: %f", (double)vibe_offset[0]);
assert(vibe_diff < 1E-3f);
delete validator; //force delete
}
/**
@ -309,7 +297,6 @@ int main(int argc, char *argv[])
test_stale_detector();
test_rms_calculation();
test_error_tracking();
//TODO verify vibration calculation
return 0; //passed
}

View File

@ -72,15 +72,6 @@ DataValidatorGroup *setup_base_group(unsigned *sibling_count)
assert(DataValidator::ERROR_FLAG_NO_ERROR == group->failover_state());
assert(-1 == group->failover_index());
//no vibration yet
float vibe_off = group->get_vibration_offset(base_timestamp, 0);
printf("vibe_off: %f \n", (double)vibe_off);
assert(-1.0f == group->get_vibration_offset(base_timestamp, 0));
float vibe_fact = group->get_vibration_factor(base_timestamp);
printf("vibe_fact: %f \n", (double)vibe_fact);
assert(0.0f == vibe_fact);
//this sets the timeout on all current members of the group, as well as members added later
group->set_timeout(base_timeout_usec);
//the following sets the threshold on all CURRENT members of the group, but not any added later
@ -91,7 +82,6 @@ DataValidatorGroup *setup_base_group(unsigned *sibling_count)
*sibling_count = num_siblings;
return group;
}
/**
@ -340,51 +330,6 @@ void test_simple_failover()
delete group; //cleanup
}
/**
* Verify that we get expected vibration values after injecting samples.
*/
void test_vibration()
{
unsigned num_siblings = 0;
uint64_t timestamp = base_timestamp;
DataValidatorGroup *group = setup_base_group(&num_siblings);
//now we add validators
DataValidator *validator = add_validator_to_group(group);
assert(nullptr != validator);
num_siblings++;
float *vibes = validator->vibration_offset();
assert(nullptr != vibes);
//printf("val vibes: %f \n", vibes[0]);
//should be no vibration data yet
assert(0 == vibes[0]);
float vibe_o = group->get_vibration_offset(timestamp, 0);
//printf("group vibe_o %f \n", vibe_o);
// there should be no known vibe offset before samples are inserted
assert(-1.0f == vibe_o);
float rms_err = 0.0f;
//insert some swinging values
insert_values_around_mean(validator, 3.14159f, 1000, &rms_err, &timestamp);
vibes = validator->vibration_offset();
assert(nullptr != vibes);
printf("val1 vibes: %f rms_err: %f \n", vibes[0], (double)rms_err);
vibe_o = group->get_vibration_offset(timestamp, 0);
printf("group vibe_o %f \n", vibe_o);
//the one validator's vibration offset should match the group's vibration offset
assert(vibes[0] == vibe_o);
//this should be "The best RMS value of a non-timed out sensor"
float group_vibe_fact = group->get_vibration_factor(timestamp);
float val1_rms = (validator->rms())[0];
printf("group_vibe_fact: %f val1_rms: %f\n", (double)group_vibe_fact, (double)val1_rms);
assert(group_vibe_fact == val1_rms);
}
/**
* Force once sensor to fail and ensure that we detect it
*/
@ -434,7 +379,6 @@ int main(int argc, char *argv[])
test_put();
test_simple_failover();
test_priority_switch();
test_vibration();
test_sensor_failure();
return 0; //passed