ArduCopter: make terrain checks common between Copter and Plane

This commit is contained in:
Peter Barker 2022-08-03 22:59:38 +10:00 committed by Peter Barker
parent 3bcd4fa22a
commit 67d8965cad
2 changed files with 16 additions and 16 deletions

View File

@ -120,6 +120,17 @@ bool AP_Arming_Copter::board_voltage_checks(bool display_failure)
return true; return true;
} }
// expected to return true if the terrain database is required to have
// all data loaded
bool AP_Arming_Copter::terrain_database_required() const
{
if (copter.wp_nav->get_terrain_source() == AC_WPNav::TerrainSource::TERRAIN_FROM_TERRAINDATABASE &&
copter.mode_rtl.get_alt_type() == ModeRTL::RTLAltType::RTL_ALTTYPE_TERRAIN) {
return true;
}
return AP_Arming::terrain_database_required();
}
bool AP_Arming_Copter::parameter_checks(bool display_failure) bool AP_Arming_Copter::parameter_checks(bool display_failure)
{ {
// check various parameter values // check various parameter values
@ -228,22 +239,7 @@ bool AP_Arming_Copter::parameter_checks(bool display_failure)
} }
break; break;
case AC_WPNav::TerrainSource::TERRAIN_FROM_TERRAINDATABASE: case AC_WPNav::TerrainSource::TERRAIN_FROM_TERRAINDATABASE:
#if AP_TERRAIN_AVAILABLE // these checks are done in AP_Arming
if (!copter.terrain.enabled()) {
check_failed(ARMING_CHECK_PARAMETERS, display_failure, failure_template, "terrain disabled");
return false;
}
// check terrain data is loaded
uint16_t terr_pending, terr_loaded;
copter.terrain.get_statistics(terr_pending, terr_loaded);
if (terr_pending != 0) {
check_failed(ARMING_CHECK_PARAMETERS, display_failure, failure_template, "waiting for terrain data");
return false;
}
#else
check_failed(ARMING_CHECK_PARAMETERS, display_failure, failure_template, "terrain disabled");
return false;
#endif
break; break;
} }
} }

View File

@ -51,6 +51,10 @@ protected:
void set_pre_arm_check(bool b); void set_pre_arm_check(bool b);
// expected to return true if the terrain database is required to have
// all data loaded
bool terrain_database_required() const override;
private: private:
// actually contains the pre-arm checks. This is wrapped so that // actually contains the pre-arm checks. This is wrapped so that