Plane: correct compilation when airspeed disabled

This commit is contained in:
Peter Barker 2022-03-12 22:48:55 +11:00 committed by Peter Barker
parent 6b48a8df02
commit 1f5165349e
6 changed files with 20 additions and 1 deletions

View File

@ -247,9 +247,11 @@ float GCS_MAVLINK_Plane::vfr_hud_airspeed() const
// will use an airspeed sensor, that value is constrained by the
// ground speed. When reporting we should send the true airspeed
// value if possible:
#if AP_AIRSPEED_ENABLED
if (plane.airspeed.enabled() && plane.airspeed.healthy()) {
return plane.airspeed.get_airspeed();
}
#endif
// airspeed estimates are OK:
float aspeed;

View File

@ -1492,6 +1492,7 @@ void Plane::load_parameters(void)
}
#endif
#if AP_AIRSPEED_ENABLED
// PARAMETER_CONVERSION - Added: Jan-2022
{
const uint16_t old_key = g.k_param_airspeed;
@ -1499,6 +1500,7 @@ void Plane::load_parameters(void)
const uint16_t old_top_element = 0; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP)
AP_Param::convert_class(old_key, &airspeed, airspeed.var_info, old_index, old_top_element, true);
}
#endif
hal.console->printf("load_all took %uus\n", (unsigned)(micros() - before));
}

View File

@ -31,6 +31,7 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Common/AP_Common.h>
#include <AP_Airspeed/AP_Airspeed.h>
#include <AP_Param/AP_Param.h>
#include <StorageManager/StorageManager.h>
#include <AP_Math/AP_Math.h> // ArduPilot Mega Vector/Matrix math Library

View File

@ -291,8 +291,14 @@ void Plane::crash_detection_update(void)
// if we have no GPS lock and we don't have a functional airspeed
// sensor then don't do crash detection
if (gps.status() < AP_GPS::GPS_OK_FIX_3D && (!airspeed.use() || !airspeed.healthy())) {
if (gps.status() < AP_GPS::GPS_OK_FIX_3D) {
#if AP_AIRSPEED_ENABLED
if (!airspeed.use() || !airspeed.healthy()) {
crashed = false;
}
#else
crashed = false;
#endif
}
if (!crashed) {

View File

@ -3014,11 +3014,13 @@ bool QuadPlane::verify_vtol_takeoff(const AP_Mission::Mission_Command &cmd)
return false;
}
#if AP_AIRSPEED_ENABLED
if (is_positive(maximum_takeoff_airspeed) && (plane.airspeed.get_airspeed() > maximum_takeoff_airspeed)) {
gcs().send_text(MAV_SEVERITY_CRITICAL, "Failed to complete takeoff, excessive wind");
plane.set_mode(plane.mode_qland, ModeReason::VTOL_FAILED_TAKEOFF);
return false;
}
#endif
if (plane.current_loc.alt < plane.next_WP_loc.alt) {
return false;

View File

@ -133,11 +133,17 @@ bool Plane::suppress_throttle(void)
// if we have an airspeed sensor, then check it too, and
// require 5m/s. This prevents throttle up due to spiky GPS
// groundspeed with bad GPS reception
#if AP_AIRSPEED_ENABLED
if ((!ahrs.airspeed_sensor_enabled()) || airspeed.get_airspeed() >= 5) {
// we're moving at more than 5 m/s
throttle_suppressed = false;
return false;
}
#else
// no airspeed sensor, so we trust that the GPS's movement is truthful
throttle_suppressed = false;
return false;
#endif
}
#if HAL_QUADPLANE_ENABLED