fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected (#29214)

* fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected

A sensor that starts publishing after the selector's init (e.g. the SITL
airspeed sim, which waits for a global position) was flagged stale on the
first cycle after detection: its last-update timestamp was still zero, so
the 1 s missing-data timeout fired before a single sample was read. With
ASPD_FS_T_START at its default of -1 the validator never recovers, the
selected source stays DISABLED and preflight reports "Airspeed invalid".

Seed the timestamp when a new sensor index is detected so the timeout
counts from detection. Also silence the DISABLED-to-sensor transition
message, which otherwise reports a spurious "healthy, start using again".

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Balduin <balduin@auterion.com>

* fix(airspeed_selector): only silence reporting when new sensor added

* fix(airspeed_selector): remove newly dead line

 - this time is always set check_for_connected_airspeed_sensors
 - there it depends on:
     - primary index set - otherwise nothing really happens
     - i >= _number_of_airspeed_sensors: always true on init

* test(mavsdk_tests): give the VTOL return with approaches 180 s to disarm

The flight from the end of the approach check to disarm takes about 155 s
of autopilot time, over the 150 s budget. The test only passed because
poll_condition_with_timeout checks elapsed time once per 15 s of autopilot
time and usually landed a check before the budget ran out; when the
lockstep sim ran slightly faster than the speed factor the disarm fell
inside a poll sleep and the test timed out at 158 s.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Balduin <balduin@auterion.com>

---------

Signed-off-by: Balduin <balduin@auterion.com>
This commit is contained in:
Balduin authored and GitHub committed 2026-10-14 13:20:58 +02:00
1 parent 1064bf28f7
commit 317a681cae
2 files changed
+8 -2

No files matched your search

@@ -316,7 +316,6 @@ AirspeedModule::init()
if (_airspeed_subs[i].copy(&airspeed)) {
_airspeed_device_id[i] = airspeed.device_id;
_time_last_airspeed_update[i] = _time_now_usec;
}
}
@@ -364,6 +363,10 @@ AirspeedModule::check_for_connected_airspeed_sensors()
break;
}
if (i >= _number_of_airspeed_sensors) {
_time_last_airspeed_update[i] = _time_now_usec; // newly detected: start stale-data timeout now
}
detected_airspeed_sensors = i + 1;
}
@@ -850,6 +853,9 @@ void AirspeedModule::select_airspeed_and_publish()
events::send(events::ID("airspeed_selector_estimation_valid"), events::Log::Info,
"Airspeed estimation valid");
} else if (_prev_airspeed_src == AirspeedSource::DISABLED && airspeed_sensor_added) {
// sensor detected after boot, nothing to report
} else {
mavlink_log_critical(&_mavlink_log_pub, "Airspeed sensor healthy, start using again (%i, %i)\t", prev_airspeed_index,
valid_airspeed_index);
+1 -1
View File
@@ -202,7 +202,7 @@ TEST_CASE("Return direct home with approaches", "[vtol]")
tester.arm();
tester.execute_rtl_when_reaching_mission_sequence(4);
tester.check_rtl_approaches(5., std::chrono::seconds(60));
tester.wait_until_disarmed(std::chrono::seconds(150));
tester.wait_until_disarmed(std::chrono::seconds(180));
tester.check_home_within(5.0f);
}