mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-16 17:20:35 +08:00
commander: move ownership of vehicle_status_flags_s to HealthAndArmingChecks
This commit is contained in:
@@ -33,11 +33,10 @@
|
||||
|
||||
#include "HealthAndArmingChecks.hpp"
|
||||
|
||||
HealthAndArmingChecks::HealthAndArmingChecks(ModuleParams *parent, vehicle_status_flags_s &status_flags,
|
||||
vehicle_status_s &status)
|
||||
HealthAndArmingChecks::HealthAndArmingChecks(ModuleParams *parent, vehicle_status_s &status)
|
||||
: ModuleParams(parent),
|
||||
_context(status),
|
||||
_reporter(status_flags)
|
||||
_reporter(_failsafe_flags)
|
||||
{
|
||||
// Initialize mode requirements to invalid
|
||||
_failsafe_flags.angular_velocity_invalid = true;
|
||||
@@ -67,9 +66,10 @@ bool HealthAndArmingChecks::update(bool force_reporting)
|
||||
_checks[i]->checkAndReport(_context, _reporter);
|
||||
}
|
||||
|
||||
_reporter.finalize();
|
||||
const bool results_changed = _reporter.finalize();
|
||||
const bool reported = _reporter.report(_context.isArmed(), force_reporting);
|
||||
|
||||
if (_reporter.report(_context.isArmed(), force_reporting)) {
|
||||
if (reported) {
|
||||
|
||||
// LEGACY start
|
||||
// Run the checks again, this time with the mavlink publication set.
|
||||
@@ -97,10 +97,17 @@ bool HealthAndArmingChecks::update(bool force_reporting)
|
||||
_reporter.getHealthReport(health_report);
|
||||
health_report.timestamp = hrt_absolute_time();
|
||||
_health_report_pub.publish(health_report);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// Check if we need to publish the failsafe flags
|
||||
const hrt_abstime now = hrt_absolute_time();
|
||||
|
||||
if (now - _failsafe_flags.timestamp > 500_ms || results_changed) {
|
||||
_failsafe_flags.timestamp = now;
|
||||
_failsafe_flags_pub.publish(_failsafe_flags);
|
||||
}
|
||||
|
||||
return reported;
|
||||
}
|
||||
|
||||
void HealthAndArmingChecks::updateParams()
|
||||
|
||||
Reference in New Issue
Block a user