-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Implement ESC Minimum RPM Check Before Takeoff #27696
base: master
Are you sure you want to change the base?
Changes from all commits
72085c8
55f72b4
8478e75
369c190
c335908
6ce7d5a
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 |
---|---|---|
|
@@ -538,6 +538,21 @@ const AP_Param::GroupInfo QuadPlane::var_info2[] = { | |
// @User: Standard | ||
AP_GROUPINFO("BCK_PIT_LIM", 38, QuadPlane, q_bck_pitch_lim, 10.0f), | ||
|
||
#if HAL_WITH_ESC_TELEM | ||
// @Param: TKOFF_RPM_MIN | ||
// @DisplayName: Takeoff Check RPM minimum | ||
// @Description: Takeoff is not permitted until motors report at least this RPM. Set to zero to disable check | ||
// @Range: 0 10000 | ||
// @User: Standard | ||
AP_GROUPINFO("TKOFF_RPM_MIN", 39, QuadPlane, takeoff_rpm_min, 0), | ||
// @Param: TKOFF_RPM_MAX | ||
// @DisplayName: Takeoff Check RPM maximum | ||
// @Description: Takeoff is not permitted until motors report no more than this RPM. Set to zero to disable check | ||
// @Range: 0 10000 | ||
// @User: Standard | ||
AP_GROUPINFO("TKOFF_RPM_MAX", 40, QuadPlane, takeoff_rpm_max, 0), | ||
#endif | ||
|
||
AP_GROUPEND | ||
}; | ||
|
||
|
@@ -1926,6 +1941,11 @@ void QuadPlane::update_throttle_hover() | |
*/ | ||
void QuadPlane::motors_output(bool run_rate_controller) | ||
{ | ||
#if HAL_WITH_ESC_TELEM | ||
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. I'd much rather have this in QuadPlane::takeoff_controller(), and operate just like the existing check for tiltrotor.fully_up() |
||
const bool allow_spoolup_block = in_vtol_takeoff() && (motors->get_spool_state() == AP_Motors::SpoolState::GROUND_IDLE || motors->get_spool_state() == AP_Motors::SpoolState::SHUT_DOWN); | ||
plane.motors_takeoff_check(takeoff_rpm_min, takeoff_rpm_max, allow_spoolup_block); | ||
#endif | ||
|
||
/* Delay for ARMING_DELAY_MS after arming before allowing props to spin: | ||
1) for safety (OPTION_DELAY_ARMING) | ||
2) to allow motors to return to vertical (OPTION_DISARMED_TILT) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -612,6 +612,11 @@ class QuadPlane | |
// AHRS alt for land abort and package place, meters | ||
float land_descend_start_alt; | ||
|
||
// support for blocking takeoff until RPMs reach parameter-defined | ||
// minimum levels: | ||
AP_Float takeoff_rpm_min; | ||
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. these are AP_Int16 in copter, we should make them the same type in plane 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. needs #if HAL_WITH_ESC_TELEM around these |
||
AP_Float takeoff_rpm_max; | ||
|
||
// min alt for navigation in takeoff | ||
AP_Float takeoff_navalt_min; | ||
uint32_t takeoff_last_run_ms; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <AP_HAL/AP_HAL_Boards.h> | ||
|
||
#ifndef AP_MOTORS_ENABLED | ||
#define AP_MOTORS_ENABLED 1 | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "AP_Vehicle.h" | ||
|
||
#include <AP_Motors/AP_Motors.h> | ||
#include <GCS_MAVLink/GCS.h> | ||
|
||
#if AP_MOTORS_ENABLED && HAL_WITH_ESC_TELEM | ||
void AP_Vehicle::motors_takeoff_check(float rpm_min, float rpm_max, bool land_complete) | ||
{ | ||
auto motors = AP::motors(); | ||
|
||
// If takeoff check is disabled or vehicle is armed and flying then clear block and return | ||
if ((rpm_min <= 0) || (motors->armed() && !land_complete)) { | ||
motors->set_spoolup_block(false); | ||
return; | ||
} | ||
|
||
// block takeoff when disarmed but do not display warnings | ||
if (!motors->armed()) { | ||
motors->set_spoolup_block(true); | ||
takeoff_check_state.warning_ms = 0; | ||
return; | ||
} | ||
|
||
// if motors have become unblocked return immediately | ||
// this ensures the motors can only be blocked immediate after arming | ||
if (!motors->get_spoolup_block()) { | ||
return; | ||
} | ||
|
||
// check ESCs are sending RPM at expected level | ||
uint32_t motor_mask = motors->get_motor_mask(); | ||
const bool telem_active = AP::esc_telem().is_telemetry_active(motor_mask); | ||
const bool rpm_adequate = AP::esc_telem().are_motors_running(motor_mask, rpm_min, rpm_max); | ||
|
||
// if RPM is at the expected level clear block | ||
if (telem_active && rpm_adequate) { | ||
motors->set_spoolup_block(false); | ||
return; | ||
} | ||
|
||
// warn user telem inactive or rpm is inadequate every 5 seconds | ||
uint32_t now_ms = AP_HAL::millis(); | ||
if (takeoff_check_state.warning_ms == 0) { | ||
takeoff_check_state.warning_ms = now_ms; | ||
} | ||
if (now_ms - takeoff_check_state.warning_ms > 5000) { | ||
takeoff_check_state.warning_ms = now_ms; | ||
const char* prefix_str = "Takeoff blocked:"; | ||
if (!telem_active) { | ||
gcs().send_text(MAV_SEVERITY_CRITICAL, "%s waiting for ESC RPM", prefix_str); | ||
} else if (!rpm_adequate) { | ||
gcs().send_text(MAV_SEVERITY_CRITICAL, "%s ESC RPM out of range", prefix_str); | ||
} | ||
} | ||
} | ||
|
||
#endif // AP_MOTORS_ENABLED && HAL_WITH_ESC_TELEM |
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.
a blank line between params helps readability