diff --git a/src/modules/navigator/geofence.cpp b/src/modules/navigator/geofence.cpp index e9a18e3cb0d..4b8da9e121a 100644 --- a/src/modules/navigator/geofence.cpp +++ b/src/modules/navigator/geofence.cpp @@ -903,25 +903,6 @@ bool Geofence::isBelowMaxAltitude(float altitude) return inside_fence; } -uint8_t Geofence::getContGeofenceAction() const -{ - if (getContGeofenceMargin() <= FLT_EPSILON) { - return geofence_result_s::GF_ACTION_NONE; - } - - switch (_param_gf_cont_action.get()) { - case geofence_result_s::GF_ACTION_NONE: - case geofence_result_s::GF_ACTION_LOITER: - case geofence_result_s::GF_ACTION_RTL: - case geofence_result_s::GF_ACTION_LAND: - return static_cast(_param_gf_cont_action.get()); - - default: - // The contingency geofence does not offer Terminate. - return geofence_result_s::GF_ACTION_WARN; - } -} - bool Geofence::isWithinAltitudeBand(float altitude) { if (!isEmpty() && _altitude_max > _altitude_min) { diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h index 9144eb250b9..8f7be547d4c 100644 --- a/src/modules/navigator/geofence.h +++ b/src/modules/navigator/geofence.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -223,11 +224,11 @@ public: int getSource() { return _param_gf_source.get(); } int getGeofenceAction() { return _param_gf_action.get(); } - /** - * GF_CONT_ACTION as a GF_ACTION value: None while the contingency geofence is disabled, Warning for values - * it does not offer. - */ - uint8_t getContGeofenceAction() const; + /** GF_CONT_ACTION, or None while the contingency geofence is disabled. */ + int getContGeofenceAction() const + { + return getContGeofenceMargin() > FLT_EPSILON ? _param_gf_cont_action.get() : geofence_result_s::GF_ACTION_NONE; + } float getMaxHorDistanceHome() { return _param_gf_max_hor_dist.get(); } diff --git a/src/modules/navigator/test/test_contingency_geofence_breach.cpp b/src/modules/navigator/test/test_contingency_geofence_breach.cpp index ac9e5b2f414..cbdfc17d054 100644 --- a/src/modules/navigator/test/test_contingency_geofence_breach.cpp +++ b/src/modules/navigator/test/test_contingency_geofence_breach.cpp @@ -373,10 +373,6 @@ TEST_P(ContGeofenceSourceTest, PublishesTheContGeofenceAction) setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_NONE)); EXPECT_EQ(checkAt(inside()).geofence_cont_action, geofence_result_s::GF_ACTION_NONE); - - // Terminate is not offered. - setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_TERMINATE)); - EXPECT_EQ(checkAt(inside()).geofence_cont_action, geofence_result_s::GF_ACTION_WARN); } TEST_P(ContGeofenceSourceTest, HoldLoitersAtTheTriggerPosition)