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

Copter: Prevent Auto-Mode Tipovers caused by missing takeoff command #4102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions ArduCopter/control_auto.cpp
Expand Up @@ -37,6 +37,10 @@ bool Copter::auto_init(bool ignore_checks)
// clear guided limits
guided_limit_clear();

// Deny switching to auto mode if land is completed and motors are armed but the next command in the mission is lateral flying
if (motors.armed() && ap.land_complete && !mission.check_takeoff_cmd()) {
return false;
}
// start/resume the mission (based on MIS_RESTART parameter)
mission.start_or_resume();
return true;
Expand Down
24 changes: 24 additions & 0 deletions libraries/AP_Mission/AP_Mission.cpp
Expand Up @@ -113,6 +113,30 @@ void AP_Mission::resume()
}
}

// return false if next command in the mission is not takeoff
bool AP_Mission::check_takeoff_cmd()
{
Mission_Command cmd = {};
uint16_t cmd_index;

// get starting point for search or Reset cmd_index, if _restart is set
cmd_index = _restart ? AP_MISSION_CMD_INDEX_NONE : _nav_cmd.index;

if (cmd_index == AP_MISSION_CMD_INDEX_NONE) {
// start from beginning of the mission command list
cmd_index = AP_MISSION_FIRST_REAL_COMMAND;
get_next_cmd(cmd_index, cmd, true);

} else {
read_cmd_from_storage(cmd_index, cmd);
}

if (cmd.id != MAV_CMD_NAV_TAKEOFF) {
return false;
}
return true;
}

/// start_or_resume - if MIS_AUTORESTART=0 this will call resume(), otherwise it will call start()
void AP_Mission::start_or_resume()
{
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Mission/AP_Mission.h
Expand Up @@ -292,6 +292,7 @@ class AP_Mission {

/// start_or_resume - if MIS_AUTORESTART=0 this will call resume(), otherwise it will call start()
void start_or_resume();
bool check_takeoff_cmd();

/// reset - reset mission to the first command
void reset();
Expand Down