delete deprecated BAT_* parameters

This commit is contained in:
Daniel Agar
2021-07-08 22:19:12 -04:00
parent 19bc1f9d02
commit c5b1fe86ca
41 changed files with 76 additions and 407 deletions
+7 -34
View File
@@ -92,14 +92,6 @@ Battery::Battery(int index, ModuleParams *parent, const int sample_interval_us)
_param_handles.crit_thr = param_find("BAT_CRIT_THR");
_param_handles.emergen_thr = param_find("BAT_EMERGEN_THR");
_param_handles.v_empty_old = param_find("BAT_V_EMPTY");
_param_handles.v_charged_old = param_find("BAT_V_CHARGED");
_param_handles.n_cells_old = param_find("BAT_N_CELLS");
_param_handles.capacity_old = param_find("BAT_CAPACITY");
_param_handles.v_load_drop_old = param_find("BAT_V_LOAD_DROP");
_param_handles.r_internal_old = param_find("BAT_R_INTERNAL");
_param_handles.source_old = param_find("BAT_SOURCE");
updateParams();
}
@@ -255,32 +247,13 @@ void Battery::computeScale()
void Battery::updateParams()
{
if (_index == 1) {
migrateParam<float>(_param_handles.v_empty_old, _param_handles.v_empty, &_params.v_empty_old, &_params.v_empty,
_first_parameter_update);
migrateParam<float>(_param_handles.v_charged_old, _param_handles.v_charged, &_params.v_charged_old, &_params.v_charged,
_first_parameter_update);
migrateParam<int32_t>(_param_handles.n_cells_old, _param_handles.n_cells, &_params.n_cells_old, &_params.n_cells,
_first_parameter_update);
migrateParam<float>(_param_handles.capacity_old, _param_handles.capacity, &_params.capacity_old, &_params.capacity,
_first_parameter_update);
migrateParam<float>(_param_handles.v_load_drop_old, _param_handles.v_load_drop, &_params.v_load_drop_old,
&_params.v_load_drop, _first_parameter_update);
migrateParam<float>(_param_handles.r_internal_old, _param_handles.r_internal, &_params.r_internal_old,
&_params.r_internal, _first_parameter_update);
migrateParam<int32_t>(_param_handles.source_old, _param_handles.source, &_params.source_old, &_params.source,
_first_parameter_update);
} else {
param_get(_param_handles.v_empty, &_params.v_empty);
param_get(_param_handles.v_charged, &_params.v_charged);
param_get(_param_handles.n_cells, &_params.n_cells);
param_get(_param_handles.capacity, &_params.capacity);
param_get(_param_handles.v_load_drop, &_params.v_load_drop);
param_get(_param_handles.r_internal, &_params.r_internal);
param_get(_param_handles.source, &_params.source);
}
param_get(_param_handles.v_empty, &_params.v_empty);
param_get(_param_handles.v_charged, &_params.v_charged);
param_get(_param_handles.n_cells, &_params.n_cells);
param_get(_param_handles.capacity, &_params.capacity);
param_get(_param_handles.v_load_drop, &_params.v_load_drop);
param_get(_param_handles.r_internal, &_params.r_internal);
param_get(_param_handles.source, &_params.source);
param_get(_param_handles.low_thr, &_params.low_thr);
param_get(_param_handles.crit_thr, &_params.crit_thr);
param_get(_param_handles.emergen_thr, &_params.emergen_thr);
-54
View File
@@ -108,16 +108,6 @@ protected:
param_t crit_thr;
param_t emergen_thr;
param_t source;
// TODO: These parameters are depracated. They can be removed entirely once the
// new version of Firmware has been around for long enough.
param_t v_empty_old;
param_t v_charged_old;
param_t n_cells_old;
param_t capacity_old;
param_t v_load_drop_old;
param_t r_internal_old;
param_t source_old;
} _param_handles{};
struct {
@@ -131,16 +121,6 @@ protected:
float crit_thr;
float emergen_thr;
int32_t source;
// TODO: These parameters are depracated. They can be removed entirely once the
// new version of Firmware has been around for long enough.
float v_empty_old;
float v_charged_old;
int32_t n_cells_old;
float capacity_old;
float v_load_drop_old;
float r_internal_old;
int32_t source_old;
} _params{};
const int _index;
@@ -148,40 +128,6 @@ protected:
bool _first_parameter_update{true};
void updateParams() override;
/**
* This function helps migrating and syncing from/to deprecated parameters. BAT_* BAT1_*
* @tparam T Type of the parameter (int or float)
* @param old_param Handle to the old deprecated parameter (for example, param_find("BAT_N_CELLS"))
* @param new_param Handle to the new replacement parameter (for example, param_find("BAT1_N_CELLS"))
* @param old_val Pointer to the value of the old deprecated parameter
* @param new_val Pointer to the value of the new replacement parameter
* @param firstcall If true, this function prefers migrating old to new
*/
template<typename T>
void migrateParam(param_t old_param, param_t new_param, T *old_val, T *new_val, bool firstcall)
{
T previous_old_val = *old_val;
T previous_new_val = *new_val;
// Update both the old and new parameter values
param_get(old_param, old_val);
param_get(new_param, new_val);
// Check if the parameter values are different
if (!matrix::isEqualF((float)*old_val, (float)*new_val)) {
// If so, copy the new value over to the unchanged parameter
// Note: If they differ from the beginning we migrate old to new
if (firstcall || !matrix::isEqualF((float)*old_val, (float)previous_old_val)) {
param_set_no_notification(new_param, old_val);
param_get(new_param, new_val);
} else if (!matrix::isEqualF((float)*new_val, (float)previous_new_val)) {
param_set_no_notification(old_param, new_val);
param_get(old_param, old_val);
}
}
}
private:
void sumDischarged(const hrt_abstime &timestamp, float current_a);
void estimateStateOfCharge(const float voltage_v, const float current_a, const float throttle);
-163
View File
@@ -1,163 +0,0 @@
/****************************************************************************
*
* Copyright (c) 2012-2019 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
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file battery_params_deprecated.c
* @author Timothy Scott <timothy@auterion.com>
*
* Defines the deprcated single battery configuration which are temporarily kept for backwards compatibility with QGC.
* The new parameter set has a number after "BAT" e.g. BAT1_V_EMPTY.
*/
/**
* This parameter is deprecated. Please use BAT1_V_EMPTY instead.
*
* Defines the voltage where a single cell of battery 1 is considered empty.
* The voltage should be chosen before the steep dropoff to 2.8V. A typical
* lithium battery can only be discharged down to 10% before it drops off
* to a voltage level damaging the cells.
*
* @group Battery Calibration
* @unit V
* @decimal 2
* @increment 0.01
* @reboot_required true
*/
PARAM_DEFINE_FLOAT(BAT_V_EMPTY, 3.5f);
/**
* This parameter is deprecated. Please use BAT1_V_CHARGED instead.
*
* Defines the voltage where a single cell of battery 1 is considered full
* under a mild load. This will never be the nominal voltage of 4.2V
*
* @group Battery Calibration
* @unit V
* @decimal 2
* @increment 0.01
* @reboot_required true
*/
PARAM_DEFINE_FLOAT(BAT_V_CHARGED, 4.05f);
/**
* This parameter is deprecated. Please use BAT1_V_LOAD_DROP instead.
*
* This implicitely defines the internal resistance
* to maximum current ratio for battery 1 and assumes linearity.
* A good value to use is the difference between the
* 5C and 20-25C load. Not used if BAT_R_INTERNAL is
* set.
*
* @group Battery Calibration
* @unit V
* @min 0.07
* @max 0.5
* @decimal 2
* @increment 0.01
* @reboot_required true
*/
PARAM_DEFINE_FLOAT(BAT_V_LOAD_DROP, 0.3f);
/**
* This parameter is deprecated. Please use BAT1_R_INTERNAL instead.
*
* If non-negative, then this will be used in place of
* BAT_V_LOAD_DROP for all calculations.
*
* @group Battery Calibration
* @unit Ohm
* @min -1.0
* @max 0.2
* @reboot_required true
*/
PARAM_DEFINE_FLOAT(BAT_R_INTERNAL, -1.0f);
/**
* This parameter is deprecated. Please use BAT1_N_CELLS instead.
*
* Defines the number of cells the attached battery consists of.
*
* @group Battery Calibration
* @unit S
* @value 0 Unconfigured
* @value 2 2S Battery
* @value 3 3S Battery
* @value 4 4S Battery
* @value 5 5S Battery
* @value 6 6S Battery
* @value 7 7S Battery
* @value 8 8S Battery
* @value 9 9S Battery
* @value 10 10S Battery
* @value 11 11S Battery
* @value 12 12S Battery
* @value 13 13S Battery
* @value 14 14S Battery
* @value 15 15S Battery
* @value 16 16S Battery
* @reboot_required true
*/
PARAM_DEFINE_INT32(BAT_N_CELLS, 0);
/**
* This parameter is deprecated. Please use BAT1_CAPACITY instead.
*
* Defines the capacity of battery 1.
*
* @group Battery Calibration
* @unit mAh
* @decimal 0
* @min -1.0
* @max 100000
* @increment 50
* @reboot_required true
*/
PARAM_DEFINE_FLOAT(BAT_CAPACITY, -1.0f);
/**
* This parameter is deprecated. Please use BAT1_SOURCE instead.
*
* Battery monitoring source.
*
* This parameter controls the source of battery data. The value 'Power Module'
* means that measurements are expected to come from a power module. If the value is set to
* 'External' then the system expects to receive mavlink battery status messages.
*
* @min 0
* @max 1
* @value 0 Power Module
* @value 1 External
* @group Battery Calibration
*/
PARAM_DEFINE_INT32(BAT_SOURCE, 0);