Plane: only activate mission callbacks in AUTO mode

This commit is contained in:
Andrew Tridgell 2014-03-14 13:48:58 +11:00 committed by Randy Mackay
parent 3277416aeb
commit 2b5bf45e83
2 changed files with 37 additions and 14 deletions

View File

@ -575,12 +575,12 @@ static int32_t nav_pitch_cd;
////////////////////////////////////////////////////////////////////////////////
// Mission library
// forward declaration to keep compiler happy
////////////////////////////////////////////////////////////////////////////////
static bool start_command(const AP_Mission::Mission_Command& cmd);
static bool verify_command(const AP_Mission::Mission_Command& cmd);
static void exit_mission();
AP_Mission mission(ahrs, &start_command, &verify_command, &exit_mission, MISSION_START_BYTE, MISSION_END_BYTE);
AP_Mission mission(ahrs,
&start_command_callback,
&verify_command_callback,
&exit_mission_callback,
MISSION_START_BYTE, MISSION_END_BYTE);
////////////////////////////////////////////////////////////////////////////////
// Waypoint distances

View File

@ -14,6 +14,11 @@ static void do_change_speed(const AP_Mission::Mission_Command& cmd);
static void do_set_home(const AP_Mission::Mission_Command& cmd);
static AP_Mission::Mission_Command rally_find_best_cmd(const Location &myloc, const Location &homeloc);
/********************************************************************************/
// Command Event Handlers
/********************************************************************************/
/********************************************************************************/
// Command Event Handlers
/********************************************************************************/
@ -155,15 +160,6 @@ start_command(const AP_Mission::Mission_Command& cmd)
return true;
}
static void exit_mission()
{
gcs_send_text_fmt(PSTR("Returning to Home"));
next_nav_command = rally_find_best_cmd(current_loc, home);
next_nav_command.id = MAV_CMD_NAV_LOITER_UNLIM;
setup_glide_slope();
start_command(next_nav_command);
}
/*******************************************************************************
Verify command Handlers
@ -587,3 +583,30 @@ static void do_take_picture()
}
#endif
}
static bool verify_command_callback(const AP_Mission::Mission_Command& cmd)
{
if (control_mode == AUTO) {
return verify_command(cmd);
}
return false;
}
static void exit_mission_callback()
{
if (control_mode == AUTO) {
gcs_send_text_fmt(PSTR("Returning to Home"));
next_nav_command = rally_find_best_cmd(current_loc, home);
next_nav_command.id = MAV_CMD_NAV_LOITER_UNLIM;
setup_glide_slope();
start_command(next_nav_command);
}
}
static bool start_command_callback(const AP_Mission::Mission_Command &cmd)
{
if (control_mode == AUTO) {
return start_command(cmd);
}
return true;
}