mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
feat(gnss): warn before arming when the primary receiver is offline
A configured primary receiver, set with SENS_GNSS_PRIME or the moving base of a moving base pair, that doesn't publish leaves the vehicle on another receiver, and nothing said so before the switch event in flight. The sensors module reports it on sensors_status_gnss, also while no receiver publishes at all, and commander warns before arming. It doesn't block arming: the selection falls back to the other receiver, and a missing receiver blocks arming only when SYS_HAS_NUM_GNSS counts it, which the offline check already reports. Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
1 parent
4fbaa1ced2
commit
eef80e7fee
4 files changed
+52
No files matched your search
@@ -5,6 +5,7 @@
|
||||
uint64 timestamp # [us] Time since system start
|
||||
|
||||
uint32 device_id_selected # [-] Receiver that vehicle_gnss carries
|
||||
bool primary_offline # A primary receiver is configured and is not publishing
|
||||
|
||||
uint8 MAX_RECEIVERS = 4 # Length of the per-receiver arrays
|
||||
|
||||
|
||||
@@ -182,4 +182,19 @@ void GnssRedundancyChecks::checkAndReport(const Context &context, Report &report
|
||||
"GPS receivers disagree by {1:.1}m horizontally, {2:.1}m vertically",
|
||||
_divergence_h_m, _divergence_v_m);
|
||||
}
|
||||
|
||||
// The selection falls back to another receiver, so like any other receiver the primary blocks arming only when
|
||||
// SYS_HAS_NUM_GNSS counts it
|
||||
if (!context.isArmed() && status_valid && status.primary_offline) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* Another receiver, if any, is used until the primary one publishes.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* The primary receiver is set with <param>SENS_GNSS_PRIME</param>, or is the moving base of a moving base pair.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(NavModes::None, health_component_t::gps, events::ID("check_gnss_primary_offline"),
|
||||
events::Log::Warning, "Primary GNSS receiver offline");
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,9 @@ public:
|
||||
// Capture any GPS health issue regardless of log level (Warning or Error).
|
||||
_health_warning_gps = (reporter.healthResults().warning | reporter.healthResults().error) & health_component_t::gps;
|
||||
_can_arm_all_modes = reporter.armingCheckResults().can_arm == NavModes::All;
|
||||
_arming_warning_gps = reporter.armingCheckResults().warning & health_component_t::gps;
|
||||
_arming_error_gps = reporter.armingCheckResults().error & health_component_t::gps;
|
||||
_can_arm = reporter.armingCheckResults().can_arm;
|
||||
}
|
||||
|
||||
// The receivers report the given disagreement past the hysteresis time
|
||||
@@ -161,6 +164,9 @@ public:
|
||||
failsafe_flags_s _failsafe_flags{};
|
||||
bool _health_warning_gps{false};
|
||||
bool _can_arm_all_modes{false};
|
||||
bool _arming_warning_gps{false};
|
||||
bool _arming_error_gps{false};
|
||||
NavModes _can_arm{NavModes::None};
|
||||
GnssRedundancyChecks _check;
|
||||
};
|
||||
|
||||
@@ -492,3 +498,24 @@ TEST_F(GnssRedundancyChecksTest, StaleStatusDoesNotCount)
|
||||
runCheck();
|
||||
EXPECT_TRUE(_failsafe_flags.gnss_lost);
|
||||
}
|
||||
|
||||
// A configured primary receiver that is not publishing is a warning before arming, not a reason to refuse it.
|
||||
TEST_F(GnssRedundancyChecksTest, PrimaryOfflineWarnsBeforeArming)
|
||||
{
|
||||
publishGnss(1);
|
||||
runCheck();
|
||||
ASSERT_FALSE(_arming_warning_gps);
|
||||
const NavModes can_arm = _can_arm;
|
||||
|
||||
_status.primary_offline = true;
|
||||
publishGnss(1);
|
||||
runCheck();
|
||||
EXPECT_TRUE(_arming_warning_gps);
|
||||
EXPECT_FALSE(_arming_error_gps);
|
||||
EXPECT_EQ(_can_arm, can_arm);
|
||||
EXPECT_FALSE(_failsafe_flags.gnss_lost);
|
||||
|
||||
// in flight the switch away from it is reported instead
|
||||
runCheck(true);
|
||||
EXPECT_FALSE(_arming_warning_gps);
|
||||
}
|
||||
@@ -289,6 +289,10 @@ void VehicleGPSPosition::Run()
|
||||
// A receiver that stopped publishing still has to time out and lose availability when no other one publishes
|
||||
_gnss_selector.update(hrt_absolute_time());
|
||||
PublishStatus();
|
||||
|
||||
} else if (hasConfiguredPreference()) {
|
||||
// A configured primary is reported offline even when no receiver ever published
|
||||
PublishStatus();
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SENSORS_VEHICLE_GNSS_HEADING)
|
||||
@@ -505,6 +509,11 @@ void VehicleGPSPosition::PublishStatus()
|
||||
const matrix::Quatf attitude_q = (compare && _vehicle_attitude_sub.copy(&attitude)) ? matrix::Quatf(attitude.q)
|
||||
: matrix::Quatf();
|
||||
|
||||
if (hasConfiguredPreference()) {
|
||||
const int primary = resolvePreferredInstance();
|
||||
status.primary_offline = (primary < 0) || !publishing[primary];
|
||||
}
|
||||
|
||||
for (int i = 0; i < GPS_MAX_RECEIVERS; i++) {
|
||||
const GnssChecks &checks = _gnss_checks[i];
|
||||
const sensor_gnss_s &sample = _latest_sample[i];
|
||||
|
||||
Reference in new issue
Block a user