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:
Matthias Grob
2020-05-18 18:51:58 +02:00
committed by Daniel Agar
parent 37fb4dbb64
commit 7ff25373e4
2 changed files with 38 additions and 0 deletions
@@ -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");
+12
View File
@@ -912,3 +912,15 @@ PARAM_DEFINE_FLOAT(COM_KILL_DISARM, 5.0f);
* @increment 1
*/
PARAM_DEFINE_FLOAT(COM_CPU_MAX, 90.0f);
/**
* Required number of redundant power modules
*
* This configures a check to verify the expected number of 5V rail power supplies are present. By default only one is expected.
* Note: CBRK_SUPPLY_CHK disables all power checks including this one.
*
* @group Commander
* @min 0
* @max 4
*/
PARAM_DEFINE_INT32(COM_POWER_COUNT, 1);