mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 07:44:03 -04:00
Plane: move loiter heading init for auto into auto helper, and properly reset it in loiter mode enter
This commit is contained in:
parent
fd4b7c823e
commit
ec8f82422a
@ -1074,5 +1074,9 @@ bool Plane::verify_loiter_heading(bool init)
|
||||
return true;
|
||||
}
|
||||
|
||||
return plane.mode_loiter.headingLinedUp(init, next_WP_loc, next_nav_cmd.content.location);
|
||||
if (init) {
|
||||
loiter.sum_cd = 0;
|
||||
}
|
||||
|
||||
return plane.mode_loiter.headingLinedUp(next_WP_loc, next_nav_cmd.content.location);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
// methods that affect movement of the vehicle in this mode
|
||||
void update() override;
|
||||
|
||||
bool headingLinedUp(const bool init, const Location loiterCenterLoc, const Location targetLoc);
|
||||
bool headingLinedUp(const Location loiterCenterLoc, const Location targetLoc);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -7,6 +7,7 @@ bool ModeLoiter::_enter()
|
||||
plane.auto_throttle_mode = true;
|
||||
plane.auto_navigation_mode = true;
|
||||
plane.do_loiter_at_location();
|
||||
plane.loiter_angle_reset();
|
||||
|
||||
#if SOARING_ENABLED == ENABLED
|
||||
if (plane.g2.soaring_controller.is_active() && plane.g2.soaring_controller.suppress_throttle()) {
|
||||
@ -25,7 +26,7 @@ void ModeLoiter::update()
|
||||
plane.calc_throttle();
|
||||
}
|
||||
|
||||
bool ModeLoiter::headingLinedUp(const bool init, const Location loiterCenterLoc, const Location targetLoc)
|
||||
bool ModeLoiter::headingLinedUp(const Location loiterCenterLoc, const Location targetLoc)
|
||||
{
|
||||
const uint16_t loiterRadius = abs(plane.aparm.loiter_radius);
|
||||
if (loiterCenterLoc.get_distance(targetLoc) < loiterRadius + loiterRadius*0.05) {
|
||||
@ -44,10 +45,6 @@ bool ModeLoiter::headingLinedUp(const bool init, const Location loiterCenterLoc,
|
||||
|
||||
const int32_t heading_err_cd = wrap_180_cd(bearing_cd - heading_cd);
|
||||
|
||||
if (init) {
|
||||
plane.loiter.sum_cd = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Check to see if the the plane is heading toward the land
|
||||
waypoint. We use 20 degrees (+/-10 deg) of margin so that
|
||||
|
@ -79,7 +79,7 @@ void Plane::update_soaring() {
|
||||
switch (loiterStatus) {
|
||||
case SoaringController::LoiterStatus::ALT_TOO_HIGH: {
|
||||
const bool homeIsSet = AP::ahrs().home_is_set();
|
||||
const bool headingLinedupToHome = homeIsSet && plane.mode_loiter.headingLinedUp(false, next_WP_loc, AP::ahrs().get_home());
|
||||
const bool headingLinedupToHome = homeIsSet && plane.mode_loiter.headingLinedUp(next_WP_loc, AP::ahrs().get_home());
|
||||
if (!homeIsSet || headingLinedupToHome) {
|
||||
gcs().send_text(MAV_SEVERITY_INFO, "%s%s", strTooHigh, mode_fbwb.name());
|
||||
set_mode(mode_fbwb, ModeReason::SOARING_ALT_TOO_HIGH);
|
||||
@ -137,7 +137,7 @@ void Plane::update_soaring() {
|
||||
//Get the lat/lon of next Nav waypoint after this one:
|
||||
AP_Mission::Mission_Command next_nav_cmd;
|
||||
const bool nextWpisValid = mission.get_next_nav_cmd(mission.get_current_nav_index() + 1, next_nav_cmd);
|
||||
const bool headingLinedupToWP = nextWpisValid && plane.mode_loiter.headingLinedUp(false, next_WP_loc, next_nav_cmd.content.location);
|
||||
const bool headingLinedupToWP = nextWpisValid && plane.mode_loiter.headingLinedUp(next_WP_loc, next_nav_cmd.content.location);
|
||||
if (!nextWpisValid || headingLinedupToWP) {
|
||||
gcs().send_text(MAV_SEVERITY_INFO, "%s%s", strTooWeak, mode_auto.name());
|
||||
set_mode(mode_auto, ModeReason::SOARING_THERMAL_ESTIMATE_DETERIORATED);
|
||||
|
Loading…
Reference in New Issue
Block a user