From e185bab775eedf7ea97e4aa7aff1994ea65edd6b Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 16 Jun 2016 14:28:49 +0900 Subject: [PATCH] AP_MotorsMulticopter: add HOVER_LEARN option to learn but not save --- libraries/AP_Motors/AP_MotorsMulticopter.cpp | 8 ++++---- libraries/AP_Motors/AP_MotorsMulticopter.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.cpp b/libraries/AP_Motors/AP_MotorsMulticopter.cpp index a076aa3ec9..487d6d0f95 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.cpp +++ b/libraries/AP_Motors/AP_MotorsMulticopter.cpp @@ -134,9 +134,9 @@ const AP_Param::GroupInfo AP_MotorsMulticopter::var_info[] = { // @Param: HOVER_LEARN // @DisplayName: Hover Value Learning // @Description: Enable/Disable automatic learning of hover throttle - // @Values: 0:Disabled, 1:Enabled + // @Values: 0:Disabled, 1:Learn, 2:LearnAndSave // @User: Advanced - AP_GROUPINFO("HOVER_LEARN", 22, AP_MotorsMulticopter, _throttle_hover_learn, 1), + AP_GROUPINFO("HOVER_LEARN", 22, AP_MotorsMulticopter, _throttle_hover_learn, HOVER_LEARN_AND_SAVE), AP_GROUPEND }; @@ -374,7 +374,7 @@ void AP_MotorsMulticopter::set_throttle_range(int16_t radio_min, int16_t radio_m // update the throttle input filter. should be called at 100hz void AP_MotorsMulticopter::update_throttle_hover(float dt) { - if (_throttle_hover_learn > 0) { + if (_throttle_hover_learn != HOVER_LEARN_DISABLED) { _throttle_hover = _throttle_hover + (dt/(dt+AP_MOTORS_THST_HOVER_TC))*(_throttle_in-_throttle_hover); } } @@ -570,7 +570,7 @@ void AP_MotorsMulticopter::output_motor_mask(float thrust, uint8_t mask) void AP_MotorsMulticopter::save_params_on_disarm() { // save hover throttle - if (_throttle_hover_learn > 0) { + if (_throttle_hover_learn == HOVER_LEARN_AND_SAVE) { _throttle_hover.save(); } } diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.h b/libraries/AP_Motors/AP_MotorsMulticopter.h index d463a9aca5..a94d304d6f 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.h +++ b/libraries/AP_Motors/AP_MotorsMulticopter.h @@ -140,6 +140,13 @@ protected: // save parameters as part of disarming void save_params_on_disarm(); + // enum values for HOVER_LEARN parameter + enum HoverLearn { + HOVER_LEARN_DISABLED = 0, + HOVER_LEARN_ONLY = 1, + HOVER_LEARN_AND_SAVE = 2 + }; + // parameters AP_Int16 _yaw_headroom; // yaw control is given at least this pwm range AP_Float _thrust_curve_expo; // curve used to linearize pwm to thrust conversion. set to 0 for linear and 1 for second order approximation