fix(drivers): fix wrong RPM in UAVCAN ESC telemetry (#29580)

This commit is contained in:
Mathéo Taillandier authored and GitHub committed 2026-11-16 08:55:04 +01:00
1 parent c4b8f107ae
commit 336eafd0c5
4 files changed
+19 -1

No files matched your search

+2
View File
@@ -49,6 +49,8 @@ These workarounds are disabled by default and can be enabled with the [UAVCAN_QU
- **Hobbywing ESCs:** some Hobbywing DroneCAN ESCs report `uavcan.equipment.esc.Status.esc_index` starting at 1 for the first ESC instead of 0 as required by the specification, while still expecting `RawCommand.cmd[0]` to command the first ESC.
This causes ESC status feedback (e.g. RPM, voltage, current) to be matched to the wrong motor.
Set bit 0 of `UAVCAN_QUIRKS` to correct for this off-by-one indexing.
- **Scaled RPM telemetry:** some ESCs report `uavcan.equipment.esc.Status.rpm` off by a fixed factor (for example electrical instead of mechanical RPM).
Set [UAVCAN_ESC_RPMSC](../advanced_config/parameter_reference.md#UAVCAN_ESC_RPMSC) to the factor that converts the reported value to mechanical RPM.
## Reversible Motors {#reversible-motors}
+2 -1
View File
@@ -87,6 +87,7 @@ int UavcanEscController::init()
}
param_get(param_find("UAVCAN_QUIRKS"), &_param_uavcan_quirks);
param_get(param_find("UAVCAN_ESC_RPMSC"), &_param_esc_rpm_scale);
_initialized = true;
@@ -138,7 +139,7 @@ void UavcanEscController::esc_status_sub_cb(const uavcan::ReceivedDataStructure<
esc_report.esc_current = msg.current;
esc_report.esc_temperature = msg.temperature + atmosphere::kAbsoluteNullCelsius; // Kelvin to Celsius
// esc_report.motor_temperature is filled in the extended status callback
esc_report.esc_rpm = msg.rpm;
esc_report.esc_rpm = static_cast<int32_t>(lroundf(msg.rpm * _param_esc_rpm_scale));
esc_report.esc_errorcount = msg.error_count;
esc_report.failures = get_failures(msg.getSrcNodeID().get());
+2
View File
@@ -130,6 +130,8 @@ private:
failure_injection::Config _failure_config;
float _param_esc_rpm_scale{1.f};
int32_t _param_uavcan_quirks{0};
enum class Quirk : int32_t {
HobbywingEscIdx1 = (1 << 0), ///< ESCs reporting a 1-based esc_index instead of 0-based
+13
View File
@@ -47,6 +47,19 @@ parameters:
0: Hobbywing 1-based esc_index
default: 0
reboot_required: true
UAVCAN_ESC_RPMSC:
description:
short: ESC RPM telemetry scale
long: Multiplies the RPM reported in uavcan.equipment.esc.Status by this factor
before publishing, for ESCs that report RPM off by a fixed factor (e.g. electrical
instead of mechanical RPM). Applies to all DroneCAN ESCs.
type: float
default: 1.0
min: 0.001
max: 100.0
decimal: 4
increment: 0.01
reboot_required: true
UAVCAN_EC_SIGNED:
description:
short: Signed command for non-motor ESC channels