Improvement iteration for under- and new overcurrent motor failure detection#26262
Improvement iteration for under- and new overcurrent motor failure detection#26262
Conversation
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 168 byte (0.01 %)]px4_fmu-v6x [Total VM Diff: 72 byte (0 %)]Updated: 2026-02-09T12:47:04 |
Addressed in #26263 |
dakejahl
left a comment
There was a problem hiding this comment.
A few comments but otherwise LGTM
| esc_fail_msg[sizeof(esc_fail_msg) - 1] = '\0'; | ||
| } | ||
| for (int i = 0; i < esc_status_s::CONNECTED_ESC_MAX; ++i) { | ||
| const bool mapped = math::isInRange(esc_status.esc[i].actuator_function, actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1, |
There was a problem hiding this comment.
| const bool mapped = math::isInRange(esc_status.esc[i].actuator_function, actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1, | |
| const bool is_motor = math::isInRange(esc_status.esc[i].actuator_function, actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1, |
There was a problem hiding this comment.
is mapped as motor? I'll check 🤔 👍
There was a problem hiding this comment.
I think you look at the check and see it checks for being mapped to a motor and I looked at what's interesting, is it mapped at all. Both are valid. I think we should combine tha names in the next iteration, I want to unblock @ttechnick 's work.
| } | ||
|
|
||
| for (int index = 0; index < esc_status.esc_count; index++) { | ||
| for (int index = 0; index < math::min(esc_status.esc_count, esc_status_s::CONNECTED_ESC_MAX); ++index) { |
There was a problem hiding this comment.
| for (int index = 0; index < math::min(esc_status.esc_count, esc_status_s::CONNECTED_ESC_MAX); ++index) { | |
| for (int index = 0; index < esc_status_s::CONNECTED_ESC_MAX; ++index) { |
you should still iterate over esc_status_s::CONNECTED_ESC_MAX. Technically you could configure Motor1 and Motor2 on actuator channels 1&2 and Motor3 and Motor4 on channels 5&6. The EscStatus.esc[8] message is in actuator order.
There was a problem hiding this comment.
Can we keep it the proposed way, as it is more conservative and change it to your suggested way in the next iteration?
There was a problem hiding this comment.
We need to document more clearly how the array and esc_count works in the esc_status message. This implementation is based on the assumption the count gives the number of valid array entries from the beginning. I thought that's currently also the case but we need to check the details.
There was a problem hiding this comment.
EscStatus.esc_count is the total number of valid entries but they are not necessarily sequential. The EscReport[8] esc is in actuator order not motor order, hence the EscReport.actuator_function
|
The buffer overflow issue should be addressed here, but the timeout can also be fixed in a later iteration :) |
previous to this 09d79b2 set `esc_online_flags` e.g. for UAVCAN ESCs which specific one is online and that then got compared to a mask where the first `esc_count` bits were set. So if only ESC 5 is mapped and online you get the message "ESC 156 offline" because `esc_online_flags = 0b1000` gets compared to `online_bitmask = 0b1` based on `esc_count = 1` and the motor index is `esc[0].actuator_function = 0` wrapped using `0 - actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1 + 1 = 156`.
Prevent Buffer overflow
71e531b to
612a160
Compare
|
❌ The last analysis has failed. |
| } | ||
|
|
||
| for (int index = 0; index < esc_status.esc_count; index++) { | ||
| for (int index = 0; index < math::min(esc_status.esc_count, esc_status_s::CONNECTED_ESC_MAX); ++index) { |
There was a problem hiding this comment.
Can we keep it the proposed way, as it is more conservative and change it to your suggested way in the next iteration?
|
Thanks for the reviews! They were direly necessary (array overflow 🙈). I think by now we can merge this iteration to allow progressing to the next one: #26420 |
Solved Problem
The motor failure detection based on current was already supported in PX4 since #19570 but has some real world limitations e.g.:
Solution
This is only my first iteration of improving the logic.
I'll follow up with more iterations to:
FD_ACT_MOT_THRmight have become obsoleteescCheckproviding user feedback and UAVCAN driverChangelog Entry
Test coverage
Only bench testing and comparison to real-world flight log data so far.
Context
I made this current check implementation based on real world data analysis which looked like this. Upper bound yellow (imagine a line), lower bound red (imagine a line), blue points are actual data points of current at a certain command during the flight.
