diff --git a/libraries/AP_Mission/AP_Mission.cpp b/libraries/AP_Mission/AP_Mission.cpp index c9f05dbd5a..864c12df91 100644 --- a/libraries/AP_Mission/AP_Mission.cpp +++ b/libraries/AP_Mission/AP_Mission.cpp @@ -1968,6 +1968,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 9034942fba..bdecfecfd2 100644 --- a/libraries/AP_Mission/AP_Mission.h +++ b/libraries/AP_Mission/AP_Mission.h @@ -480,6 +480,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[];