diff --git a/libraries/AP_Mission/AP_Mission.cpp b/libraries/AP_Mission/AP_Mission.cpp index 9fe982a7da..c5d5e7fe2e 100644 --- a/libraries/AP_Mission/AP_Mission.cpp +++ b/libraries/AP_Mission/AP_Mission.cpp @@ -1969,6 +1969,23 @@ bool AP_Mission::contains_item(MAV_CMD command) const return false; } +/* + return true if the mission has a terrain relative item + */ +bool AP_Mission::contains_terrain_relative(void) const +{ + for (int i = 1; i < num_commands(); i++) { + Mission_Command tmp; + if (!read_cmd_from_storage(i, tmp)) { + continue; + } + if (stored_in_location(tmp.id) && tmp.content.location.terrain_alt) { + return true; + } + } + return false; +} + // singleton instance AP_Mission *AP_Mission::_singleton; diff --git a/libraries/AP_Mission/AP_Mission.h b/libraries/AP_Mission/AP_Mission.h index d0e784f387..7399301d10 100644 --- a/libraries/AP_Mission/AP_Mission.h +++ b/libraries/AP_Mission/AP_Mission.h @@ -484,6 +484,9 @@ public: // returns true if the mission contains the requested items bool contains_item(MAV_CMD command) const; + // returns true if the mission has a terrain relative mission item + bool contains_terrain_relative(void) const; + // user settable parameters static const struct AP_Param::GroupInfo var_info[];