From 73710d888de1c1f8a1153327624ac893473a11e4 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 16 Dec 2024 10:53:09 +1100 Subject: [PATCH] Rover: tidy WATER_DEPTH send checks --- Rover/GCS_Mavlink.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Rover/GCS_Mavlink.cpp b/Rover/GCS_Mavlink.cpp index b4a53e3c9f..841f6e97cb 100644 --- a/Rover/GCS_Mavlink.cpp +++ b/Rover/GCS_Mavlink.cpp @@ -199,9 +199,14 @@ void GCS_MAVLINK_Rover::send_water_depth() const RangeFinder *rangefinder = RangeFinder::get_singleton(); - if (rangefinder == nullptr || !rangefinder->has_orientation(ROTATION_PITCH_270)){ + if (rangefinder == nullptr) { return; - } + } + + // depth can only be measured by a downward-facing rangefinder: + if (!rangefinder->has_orientation(ROTATION_PITCH_270)) { + return; + } // get position const AP_AHRS &ahrs = AP::ahrs();