From fd709e05b0634c6aad1c01b657c5997259d114a3 Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Thu, 16 Nov 2023 13:47:12 +0100 Subject: [PATCH] Geofence: remove GF_ALTMODE Signed-off-by: Silvan Fuhrer --- src/modules/navigator/geofence.cpp | 30 +++++-------------------- src/modules/navigator/geofence.h | 12 +--------- src/modules/navigator/geofence_params.c | 13 ----------- 3 files changed, 6 insertions(+), 49 deletions(-) diff --git a/src/modules/navigator/geofence.cpp b/src/modules/navigator/geofence.cpp index b2493057ba..9b01736f3d 100644 --- a/src/modules/navigator/geofence.cpp +++ b/src/modules/navigator/geofence.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2013,2017 PX4 Development Team. All rights reserved. + * Copyright (c) 2013-2023 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,8 +55,7 @@ Geofence::Geofence(Navigator *navigator) : ModuleParams(navigator), - _navigator(navigator), - _sub_airdata(ORB_ID(vehicle_air_data)) + _navigator(navigator) { if (_navigator != nullptr) { updateFence(); @@ -250,11 +249,6 @@ bool Geofence::checkAll(const struct vehicle_global_position_s &global_position) return checkAll(global_position.lat, global_position.lon, global_position.alt); } -bool Geofence::checkAll(const struct vehicle_global_position_s &global_position, const float alt) -{ - return checkAll(global_position.lat, global_position.lon, alt); -} - bool Geofence::checkAll(double lat, double lon, float altitude) { bool inside_fence = isCloserThanMaxDistToHome(lat, lon, altitude); @@ -283,25 +277,11 @@ bool Geofence::checkAll(double lat, double lon, float altitude) bool Geofence::check(const vehicle_global_position_s &global_position, const sensor_gps_s &gps_position) { - if (_param_gf_altmode.get() == Geofence::GF_ALT_MODE_WGS84) { - if (getSource() == Geofence::GF_SOURCE_GLOBALPOS) { - return checkAll(global_position); - - } else { - return checkAll(gps_position.latitude_deg, gps_position.longitude_deg, gps_position.altitude_msl_m); - } + if (getSource() == Geofence::GF_SOURCE_GLOBALPOS) { + return checkAll(global_position); } else { - // get baro altitude - _sub_airdata.update(); - const float baro_altitude_amsl = _sub_airdata.get().baro_alt_meter; - - if (getSource() == Geofence::GF_SOURCE_GLOBALPOS) { - return checkAll(global_position, baro_altitude_amsl); - - } else { - return checkAll(gps_position.latitude_deg, gps_position.longitude_deg, baro_altitude_amsl); - } + return checkAll(gps_position.latitude_deg, gps_position.longitude_deg, gps_position.altitude_msl_m); } } diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h index 1804d151d5..0359141404 100644 --- a/src/modules/navigator/geofence.h +++ b/src/modules/navigator/geofence.h @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2013 PX4 Development Team. All rights reserved. + * Copyright (c) 2013-2023 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -52,7 +52,6 @@ #include #include #include -#include #define GEOFENCE_FILENAME PX4_STORAGEDIR"/etc/geofence.txt" @@ -66,12 +65,6 @@ public: Geofence &operator=(const Geofence &) = delete; virtual ~Geofence(); - /* Altitude mode, corresponding to the param GF_ALTMODE */ - enum { - GF_ALT_MODE_WGS84 = 0, - GF_ALT_MODE_AMSL = 1 - }; - /* Source, corresponding to the param GF_SOURCE */ enum { GF_SOURCE_GLOBALPOS = 0, @@ -195,7 +188,6 @@ private: MapProjection _projection_reference{}; ///< class to convert (lon, lat) to local [m] - uORB::SubscriptionData _sub_airdata; int _outside_counter{0}; uint16_t _update_counter{0}; ///< dataman update counter: if it does not match, polygon data was updated @@ -222,7 +214,6 @@ private: bool checkAll(const vehicle_global_position_s &global_position); - bool checkAll(const vehicle_global_position_s &global_position, float baro_altitude_amsl); /** * Check if a single point is within a polygon @@ -239,7 +230,6 @@ private: DEFINE_PARAMETERS( (ParamInt) _param_gf_action, - (ParamInt) _param_gf_altmode, (ParamInt) _param_gf_source, (ParamInt) _param_gf_count, (ParamFloat) _param_gf_max_hor_dist, diff --git a/src/modules/navigator/geofence_params.c b/src/modules/navigator/geofence_params.c index 053a0aa36c..3d53fa1cdf 100644 --- a/src/modules/navigator/geofence_params.c +++ b/src/modules/navigator/geofence_params.c @@ -61,19 +61,6 @@ */ PARAM_DEFINE_INT32(GF_ACTION, 2); -/** - * Geofence altitude mode - * - * Select which altitude (AMSL) source should be used for geofence calculations. - * - * @min 0 - * @max 1 - * @value 0 Autopilot estimator global position altitude (GPS) - * @value 1 Raw barometer altitude (assuming standard atmospheric pressure) - * @group Geofence - */ -PARAM_DEFINE_INT32(GF_ALTMODE, 0); - /** * Geofence source *