-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Improvement iteration for under- and new overcurrent motor failure detection #26262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b8d7afa
583e240
1661185
34fb985
612a160
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,7 @@ void EscChecks::checkAndReport(const Context &context, Report &reporter) | |||||
| checkEscStatus(context, reporter, esc_status); | ||||||
| reporter.setIsPresent(health_component_t::motors_escs); | ||||||
|
|
||||||
| } else if (_param_escs_checks_required.get() | ||||||
| } else if (_param_com_arm_chk_escs.get() | ||||||
| && now - _start_time > 5_s) { // Wait a bit after startup to allow esc's to init | ||||||
|
|
||||||
| /* EVENT | ||||||
|
|
@@ -102,40 +102,37 @@ void EscChecks::checkAndReport(const Context &context, Report &reporter) | |||||
|
|
||||||
| void EscChecks::checkEscStatus(const Context &context, Report &reporter, const esc_status_s &esc_status) | ||||||
| { | ||||||
| const NavModes required_modes = _param_escs_checks_required.get() ? NavModes::All : NavModes::None; | ||||||
| const NavModes required_modes = _param_com_arm_chk_escs.get() ? NavModes::All : NavModes::None; | ||||||
|
|
||||||
| if (esc_status.esc_count > 0) { | ||||||
|
|
||||||
| // Check if one or more the ESCs are offline | ||||||
| char esc_fail_msg[50]; | ||||||
| esc_fail_msg[0] = '\0'; | ||||||
|
|
||||||
| int online_bitmask = (1 << esc_status.esc_count) - 1; | ||||||
|
|
||||||
| // Check if one or more the ESCs are offline | ||||||
| if (online_bitmask != esc_status.esc_online_flags) { | ||||||
|
|
||||||
| for (int index = 0; index < esc_status.esc_count; index++) { | ||||||
| if ((esc_status.esc_online_flags & (1 << index)) == 0) { | ||||||
| uint8_t motor_index = esc_status.esc[index].actuator_function - actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1 + 1; | ||||||
| /* EVENT | ||||||
| * @description | ||||||
| * <profile name="dev"> | ||||||
| * This check can be configured via <param>COM_ARM_CHK_ESCS</param> parameter. | ||||||
| * </profile> | ||||||
| */ | ||||||
| reporter.healthFailure<uint8_t>(required_modes, health_component_t::motors_escs, events::ID("check_escs_offline"), | ||||||
| events::Log::Critical, "ESC {1} offline", motor_index); | ||||||
| snprintf(esc_fail_msg + strlen(esc_fail_msg), sizeof(esc_fail_msg) - strlen(esc_fail_msg), "ESC%d ", motor_index); | ||||||
| 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, | ||||||
| uint8_t(actuator_motors_s::ACTUATOR_FUNCTION_MOTOR1 + actuator_motors_s::NUM_CONTROLS - 1)); | ||||||
| const bool offline = (esc_status.esc_online_flags & (1 << i)) == 0; | ||||||
|
|
||||||
| if (mapped && offline) { | ||||||
| /* EVENT | ||||||
| * @description | ||||||
| * <profile name="dev"> | ||||||
| * This check can be configured via <param>COM_ARM_CHK_ESCS</param> parameter. | ||||||
| * </profile> | ||||||
| */ | ||||||
| reporter.healthFailure<uint8_t>(required_modes, health_component_t::motors_escs, events::ID("check_escs_offline"), | ||||||
| events::Log::Critical, "ESC {1} offline", i + 1); | ||||||
| snprintf(esc_fail_msg + strlen(esc_fail_msg), sizeof(esc_fail_msg) - strlen(esc_fail_msg), "ESC%d ", i + 1); | ||||||
| esc_fail_msg[sizeof(esc_fail_msg) - 1] = '\0'; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (reporter.mavlink_log_pub()) { | ||||||
| mavlink_log_critical(reporter.mavlink_log_pub(), "%soffline. %s\t", esc_fail_msg, context.isArmed() ? "Land now!" : ""); | ||||||
| } | ||||||
| if ((esc_fail_msg[0] != '\0') && reporter.mavlink_log_pub()) { | ||||||
| mavlink_log_critical(reporter.mavlink_log_pub(), "%soffline. %s\t", esc_fail_msg, context.isArmed() ? "Land now!" : ""); | ||||||
| } | ||||||
|
|
||||||
| 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) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
you should still iterate over
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep it the proposed way, as it is more conservative and change it to your suggested way in the next iteration?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
|
|
||||||
| if (esc_status.esc[index].failures != 0) { | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is mapped as motor? I'll check 🤔 👍
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.