Skip to content

Commit

Permalink
ArduPlane: parameterize lookahead climb ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
timtuxworth committed Dec 16, 2024
1 parent aec7cc2 commit b2bc7c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ArduPlane/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
1 change: 1 addition & 0 deletions ArduPlane/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ class ParametersG2 {
// 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[];
2 changes: 1 addition & 1 deletion ArduPlane/altitude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2bc7c5

Please sign in to comment.