ArduPlane: parameterize lookahead climb ratio

This commit is contained in:
timtuxworth 2024-12-16 14:59:58 -07:00
parent aec7cc24d1
commit 4da32dcb06
3 changed files with 12 additions and 2 deletions

View File

@ -1304,6 +1304,14 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
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
};

View File

@ -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[];

View File

@ -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