Skip to content

Commit

Permalink
fix rtl: ensure mode_completed is called when finished
Browse files Browse the repository at this point in the history
set_rtl_item() is not called if 'rtl_state == RTLState::IDLE'
  • Loading branch information
bkueng committed Dec 8, 2023
1 parent 4cfaf4a commit 2e5a281
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/modules/navigator/rtl_direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,21 @@ void RtlDirect::set_rtl_item()

startPrecLand(_mission_item.land_precision);

_rtl_state = RTLState::IDLE;
_rtl_state = RTLState::COMPLETED;

mavlink_log_info(_navigator->get_mavlink_log_pub(), "RTL: land at destination\t");
events::send(events::ID("rtl_land_at_destination"), events::Log::Info, "RTL: land at destination");
break;
}

case RTLState::IDLE: {
case RTLState::COMPLETED: {
set_idle_item(&_mission_item);
_navigator->mode_completed(vehicle_status_s::NAVIGATION_STATE_AUTO_RTL);
_rtl_state = RTLState::IDLE;
break;
}

case RTLState::IDLE:
default:
break;
}
Expand Down Expand Up @@ -489,6 +491,7 @@ rtl_time_estimate_s RtlDirect::calc_rtl_time_estimate()

break;

case RTLState::COMPLETED:
case RTLState::IDLE:
// Remaining time is 0
break;
Expand Down
1 change: 1 addition & 0 deletions src/modules/navigator/rtl_direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class RtlDirect : public MissionBlock, public ModuleParams
TRANSITION_TO_MC,
MOVE_TO_LAND_HOVER,
LAND,
COMPLETED,
IDLE
} _rtl_state{RTLState::IDLE}; /*< Current state in the state machine.*/

Expand Down

0 comments on commit 2e5a281

Please sign in to comment.