Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane: Fix RTL behaviour when MIS_RESTART = 1 and DO_LAND_START present. #13652

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ArduPlane/ArduPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ void Plane::update_navigation()
// we've reached the RTL point, see if we have a landing sequence
if (mission.jump_to_landing_sequence()) {
// switch from RTL -> AUTO
mission.set_force_resume(true);
set_mode(mode_auto, ModeReason::UNKNOWN);
}

Expand All @@ -479,6 +480,7 @@ void Plane::update_navigation()
// Go directly to the landing sequence
if (mission.jump_to_landing_sequence()) {
// switch from RTL -> AUTO
mission.set_force_resume(true);
set_mode(mode_auto, ModeReason::UNKNOWN);
}

Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_Mission/AP_Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ bool AP_Mission::starts_with_takeoff_cmd()
/// start_or_resume - if MIS_AUTORESTART=0 this will call resume(), otherwise it will call start()
void AP_Mission::start_or_resume()
{
if (_restart) {
if (_restart == 1 && !_force_resume) {
start();
} else {
resume();
_force_resume = false;
}
}

Expand Down
5 changes: 5 additions & 0 deletions libraries/AP_Mission/AP_Mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class AP_Mission {
_flags.nav_cmd_loaded = false;
_flags.do_cmd_loaded = false;
_flags.in_landing_sequence = false;
_force_resume = false;
}

// get singleton instance
Expand Down Expand Up @@ -479,6 +480,9 @@ class AP_Mission {
// set in_landing_sequence flag
void set_in_landing_sequence_flag(bool flag) { _flags.in_landing_sequence = flag; }

// force mission to resume when start_or_resume() is called
void set_force_resume(bool force_resume) { _force_resume = force_resume; }

// get a reference to the AP_Mission semaphore, allowing an external caller to lock the
// storage while working with multiple waypoints
HAL_Semaphore &get_semaphore(void) {
Expand Down Expand Up @@ -582,6 +586,7 @@ class AP_Mission {
uint16_t _prev_nav_cmd_id; // id of the previous "navigation" command. (WAYPOINT, LOITER_TO_ALT, ect etc)
uint16_t _prev_nav_cmd_index; // index of the previous "navigation" command. Rarely used which is why we don't store the whole command
uint16_t _prev_nav_cmd_wp_index; // index of the previous "navigation" command that contains a waypoint. Rarely used which is why we don't store the whole command
bool _force_resume; // when set true it forces mission to resume irrespective of MIS_RESTART param.

// jump related variables
struct jump_tracking_struct {
Expand Down