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

Plane: Respect frame type on VTOL_TAKEOFF commands #9186

Merged
merged 4 commits into from Sep 10, 2018
Merged
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: 2 additions & 2 deletions ArduCopter/mode_auto.cpp
Expand Up @@ -534,8 +534,8 @@ bool Copter::ModeAuto::start_command(const AP_Mission::Mission_Command& cmd)
#endif

default:
// do nothing with unrecognized MAVLink messages
break;
// unable to use the command, allow the vehicle to try the next command
return false;
}

// always return success
Expand Down
4 changes: 4 additions & 0 deletions ArduPlane/commands_logic.cpp
Expand Up @@ -244,6 +244,10 @@ bool Plane::start_command(const AP_Mission::Mission_Command& cmd)
}
break;
#endif

default:
// unable to use the command, allow the vehicle to try the next command
return false;
}

return true;
Expand Down
13 changes: 10 additions & 3 deletions ArduPlane/quadplane.cpp
Expand Up @@ -327,8 +327,8 @@ const AP_Param::GroupInfo QuadPlane::var_info[] = {

// @Param: OPTIONS
// @DisplayName: quadplane options
// @Description: This provides a set of additional control options for quadplanes. LevelTransition means that the wings should be held level to within LEVEL_ROLL_LIMIT degrees during transition to fixed wing flight. If AllowFWTakeoff bit is not set then fixed wing takeoff on quadplanes will instead perform a VTOL takeoff. If AllowFWLand bit is not set then fixed wing land on quadplanes will instead perform a VTOL land.
// @Bitmask: 0:LevelTransition,1:AllowFWTakeoff,2:AllowFWLand
// @Description: This provides a set of additional control options for quadplanes. LevelTransition means that the wings should be held level to within LEVEL_ROLL_LIMIT degrees during transition to fixed wing flight. If AllowFWTakeoff bit is not set then fixed wing takeoff on quadplanes will instead perform a VTOL takeoff. If AllowFWLand bit is not set then fixed wing land on quadplanes will instead perform a VTOL land. If respect takeoff frame is not set the vehicle will interpret all takeoff waypoints as an altitude above the corrent position.
// @Bitmask: 0:LevelTransition,1:AllowFWTakeoff,2:AllowFWLand,3:Respect takeoff frame types
AP_GROUPINFO("OPTIONS", 58, QuadPlane, options, 0),

AP_SUBGROUPEXTENSION("",59, QuadPlane, var_info2),
Expand Down Expand Up @@ -2094,7 +2094,14 @@ bool QuadPlane::do_vtol_takeoff(const AP_Mission::Mission_Command& cmd)
}

plane.set_next_WP(cmd.content.location);
plane.next_WP_loc.alt = plane.current_loc.alt + cmd.content.location.alt;
if (options & OPTION_RESPECT_TAKEOFF_FRAME) {
if (plane.current_loc.alt >= plane.next_WP_loc.alt) {
// we are above the takeoff already, no need to do anything
return false;
}
} else {
plane.next_WP_loc.alt = plane.current_loc.alt + cmd.content.location.alt;
}
throttle_wait = false;

// set target to current position
Expand Down
1 change: 1 addition & 0 deletions ArduPlane/quadplane.h
Expand Up @@ -450,6 +450,7 @@ class QuadPlane
OPTION_LEVEL_TRANSITION=(1<<0),
OPTION_ALLOW_FW_TAKEOFF=(1<<1),
OPTION_ALLOW_FW_LAND=(1<<2),
OPTION_RESPECT_TAKEOFF_FRAME=(1<<3),
};

/*
Expand Down
8 changes: 4 additions & 4 deletions ArduSub/commands_logic.cpp
Expand Up @@ -17,13 +17,13 @@ bool Sub::start_command(const AP_Mission::Mission_Command& cmd)
// target alt must be negative (underwater)
if (target_loc.alt > 0.0f) {
gcs().send_text(MAV_SEVERITY_WARNING, "BAD NAV ALT %0.2f", (double)target_loc.alt);
return true;
return false;
}

// only tested/supported alt frame so far is ALT_FRAME_ABOVE_HOME, where Home alt is always water's surface ie zero depth
if (target_loc.get_alt_frame() != Location_Class::ALT_FRAME_ABOVE_HOME) {
gcs().send_text(MAV_SEVERITY_WARNING, "BAD NAV ALT_FRAME %d", (int8_t)target_loc.get_alt_frame());
return true;
return false;
}

switch (cmd.id) {
Expand Down Expand Up @@ -153,8 +153,8 @@ bool Sub::start_command(const AP_Mission::Mission_Command& cmd)
#endif

default:
// do nothing with unrecognized MAVLink messages
break;
// unable to use the command, allow the vehicle to try the next command
return false;
}

// always return success
Expand Down
5 changes: 3 additions & 2 deletions libraries/AP_Mission/AP_Mission.cpp
Expand Up @@ -1411,8 +1411,9 @@ bool AP_Mission::advance_current_nav_cmd(uint16_t starting_index)
}
// set current navigation command and start it
_nav_cmd = cmd;
_flags.nav_cmd_loaded = true;
_cmd_start_fn(_nav_cmd);
if (_cmd_start_fn(_nav_cmd)) {
_flags.nav_cmd_loaded = true;
}
}else{
// set current do command and start it (if not already set)
if (!_flags.do_cmd_loaded) {
Expand Down