From 4da32dcb06a4482afe3e6bc60b0244759d8bd7e3 Mon Sep 17 00:00:00 2001 From: timtuxworth Date: Mon, 16 Dec 2024 14:59:58 -0700 Subject: [PATCH] ArduPlane: parameterize lookahead climb ratio --- ArduPlane/Parameters.cpp | 10 +++++++++- ArduPlane/Parameters.h | 2 ++ ArduPlane/altitude.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index 8dcd235220..d9bca9b364 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1303,7 +1303,15 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("RNGFND_LND_ORNT", 36, ParametersG2, rangefinder_land_orient, ROTATION_PITCH_270), #endif - + + // @Param: PTCH_LKAHD_CLMB + // @DisplayName: lookahead climb pitch ratio + // @Description: The ratio of pitch to use when doing a terrain lookahead so the plane is not constantly at 100% throttle. + // @Range: 0 100 + // @Units: % + // @User: Standard + AP_GROUPINFO("PTCH_LKAHD_CLMB", 37, ParametersG2, pitch_lookahead_climb_ratio, 50), + AP_GROUPEND }; diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index e7cc5326f4..b0086c0070 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -588,6 +588,8 @@ public: // orientation of rangefinder to use for landing AP_Int8 rangefinder_land_orient; #endif + + AP_Float pitch_lookahead_climb_ratio; }; extern const AP_Param::Info var_info[]; diff --git a/ArduPlane/altitude.cpp b/ArduPlane/altitude.cpp index 230a16d067..3495a49496 100644 --- a/ArduPlane/altitude.cpp +++ b/ArduPlane/altitude.cpp @@ -605,7 +605,7 @@ float Plane::lookahead_adjustment(void) // we need to know the climb ratio. We use 50% of the maximum // climb rate so we are not constantly at 100% throttle and to // give a bit more margin on terrain - float climb_ratio = 0.5f * TECS_controller.get_max_climbrate() / groundspeed; + float climb_ratio = g2.pitch_lookahead_climb_ratio * TECS_controller.get_max_climbrate() / groundspeed; if (climb_ratio <= 0) { // lookahead makes no sense for negative climb rates