From 50b8ed0a89d2a6022cc518df65fa6bc57375f393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 20 Sep 2016 18:47:33 +0200 Subject: [PATCH] commander: initialize gps & baro as failure state This avoids error messages on startup. --- src/modules/commander/commander.cpp | 10 +++++++++- src/modules/commander/state_machine_helper.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 611cfd638d..f6b083d30c 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -1314,6 +1314,11 @@ int commander_thread_main(int argc, char *argv[]) status_flags.offboard_control_signal_found_once = false; status_flags.rc_signal_found_once = false; + /* assume we don't have a valid GPS & baro on startup */ + status_flags.gps_failure = true; + status_flags.barometer_failure = true; + status_flags.ever_had_barometer_data = false; + /* mark all signals lost as long as they haven't been found */ status.rc_signal_lost = true; status_flags.offboard_control_signal_lost = true; @@ -1833,7 +1838,10 @@ int commander_thread_main(int argc, char *argv[]) if (status_flags.barometer_failure) { status_flags.barometer_failure = false; status_changed = true; - mavlink_log_critical(&mavlink_log_pub, "baro healthy"); + if (status_flags.ever_had_barometer_data) { + mavlink_log_critical(&mavlink_log_pub, "baro healthy"); + } + status_flags.ever_had_barometer_data = true; } } else { diff --git a/src/modules/commander/state_machine_helper.h b/src/modules/commander/state_machine_helper.h index 1506ff8acb..44b468b6cd 100644 --- a/src/modules/commander/state_machine_helper.h +++ b/src/modules/commander/state_machine_helper.h @@ -92,6 +92,7 @@ struct status_flags_s { bool gps_failure; // Set to true if a gps failure is detected bool gps_failure_cmd; // Set to true if a gps failure mode is commanded bool barometer_failure; // Set to true if a barometer failure is detected + bool ever_had_barometer_data; // Set to true if ever had valid barometer data before }; bool is_safe(const struct vehicle_status_s *current_state, const struct safety_s *safety, const struct actuator_armed_s *armed);