rc_update: remove 1% deadzone for RC channels 1-8 (#25502)

* rc_update: remove 1% deadzone for all channels

this should be handled higher level.

* Remove all references to the RC{n}_DZ parameters

Regular expression: RC.{0,2}_DZ

---------

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
Matthias Grob
2025-10-13 21:41:11 -08:00
committed by GitHub
co-authored by Jacob Dahl
parent 12035682d7
commit 4842c542b8
8 changed files with 6 additions and 270 deletions
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2025 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
@@ -33,11 +33,6 @@
#include "rcCalibrationCheck.hpp"
/**
* Maximum deadzone value
*/
#define RC_INPUT_MAX_DEADZONE_US 500
/**
* Minimum value
*/
@@ -61,9 +56,6 @@ RcCalibrationChecks::RcCalibrationChecks()
snprintf(nbuf, sizeof(nbuf), "RC%d_MAX", i + 1);
_param_handles[i].max = param_find(nbuf);
snprintf(nbuf, sizeof(nbuf), "RC%d_DZ", i + 1);
_param_handles[i].dz = param_find(nbuf);
}
updateParams();
@@ -84,7 +76,6 @@ void RcCalibrationChecks::checkAndReport(const Context &context, Report &reporte
float param_min = _param_values[i].min;
float param_max = _param_values[i].max;
float param_trim = _param_values[i].trim;
float param_dz = _param_values[i].dz;
/* assert min..center..max ordering */
if (param_min < RC_INPUT_LOWEST_MIN_US) {
@@ -148,22 +139,6 @@ void RcCalibrationChecks::checkAndReport(const Context &context, Report &reporte
(int)param_trim, (int)param_max);
}
}
/* assert deadzone is sane */
if (param_dz > RC_INPUT_MAX_DEADZONE_US) {
/* EVENT
* @description
* Recalibrate the RC.
*/
reporter.armingCheckFailure<uint8_t, uint16_t>(NavModes::All, health_component_t::remote_control,
events::ID("check_rc_dz_too_high"),
events::Log::Error, "RC calibration for channel {1} invalid: DZ greater than {2}", i + 1, RC_INPUT_MAX_DEADZONE_US);
if (reporter.mavlink_log_pub()) {
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: RC ERROR: RC%d_DZ > %u", i + 1,
RC_INPUT_MAX_DEADZONE_US);
}
}
}
}
@@ -176,11 +151,9 @@ void RcCalibrationChecks::updateParams()
_param_values[i].min = 0.0f;
_param_values[i].max = 0.0f;
_param_values[i].trim = 0.0f;
_param_values[i].dz = RC_INPUT_MAX_DEADZONE_US * 2.0f;
param_get(_param_handles[i].min, &_param_values[i].min);
param_get(_param_handles[i].trim, &_param_values[i].trim);
param_get(_param_handles[i].max, &_param_values[i].max);
param_get(_param_handles[i].dz, &_param_values[i].dz);
}
}
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2022 PX4 Development Team. All rights reserved.
* Copyright (c) 2025 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
@@ -53,13 +53,11 @@ private:
param_t min;
param_t trim;
param_t max;
param_t dz;
};
struct ParamValues {
float min;
float trim;
float max;
float dz;
};
ParamHandles _param_handles[input_rc_s::RC_INPUT_MAX_CHANNELS];
-202
View File
@@ -87,18 +87,6 @@ PARAM_DEFINE_FLOAT(RC1_MAX, 2000.0f);
*/
PARAM_DEFINE_FLOAT(RC1_REV, 1.0f);
/**
* RC channel 1 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @unit us
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC1_DZ, 10.0f);
/**
* RC channel 2 minimum
*
@@ -148,18 +136,6 @@ PARAM_DEFINE_FLOAT(RC2_MAX, 2000.0f);
*/
PARAM_DEFINE_FLOAT(RC2_REV, 1.0f);
/**
* RC channel 2 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @unit us
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC2_DZ, 10.0f);
/**
* RC channel 3 minimum
*
@@ -209,18 +185,6 @@ PARAM_DEFINE_FLOAT(RC3_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC3_REV, 1.0f);
/**
* RC channel 3 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @unit us
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC3_DZ, 10.0f);
/**
* RC channel 4 minimum
*
@@ -270,18 +234,6 @@ PARAM_DEFINE_FLOAT(RC4_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC4_REV, 1.0f);
/**
* RC channel 4 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @unit us
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC4_DZ, 10.0f);
/**
* RC channel 5 minimum
*
@@ -331,17 +283,6 @@ PARAM_DEFINE_FLOAT(RC5_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC5_REV, 1.0f);
/**
* RC channel 5 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC5_DZ, 10.0f);
/**
* RC channel 6 minimum
*
@@ -391,17 +332,6 @@ PARAM_DEFINE_FLOAT(RC6_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC6_REV, 1.0f);
/**
* RC channel 6 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC6_DZ, 10.0f);
/**
* RC channel 7 minimum
*
@@ -451,17 +381,6 @@ PARAM_DEFINE_FLOAT(RC7_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC7_REV, 1.0f);
/**
* RC channel 7 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC7_DZ, 10.0f);
/**
* RC channel 8 minimum
*
@@ -511,17 +430,6 @@ PARAM_DEFINE_FLOAT(RC8_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC8_REV, 1.0f);
/**
* RC channel 8 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC8_DZ, 10.0f);
/**
* RC channel 9 minimum
*
@@ -571,17 +479,6 @@ PARAM_DEFINE_FLOAT(RC9_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC9_REV, 1.0f);
/**
* RC channel 9 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC9_DZ, 0.0f);
/**
* RC channel 10 minimum
*
@@ -631,17 +528,6 @@ PARAM_DEFINE_FLOAT(RC10_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC10_REV, 1.0f);
/**
* RC channel 10 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC10_DZ, 0.0f);
/**
* RC channel 11 minimum
*
@@ -691,17 +577,6 @@ PARAM_DEFINE_FLOAT(RC11_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC11_REV, 1.0f);
/**
* RC channel 11 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC11_DZ, 0.0f);
/**
* RC channel 12 minimum
*
@@ -751,17 +626,6 @@ PARAM_DEFINE_FLOAT(RC12_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC12_REV, 1.0f);
/**
* RC channel 12 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC12_DZ, 0.0f);
/**
* RC channel 13 minimum
*
@@ -811,17 +675,6 @@ PARAM_DEFINE_FLOAT(RC13_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC13_REV, 1.0f);
/**
* RC channel 13 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC13_DZ, 0.0f);
/**
* RC channel 14 minimum
*
@@ -871,17 +724,6 @@ PARAM_DEFINE_FLOAT(RC14_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC14_REV, 1.0f);
/**
* RC channel 14 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC14_DZ, 0.0f);
/**
* RC channel 15 minimum
*
@@ -931,17 +773,6 @@ PARAM_DEFINE_FLOAT(RC15_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC15_REV, 1.0f);
/**
* RC channel 15 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC15_DZ, 0.0f);
/**
* RC channel 16 minimum
*
@@ -991,17 +822,6 @@ PARAM_DEFINE_FLOAT(RC16_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC16_REV, 1.0f);
/**
* RC channel 16 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC16_DZ, 0.0f);
/**
* RC channel 17 minimum
*
@@ -1051,17 +871,6 @@ PARAM_DEFINE_FLOAT(RC17_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC17_REV, 1.0f);
/**
* RC channel 17 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC17_DZ, 0.0f);
/**
* RC channel 18 minimum
*
@@ -1111,17 +920,6 @@ PARAM_DEFINE_FLOAT(RC18_MAX, 2000);
*/
PARAM_DEFINE_FLOAT(RC18_REV, 1.0f);
/**
* RC channel 18 dead zone
*
* The +- range of this value around the trim value will be considered as zero.
*
* @min 0.0
* @max 100.0
* @group Radio Calibration
*/
PARAM_DEFINE_FLOAT(RC18_DZ, 0.0f);
/**
* RC channel count
*
+4 -15
View File
@@ -87,10 +87,6 @@ RCUpdate::RCUpdate() :
/* channel reverse */
snprintf(nbuf, sizeof(nbuf), "RC%d_REV", i + 1);
_parameter_handles.rev[i] = param_find(nbuf);
/* channel deadzone */
snprintf(nbuf, sizeof(nbuf), "RC%d_DZ", i + 1);
_parameter_handles.dz[i] = param_find(nbuf);
}
// RC to parameter mapping for changing parameters with RC
@@ -145,10 +141,6 @@ void RCUpdate::updateParams()
float rev = 0.f;
param_get(_parameter_handles.rev[i], &rev);
_parameters.rev[i] = (rev < 0.f);
float dz = 0.f;
param_get(_parameter_handles.dz[i], &dz);
_parameters.dz[i] = dz;
}
for (int i = 0; i < rc_parameter_map_s::RC_PARAM_MAP_NCHAN; i++) {
@@ -449,12 +441,9 @@ void RCUpdate::Run()
const float min = _parameters.min[i];
const float trim = _parameters.trim[i];
const float max = _parameters.max[i];
const float dz = _parameters.dz[i];
// piecewise linear function to apply RC calibration
_rc.channels[i] = math::interpolateNXY(value,
{min, trim - dz, trim + dz, max},
{-1.f, 0.f, 0.f, 1.f});
_rc.channels[i] = math::interpolateNXY(value, {min, trim, max}, {-1.f, 0.f, 1.f});
if (_parameters.rev[i]) {
_rc.channels[i] = -_rc.channels[i];
@@ -725,11 +714,11 @@ int RCUpdate::print_status()
PX4_INFO_RAW("Running\n");
if (_channel_count_max > 0) {
PX4_INFO_RAW(" # MIN MAX TRIM DZ REV\n");
PX4_INFO_RAW(" # MIN MAX TRIM REV\n");
for (int i = 0; i < _channel_count_max; i++) {
PX4_INFO_RAW("%2d %4d %4d %4d %3d %3d\n", i, _parameters.min[i], _parameters.max[i], _parameters.trim[i],
_parameters.dz[i], _parameters.rev[i]);
PX4_INFO_RAW("%2d %4d %4d %4d %3d\n",
i, _parameters.min[i], _parameters.max[i], _parameters.trim[i], _parameters.rev[i]);
}
}
-2
View File
@@ -148,7 +148,6 @@ protected:
uint16_t min[RC_MAX_CHAN_COUNT];
uint16_t trim[RC_MAX_CHAN_COUNT];
uint16_t max[RC_MAX_CHAN_COUNT];
uint16_t dz[RC_MAX_CHAN_COUNT];
bool rev[RC_MAX_CHAN_COUNT];
int32_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
@@ -159,7 +158,6 @@ protected:
param_t trim[RC_MAX_CHAN_COUNT];
param_t max[RC_MAX_CHAN_COUNT];
param_t rev[RC_MAX_CHAN_COUNT];
param_t dz[RC_MAX_CHAN_COUNT];
param_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
param_t rc_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN]; /**< param handles for the parameters which are bound