From efa0e1bf0f2f1a97d7f7f9c98708779e730f87d4 Mon Sep 17 00:00:00 2001 From: ealdaz-seesai <35691522+ealdaz-seesai@users.noreply.github.com> Date: Tue, 28 Apr 2020 09:59:24 +0100 Subject: [PATCH] Rover land detection (#13769) * Land Enabled * Declared Subscriptor in header as originally intended. In the header it caused SIGSEGV in my machine so that's why it was moved to .cpp * Code Style fixed * Removed confusing comments * Comment update Co-authored-by: Julian Oes --- src/modules/land_detector/RoverLandDetector.cpp | 11 ++++++++++- src/modules/land_detector/RoverLandDetector.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/land_detector/RoverLandDetector.cpp b/src/modules/land_detector/RoverLandDetector.cpp index 7ac174f0ff..bb1b5e2b4a 100644 --- a/src/modules/land_detector/RoverLandDetector.cpp +++ b/src/modules/land_detector/RoverLandDetector.cpp @@ -44,6 +44,7 @@ namespace land_detector { + bool RoverLandDetector::_get_ground_contact_state() { return true; @@ -51,7 +52,15 @@ bool RoverLandDetector::_get_ground_contact_state() bool RoverLandDetector::_get_landed_state() { - return !_actuator_armed.armed; + + _vehicle_status_sub.update(&_vehicle_status); + + if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LAND) { + return true; // If Landing has been requested then say we have landed. + + } else { + return !_actuator_armed.armed; // If we are armed we are not landed. + } } } // namespace land_detector diff --git a/src/modules/land_detector/RoverLandDetector.h b/src/modules/land_detector/RoverLandDetector.h index 3f1d330299..77abda2e1a 100644 --- a/src/modules/land_detector/RoverLandDetector.h +++ b/src/modules/land_detector/RoverLandDetector.h @@ -42,6 +42,7 @@ #pragma once #include "LandDetector.h" +#include namespace land_detector { @@ -56,7 +57,11 @@ protected: bool _get_ground_contact_state() override; bool _get_landed_state() override; + private: + // Program crashes when Subscriptor declared here + uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)}; + vehicle_status_s _vehicle_status{}; /**< vehicle status */ };