Better localizer unstable alert (#21660)

* use canonical language

* filter out when gps signal is flaky

* Update selfdrive/locationd/locationd.cc

Co-authored-by: Willem Melching <willem.melching@gmail.com>

Co-authored-by: Willem Melching <willem.melching@gmail.com>
pull/21669/head
HaraldSchafer 4 years ago committed by GitHub
parent ced26b806f
commit 049a1bca34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      selfdrive/controls/lib/events.py
  2. 11
      selfdrive/locationd/locationd.cc
  3. 1
      selfdrive/locationd/locationd.h

@ -545,7 +545,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
# current GPS position. This alert is thrown when the localizer is reset # current GPS position. This alert is thrown when the localizer is reset
# more often than expected. # more often than expected.
EventName.localizerMalfunction: { EventName.localizerMalfunction: {
ET.PERMANENT: NormalPermanentAlert("Localizer unstable", "Contact Support"), ET.PERMANENT: NormalPermanentAlert("Sensor Malfunction", "Contact Support"),
}, },
# ********** events that affect controls state transitions ********** # ********** events that affect controls state transitions **********

@ -372,7 +372,11 @@ void Localizer::time_check(double current_time) {
void Localizer::update_reset_tracker() { void Localizer::update_reset_tracker() {
// reset tracker is tuned to trigger when over 1reset/10s over 2min period // reset tracker is tuned to trigger when over 1reset/10s over 2min period
if (this->isGpsOK()) {
this->reset_tracker *= .99995; this->reset_tracker *= .99995;
} else {
this->reset_tracker = 0.0;
}
} }
void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd init_pos) { void Localizer::reset_kalman(double current_time, VectorXd init_orient, VectorXd init_pos) {
@ -427,6 +431,11 @@ kj::ArrayPtr<capnp::byte> Localizer::get_message_bytes(MessageBuilder& msg_build
return msg_builder.toBytes(); return msg_builder.toBytes();
} }
bool Localizer::isGpsOK() {
return this->kf->get_filter_time() - this->last_gps_fix < 1.0;
}
int Localizer::locationd_thread() { int Localizer::locationd_thread() {
const std::initializer_list<const char *> service_list = const std::initializer_list<const char *> service_list =
{ "gpsLocationExternal", "sensorEvents", "cameraOdometry", "liveCalibration", "carState" }; { "gpsLocationExternal", "sensorEvents", "cameraOdometry", "liveCalibration", "carState" };
@ -448,7 +457,7 @@ int Localizer::locationd_thread() {
uint64_t logMonoTime = sm["cameraOdometry"].getLogMonoTime(); uint64_t logMonoTime = sm["cameraOdometry"].getLogMonoTime();
bool inputsOK = sm.allAliveAndValid(); bool inputsOK = sm.allAliveAndValid();
bool sensorsOK = sm.alive("sensorEvents") && sm.valid("sensorEvents"); bool sensorsOK = sm.alive("sensorEvents") && sm.valid("sensorEvents");
bool gpsOK = (logMonoTime / 1e9) - this->last_gps_fix < 1.0; bool gpsOK = this->isGpsOK();
MessageBuilder msg_builder; MessageBuilder msg_builder;
kj::ArrayPtr<capnp::byte> bytes = this->get_message_bytes(msg_builder, logMonoTime, inputsOK, sensorsOK, gpsOK); kj::ArrayPtr<capnp::byte> bytes = this->get_message_bytes(msg_builder, logMonoTime, inputsOK, sensorsOK, gpsOK);

@ -31,6 +31,7 @@ public:
void finite_check(double current_time = NAN); void finite_check(double current_time = NAN);
void time_check(double current_time = NAN); void time_check(double current_time = NAN);
void update_reset_tracker(); void update_reset_tracker();
bool isGpsOK();
kj::ArrayPtr<capnp::byte> get_message_bytes(MessageBuilder& msg_builder, uint64_t logMonoTime, kj::ArrayPtr<capnp::byte> get_message_bytes(MessageBuilder& msg_builder, uint64_t logMonoTime,
bool inputsOK, bool sensorsOK, bool gpsOK); bool inputsOK, bool sensorsOK, bool gpsOK);

Loading…
Cancel
Save