mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
Make battery failsafe limits configurable
This commit is contained in:
@@ -48,6 +48,8 @@ Battery::Battery() :
|
|||||||
_param_n_cells(this, "N_CELLS"),
|
_param_n_cells(this, "N_CELLS"),
|
||||||
_param_capacity(this, "CAPACITY"),
|
_param_capacity(this, "CAPACITY"),
|
||||||
_param_v_load_drop(this, "V_LOAD_DROP"),
|
_param_v_load_drop(this, "V_LOAD_DROP"),
|
||||||
|
_param_low_thr(this, "LOW_THR"),
|
||||||
|
_param_crit_thr(this, "CRIT_THR"),
|
||||||
_voltage_filtered_v(0.0f),
|
_voltage_filtered_v(0.0f),
|
||||||
_throttle_filtered(0.0f),
|
_throttle_filtered(0.0f),
|
||||||
_discharged_mah(0.0f),
|
_discharged_mah(0.0f),
|
||||||
@@ -162,13 +164,11 @@ Battery::estimateRemaining(float voltage_v, float throttle_normalized)
|
|||||||
void
|
void
|
||||||
Battery::determineWarning()
|
Battery::determineWarning()
|
||||||
{
|
{
|
||||||
// TODO: Determine threshold or make params.
|
|
||||||
|
|
||||||
// Smallest values must come first
|
// Smallest values must come first
|
||||||
if (_remaining < 0.09f) {
|
if (_remaining < _param_crit_thr.get()) {
|
||||||
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
_warning = battery_status_s::BATTERY_WARNING_CRITICAL;
|
||||||
|
|
||||||
} else if (_remaining < 0.18f) {
|
} else if (_remaining < _param_low_thr.get()) {
|
||||||
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
_warning = battery_status_s::BATTERY_WARNING_LOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ private:
|
|||||||
control::BlockParamInt _param_n_cells;
|
control::BlockParamInt _param_n_cells;
|
||||||
control::BlockParamFloat _param_capacity;
|
control::BlockParamFloat _param_capacity;
|
||||||
control::BlockParamFloat _param_v_load_drop;
|
control::BlockParamFloat _param_v_load_drop;
|
||||||
|
control::BlockParamFloat _param_low_thr;
|
||||||
|
control::BlockParamFloat _param_crit_thr;
|
||||||
|
|
||||||
float _voltage_filtered_v;
|
float _voltage_filtered_v;
|
||||||
float _throttle_filtered;
|
float _throttle_filtered;
|
||||||
|
|||||||
@@ -66,6 +66,36 @@ PARAM_DEFINE_FLOAT(BAT_V_EMPTY, 3.4f);
|
|||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(BAT_V_CHARGED, 4.2f);
|
PARAM_DEFINE_FLOAT(BAT_V_CHARGED, 4.2f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Low threshold
|
||||||
|
*
|
||||||
|
* Sets the threshold (between 0 and 1, which is equivalent to between 0 and 100%)
|
||||||
|
* when the battery will be reported as low. This has to be higher than the critical
|
||||||
|
* threshold.
|
||||||
|
*
|
||||||
|
* @group Battery Calibration
|
||||||
|
* @decimal 2
|
||||||
|
* @min 0.15
|
||||||
|
* @max 0.5
|
||||||
|
* @increment 0.01
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(BAT_LOW_THR, 0.18f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Critical threshold
|
||||||
|
*
|
||||||
|
* Sets the threshold (between 0 and 1, which is equivalent to between 0 and 100%)
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @group Battery Calibration
|
||||||
|
* @decimal 2
|
||||||
|
* @min 0.05
|
||||||
|
* @max 0.14
|
||||||
|
* @increment 0.01
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(BAT_CRIT_THR, 0.09f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Voltage drop per cell on 100% load
|
* Voltage drop per cell on 100% load
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user