Skip to content

Commit

Permalink
Commander: Fall back to GPS enabled modes once GPS becomes available
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzMeier committed Feb 16, 2017
1 parent 7bd8514 commit f033de2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/modules/commander/commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ static uint64_t rc_signal_lost_timestamp; // Time at which the RC reception was
static float avionics_power_rail_voltage; // voltage of the avionics power rail

static bool can_arm_without_gps = false;
static bool _last_condition_global_position_valid = false;


/**
Expand Down Expand Up @@ -2706,6 +2707,9 @@ int commander_thread_main(int argc, char *argv[])
bool first_rc_eval = (_last_sp_man.timestamp == 0) && (sp_man.timestamp > 0);
transition_result_t main_res = set_main_state_rc(&status);

/* store last position lock state */
_last_condition_global_position_valid = status_flags.condition_global_position_valid;

/* play tune on mode change only if armed, blink LED always */
if (main_res == TRANSITION_CHANGED || first_rc_eval) {
tune_positive(armed.armed);
Expand Down Expand Up @@ -3267,15 +3271,17 @@ set_main_state_rc(struct vehicle_status_s *status_local)
// feature, just in case offboard control goes crazy.

/* manual setpoint has not updated, do not re-evaluate it */
if (((_last_sp_man.timestamp != 0) && (_last_sp_man.timestamp == sp_man.timestamp)) ||
if (!(!_last_condition_global_position_valid &&
status_flags.condition_global_position_valid)
&& (((_last_sp_man.timestamp != 0) && (_last_sp_man.timestamp == sp_man.timestamp)) ||
((_last_sp_man.offboard_switch == sp_man.offboard_switch) &&
(_last_sp_man.return_switch == sp_man.return_switch) &&
(_last_sp_man.mode_switch == sp_man.mode_switch) &&
(_last_sp_man.acro_switch == sp_man.acro_switch) &&
(_last_sp_man.rattitude_switch == sp_man.rattitude_switch) &&
(_last_sp_man.posctl_switch == sp_man.posctl_switch) &&
(_last_sp_man.loiter_switch == sp_man.loiter_switch) &&
(_last_sp_man.mode_slot == sp_man.mode_slot))) {
(_last_sp_man.mode_slot == sp_man.mode_slot)))) {

// update these fields for the geofence system

Expand Down

0 comments on commit f033de2

Please sign in to comment.