mirror of https://github.com/ArduPilot/ardupilot
Plane: implement RTL_CLIMB_MIN parameter
this allows for an initial climb on RTL where roll is limited to LEVEL_ROLL_LIMIT
This commit is contained in:
parent
7220abfc27
commit
8d93094dcf
|
@ -582,7 +582,16 @@ void Plane::update_alt()
|
|||
}
|
||||
#endif
|
||||
|
||||
SpdHgt_Controller->update_pitch_throttle(relative_target_altitude_cm(),
|
||||
float target_alt = relative_target_altitude_cm();
|
||||
|
||||
if (control_mode == &mode_rtl && !rtl.done_climb && g2.rtl_climb_min > 0) {
|
||||
// ensure we do the initial climb in RTL. We add an extra
|
||||
// 10m in the demanded height to push TECS to climb
|
||||
// quickly
|
||||
target_alt = MAX(target_alt, prev_WP_loc.alt + (g2.rtl_climb_min+10)*100);
|
||||
}
|
||||
|
||||
SpdHgt_Controller->update_pitch_throttle(target_alt,
|
||||
target_airspeed_cm,
|
||||
flight_stage,
|
||||
distance_beyond_land_wp,
|
||||
|
|
|
@ -1262,6 +1262,15 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
|
|||
// @User: Advanced
|
||||
AP_GROUPINFO("FWD_BAT_IDX", 25, ParametersG2, fwd_thr_batt_idx, 0),
|
||||
|
||||
// @Param: RTL_CLIMB_MIN
|
||||
// @DisplayName: RTL minimum climb
|
||||
// @Description: The vehicle will climb this many m during the initial climb portion of the RTL. During this time the roll will be limited to LEVEL_ROLL_LIMIT degrees.
|
||||
// @Units: m
|
||||
// @Range: 0 30
|
||||
// @Increment: 1
|
||||
// @User: Standard
|
||||
AP_GROUPINFO("RTL_CLIMB_MIN", 27, ParametersG2, rtl_climb_min, 0),
|
||||
|
||||
AP_GROUPEND
|
||||
};
|
||||
|
||||
|
|
|
@ -569,6 +569,9 @@ public:
|
|||
AP_Float fwd_thr_batt_voltage_max;
|
||||
AP_Float fwd_thr_batt_voltage_min;
|
||||
AP_Int8 fwd_thr_batt_idx;
|
||||
|
||||
// min initial climb in RTL
|
||||
AP_Int16 rtl_climb_min;
|
||||
};
|
||||
|
||||
extern const AP_Param::Info var_info[];
|
||||
|
|
|
@ -746,6 +746,10 @@ private:
|
|||
uint32_t last_trim_save;
|
||||
} auto_trim;
|
||||
|
||||
struct {
|
||||
bool done_climb;
|
||||
} rtl;
|
||||
|
||||
// last time home was updated while disarmed
|
||||
uint32_t last_home_update_ms;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ bool ModeRTL::_enter()
|
|||
plane.auto_navigation_mode = true;
|
||||
plane.prev_WP_loc = plane.current_loc;
|
||||
plane.do_RTL(plane.get_RTL_altitude());
|
||||
plane.rtl.done_climb = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -17,5 +18,19 @@ void ModeRTL::update()
|
|||
plane.calc_nav_roll();
|
||||
plane.calc_nav_pitch();
|
||||
plane.calc_throttle();
|
||||
|
||||
if (plane.g2.rtl_climb_min > 0) {
|
||||
/*
|
||||
when RTL first starts limit bank angle to LEVEL_ROLL_LIMIT
|
||||
until we have climbed by RTL_CLIMB_MIN meters
|
||||
*/
|
||||
if (!plane.rtl.done_climb && (plane.current_loc.alt - plane.prev_WP_loc.alt)*0.01 > plane.g2.rtl_climb_min) {
|
||||
plane.rtl.done_climb = true;
|
||||
}
|
||||
if (!plane.rtl.done_climb) {
|
||||
plane.roll_limit_cd = MIN(plane.roll_limit_cd, plane.g.level_roll_limit*100);
|
||||
plane.nav_roll_cd = constrain_int32(plane.nav_roll_cd, -plane.roll_limit_cd, plane.roll_limit_cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue