Skip to content

Commit

Permalink
Orbit failsafe: switch internal_state to Posctrl such that Manual-Pos…
Browse files Browse the repository at this point in the history
…itionctrl is activated after failsafe recovery. This is needed because Orbit can only be invoked via vehicle_command msg.
  • Loading branch information
Dennis Mannhart authored and bresch committed Aug 15, 2019
1 parent 82ecf4d commit bf25c46
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/modules/commander/state_machine_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,22 +593,39 @@ bool set_nav_state(vehicle_status_s *status, actuator_armed_s *armed, commander_
// failsafe: on engine failure
status->nav_state = vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL;

// Orbit can only be started via vehicle_command (mavlink). Recovery from failsafe into orbit
// is not possible and therefore the internal_state needs to be adjusted.
internal_state->main_state = commander_state_s::MAIN_STATE_POSCTL;

} else if (is_armed && check_invalid_pos_nav_state(status, old_failsafe, mavlink_log_pub, status_flags, false, true)) {
// failsafe: necessary position estimate lost (nothing to do - everything done in check_invalid_pos_nav_state)
// failsafe: necessary position estimate lost; witching is done in check_invalid_pos_nav_state

// Orbit can only be started via vehicle_command (mavlink). Consequently, recovery from failsafe into orbit
// is not possible and therefore the internal_state needs to be adjusted.
internal_state->main_state = commander_state_s::MAIN_STATE_POSCTL;

} else if (status->data_link_lost && data_link_loss_act_configured && !landed && is_armed) {
// failsafe: just datalink is lost and we're in air
set_link_loss_nav_state(status, armed, status_flags, internal_state, data_link_loss_act,
vehicle_status_s::NAVIGATION_STATE_AUTO_RTGS);

enable_failsafe(status, old_failsafe, mavlink_log_pub, reason_no_datalink);

// Orbit can only be started via vehicle_command (mavlink). Consequently, recovery from failsafe into orbit
// is not possible and therefore the internal_state needs to be adjusted.
internal_state->main_state = commander_state_s::MAIN_STATE_POSCTL;

} else if (rc_lost && !data_link_loss_act_configured && is_armed) {
// failsafe: RC is lost, datalink loss is not set up and rc loss is not disabled
enable_failsafe(status, old_failsafe, mavlink_log_pub, reason_no_rc);

set_link_loss_nav_state(status, armed, status_flags, internal_state, rc_loss_act,
vehicle_status_s::NAVIGATION_STATE_AUTO_RCRECOVER);

// Orbit can only be started via vehicle_command (mavlink). Consequently, recovery from failsafe into orbit
// is not possible and therefore the internal_state needs to be adjusted.
internal_state->main_state = commander_state_s::MAIN_STATE_POSCTL;

} else {
// no failsafe, RC is not mandatory for orbit
status->nav_state = vehicle_status_s::NAVIGATION_STATE_ORBIT;
Expand Down

0 comments on commit bf25c46

Please sign in to comment.