Battery estimator: Warn on dangerously low levels.

We need to differentiate between a level where the user should act and where we are about to fall out of the sky (emergency). This helps performing more suitable failsafe actions.
This commit is contained in:
Lorenz Meier
2017-02-22 22:03:21 +01:00
parent 7372014aee
commit 029c6de4a9
3 changed files with 24 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ Battery::Battery() :
_param_r_internal(this, "R_INTERNAL"),
_param_low_thr(this, "LOW_THR"),
_param_crit_thr(this, "CRIT_THR"),
_param_emergency_thr(this, "EMERGEN_THR"),
_voltage_filtered_v(-1.0f),
_discharged_mah(0.0f),
_remaining_voltage(1.0f),
@@ -219,7 +220,10 @@ void
Battery::determineWarning()
{
// Smallest values must come first
if (_remaining < _param_crit_thr.get()) {
if (_remaining < _param_emergency_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_EMERGENCY;
} else if (_remaining < _param_crit_thr.get()) {
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
} else if (_remaining < _param_low_thr.get()) {

View File

@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2016 PX4 Development Team. All rights reserved.
* Copyright (c) 2016, 2017 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -106,6 +106,7 @@ private:
control::BlockParamFloat _param_r_internal;
control::BlockParamFloat _param_low_thr;
control::BlockParamFloat _param_crit_thr;
control::BlockParamFloat _param_emergency_thr;
float _voltage_filtered_v;
float _current_filtered_a;

View File

@@ -90,7 +90,7 @@ PARAM_DEFINE_FLOAT(BAT_LOW_THR, 0.15f);
*
* Sets the threshold when the battery will be reported as critically low.
* This has to be lower than the low threshold. This threshold commonly
* will trigger RTL or landing.
* will trigger RTL.
*
* @group Battery Calibration
* @unit norm
@@ -101,6 +101,22 @@ PARAM_DEFINE_FLOAT(BAT_LOW_THR, 0.15f);
*/
PARAM_DEFINE_FLOAT(BAT_CRIT_THR, 0.07f);
/**
* Emergency threshold
*
* Sets the threshold when the battery will be reported as dangerously low.
* This has to be lower than the critical threshold. This threshold commonly
* will trigger landing.
*
* @group Battery Calibration
* @unit norm
* @min 0.03
* @max 0.07
* @decimal 2
* @increment 0.01
*/
PARAM_DEFINE_FLOAT(BAT_EMERGEN_THR, 0.05f);
/**
* Voltage drop per cell on full throttle
*