diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp index 228d5671c9..bc2cee9b43 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp @@ -77,7 +77,8 @@ bool PreFlightCheck::accelerometerCheck(orb_advert_t *mavlink_log_pub, vehicle_s if (exists) { uORB::SubscriptionData accel{ORB_ID(sensor_accel), instance}; - is_valid = (accel.get().device_id != 0) && (accel.get().timestamp != 0); + is_valid = (accel.get().device_id != 0) && (accel.get().timestamp != 0) + && (hrt_elapsed_time(&accel.get().timestamp) < 1_s); if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { is_calibration_valid = true; diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/baroCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/baroCheck.cpp index 004fffdf93..c30ddb9cd5 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/baroCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/baroCheck.cpp @@ -73,7 +73,7 @@ bool PreFlightCheck::baroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s & if (exists) { uORB::SubscriptionData baro{ORB_ID(sensor_baro), instance}; - valid = (baro.get().device_id != 0) && (baro.get().timestamp != 0); + valid = (baro.get().device_id != 0) && (baro.get().timestamp != 0) && (hrt_elapsed_time(&baro.get().timestamp) < 1_s); } if (instance == 0) { diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp index 590445c0fa..0f330969fa 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp @@ -75,7 +75,8 @@ bool PreFlightCheck::gyroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s & if (exists) { uORB::SubscriptionData gyro{ORB_ID(sensor_gyro), instance}; - is_valid = (gyro.get().device_id != 0) && (gyro.get().timestamp != 0); + is_valid = (gyro.get().device_id != 0) && (gyro.get().timestamp != 0) + && (hrt_elapsed_time(&gyro.get().timestamp) < 1_s); if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { is_calibration_valid = true; diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp index 338120b306..fe0f803a97 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp @@ -76,19 +76,20 @@ bool PreFlightCheck::magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_st if (exists) { uORB::SubscriptionData magnetometer{ORB_ID(sensor_mag), instance}; - is_valid = (magnetometer.get().device_id != 0) && (magnetometer.get().timestamp != 0); + const sensor_mag_s &mag_data = magnetometer.get(); + is_valid = (mag_data.device_id != 0) && (mag_data.timestamp != 0) && (hrt_elapsed_time(&mag_data.timestamp) < 1_s); if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { is_calibration_valid = true; } else { - is_calibration_valid = (calibration::FindCurrentCalibrationIndex("MAG", magnetometer.get().device_id) >= 0); + is_calibration_valid = (calibration::FindCurrentCalibrationIndex("MAG", mag_data.device_id) >= 0); } for (uint8_t i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) { uORB::SubscriptionData estimator_status_sub{ORB_ID(estimator_status), i}; - if (estimator_status_sub.get().mag_device_id == static_cast(magnetometer.get().device_id)) { + if (estimator_status_sub.get().mag_device_id == static_cast(mag_data.device_id)) { if (estimator_status_sub.get().control_mode_flags & (1 << estimator_status_s::CS_MAG_FAULT)) { is_mag_fault = true; break;