commander: only play safety change tunes if initialized

This commit is contained in:
Daniel Agar
2021-05-26 13:35:06 -04:00
committed by Julian Oes
parent af71b2e3ab
commit ad534561d3

View File

@@ -1875,6 +1875,7 @@ Commander::run()
const bool safety_updated = _safety_sub.updated();
if (safety_updated) {
const bool previous_safety_valid = (_safety.timestamp != 0);
const bool previous_safety_off = _safety.safety_off;
if (_safety_sub.copy(&_safety)) {
@@ -1899,7 +1900,7 @@ Commander::run()
}
// Notify the user if the status of the safety switch changes
if (_safety.safety_switch_available && previous_safety_off != _safety.safety_off) {
if (previous_safety_valid && _safety.safety_switch_available && previous_safety_off != _safety.safety_off) {
if (_safety.safety_off) {
set_tune(tune_control_s::TUNE_ID_NOTIFY_POSITIVE);