From f6b2a5a590be47d055b52f596be11c6c9abafaf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Benito=20Lamata?= Date: Sun, 1 Oct 2023 23:10:29 +0200 Subject: [PATCH] Fix confidence interval calculation --- EVC/LX/level_crossing.cpp | 2 +- EVC/Position/distance.cpp | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/EVC/LX/level_crossing.cpp b/EVC/LX/level_crossing.cpp index 4ddb1dc6..15cd58c9 100644 --- a/EVC/LX/level_crossing.cpp +++ b/EVC/LX/level_crossing.cpp @@ -32,7 +32,7 @@ void update_lx() for (auto it=level_crossings.begin(); it!=level_crossings.end(); ) { if (!it->lx_protected) { if (it->svl_replaced && d_minsafefront(it->start) < it->start.min+it->length) inform_lx = true; - if (V_est == 0 && it->stop && d_estfront > it->start.est-it->stoplength) { + if (!it->svl_replaced && V_est == 0 && it->stop && d_estfront > it->start.est-it->stoplength) { it->svl_replaced = distance::from_odometer(d_estfront_dir[odometer_orientation == -1]); calculate_SvL(); } diff --git a/EVC/Position/distance.cpp b/EVC/Position/distance.cpp index ac21f58f..43f2870c 100644 --- a/EVC/Position/distance.cpp +++ b/EVC/Position/distance.cpp @@ -147,17 +147,11 @@ confidence_data confidence_data::basic() } dist_base d_maxsafe(const dist_base &d, const confidence_data &conf) { - if (d > conf.ref) - return conf.ref + (d-conf.ref)*1.01 + conf.locacc; - else - return conf.ref + (d-conf.ref)*0.99 + conf.locacc; + return d + std::abs(d-conf.ref)*0.01 + conf.locacc; } dist_base d_minsafe(const dist_base &d, const confidence_data &conf) { - if (d > conf.ref) - return conf.ref + (d-conf.ref)*0.99 - conf.locacc; - else - return conf.ref + (d-conf.ref)*1.01 - conf.locacc; + return d - std::abs(d-conf.ref)*0.01 + conf.locacc; } dist_base d_maxsafefront(const confidence_data &conf) {