diff --git a/src/modules/systemlib/battery.cpp b/src/modules/systemlib/battery.cpp index 072ffdd0ef..f9937ba705 100644 --- a/src/modules/systemlib/battery.cpp +++ b/src/modules/systemlib/battery.cpp @@ -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()) { diff --git a/src/modules/systemlib/battery.h b/src/modules/systemlib/battery.h index 38784ee33d..e6efdeece1 100644 --- a/src/modules/systemlib/battery.h +++ b/src/modules/systemlib/battery.h @@ -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; diff --git a/src/modules/systemlib/battery_params.c b/src/modules/systemlib/battery_params.c index 566e23f229..17cc2c4626 100644 --- a/src/modules/systemlib/battery_params.c +++ b/src/modules/systemlib/battery_params.c @@ -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 *