mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 10:13:34 +08:00
powerCheck: add power redundancy check
A parameter spcifies what the redundancy level for 5V rail supply needs to be and a check makes sure that it's available before taking off such that the user is aware of a broken or disconnected redundant power module.
This commit is contained in:
committed by
Daniel Agar
parent
37fb4dbb64
commit
7ff25373e4
@@ -35,11 +35,24 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <systemlib/mavlink_log.h>
|
||||
#include <lib/parameters/param.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/system_power.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
unsigned int countSetBits(unsigned int n)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
|
||||
while (n) {
|
||||
count += n & 1;
|
||||
n >>= 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
bool PreFlightCheck::powerCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &status, const bool report_fail,
|
||||
const bool prearm)
|
||||
{
|
||||
@@ -79,6 +92,19 @@ bool PreFlightCheck::powerCheck(orb_advert_t *mavlink_log_pub, const vehicle_sta
|
||||
}
|
||||
}
|
||||
|
||||
int power_module_count = countSetBits(system_power.brick_valid);
|
||||
int required_power_module_count;
|
||||
param_get(param_find("COM_POWER_COUNT"), &required_power_module_count);
|
||||
|
||||
if (power_module_count < required_power_module_count) {
|
||||
success = false;
|
||||
|
||||
if (report_fail) {
|
||||
mavlink_log_critical(mavlink_log_pub, "Power redundancy not met: %d instead of %d",
|
||||
power_module_count, required_power_module_count);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (report_fail) {
|
||||
mavlink_log_critical(mavlink_log_pub, "system power unavailable");
|
||||
|
||||
Reference in New Issue
Block a user