|
|
|
@ -76,19 +76,20 @@ bool PreFlightCheck::magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_st
@@ -76,19 +76,20 @@ bool PreFlightCheck::magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_st
|
|
|
|
|
if (exists) { |
|
|
|
|
uORB::SubscriptionData<sensor_mag_s> 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_s> estimator_status_sub{ORB_ID(estimator_status), i}; |
|
|
|
|
|
|
|
|
|
if (estimator_status_sub.get().mag_device_id == static_cast<uint32_t>(magnetometer.get().device_id)) { |
|
|
|
|
if (estimator_status_sub.get().mag_device_id == static_cast<uint32_t>(mag_data.device_id)) { |
|
|
|
|
if (estimator_status_sub.get().control_mode_flags & (1 << estimator_status_s::CS_MAG_FAULT)) { |
|
|
|
|
is_mag_fault = true; |
|
|
|
|
break; |
|
|
|
|