mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-20 07:01:36 +08:00
arming checks: add health topic
This commit is contained in:
@@ -95,6 +95,7 @@ set(msg_files
|
||||
gimbal_manager_status.msg
|
||||
gps_dump.msg
|
||||
gps_inject_data.msg
|
||||
health_report.msg
|
||||
heater_status.msg
|
||||
home_position.msg
|
||||
hover_thrust_estimate.msg
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
uint64 timestamp # time since system start (microseconds)
|
||||
|
||||
uint64 can_arm_mode_flags # bitfield for each flight mode (NAVIGATION_STATE_*) if arming is possible
|
||||
uint64 can_run_mode_flags # bitfield for each flight mode if it can run
|
||||
|
||||
uint64 health_is_present_flags # flags for each health_component_t
|
||||
uint64 health_warning_flags
|
||||
uint64 health_error_flags
|
||||
# A component is required but missing, if present==0 and error==1
|
||||
|
||||
uint64 arming_check_warning_flags
|
||||
uint64 arming_check_error_flags
|
||||
|
||||
@@ -33,6 +33,31 @@
|
||||
|
||||
#include "Common.hpp"
|
||||
|
||||
void Report::getHealthReport(health_report_s &report) const
|
||||
{
|
||||
const Results ¤t_results = _results[_current_result];
|
||||
report.can_arm_mode_flags = 0;
|
||||
report.can_run_mode_flags = 0;
|
||||
|
||||
for (int i = 0; i < vehicle_status_s::NAVIGATION_STATE_MAX; ++i) {
|
||||
NavModes group = getModeGroup(i);
|
||||
|
||||
if ((uint32_t)(current_results.arming_checks.can_arm & group)) {
|
||||
report.can_arm_mode_flags |= 1ull << i;
|
||||
}
|
||||
|
||||
if ((uint32_t)(current_results.arming_checks.can_run & group)) {
|
||||
report.can_run_mode_flags |= 1ull << i;
|
||||
}
|
||||
}
|
||||
|
||||
report.arming_check_error_flags = (uint64_t)current_results.arming_checks.error;
|
||||
report.arming_check_warning_flags = (uint64_t)current_results.arming_checks.warning;
|
||||
report.health_is_present_flags = (uint64_t)current_results.health.is_present;
|
||||
report.health_error_flags = (uint64_t)current_results.health.error;
|
||||
report.health_warning_flags = (uint64_t)current_results.health.warning;
|
||||
}
|
||||
|
||||
void Report::healthFailure(NavModes required_modes, HealthComponentIndex component, uint32_t event_id,
|
||||
const events::LogLevels &log_levels, const char *message)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <px4_platform_common/events.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/topics/health_report.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <uORB/topics/vehicle_status_flags.h>
|
||||
|
||||
@@ -207,6 +208,8 @@ public:
|
||||
(uint32_t)(_results[_current_result].arming_checks.can_run & getModeGroup(nav_state)) != 0;
|
||||
}
|
||||
|
||||
void getHealthReport(health_report_s &report) const;
|
||||
|
||||
/**
|
||||
* Report a health failure. A health issue generally refers to a hardware issue, independent from environment
|
||||
* or e.g. calibration.
|
||||
|
||||
@@ -57,6 +57,10 @@ bool HealthAndArmingChecks::update(bool force_reporting)
|
||||
|
||||
if (_reporter.report(_context.isArmed(), force_reporting)) {
|
||||
|
||||
health_report_s health_report;
|
||||
_reporter.getHealthReport(health_report);
|
||||
health_report.timestamp = hrt_absolute_time();
|
||||
_health_report_pub.publish(health_report);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "Common.hpp"
|
||||
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/health_report.h>
|
||||
|
||||
class HealthAndArmingChecks : public ModuleParams
|
||||
{
|
||||
@@ -62,6 +64,8 @@ private:
|
||||
Context _context;
|
||||
Report _reporter;
|
||||
|
||||
uORB::Publication<health_report_s> _health_report_pub{ORB_ID(health_report)};
|
||||
|
||||
// all checks
|
||||
HealthAndArmingCheckBase *_checks[10] = {
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user