refactor(navigator): pass GF_CONT_ACTION on like GF_ACTION

Navigator turned the values GF_CONT_ACTION does not offer into Warning.
Commander does the same where the action is taken, so the list of
offered actions was written twice.

Navigator now passes the parameter on, as it does for GF_ACTION, and
only reports None while the contingency geofence is disabled.

Only a value outside the parameter's list behaves differently: with 4
(Terminate) a breach still only warns, but Go-to targets outside the
contingency geofence are refused.

Assisted-by: Claude:claude-fable-5-2
Signed-off-by: jonas <jonspero@me.com>
This commit is contained in:
jonas committed 2026-11-20 10:30:18 +01:00
1 parent 6a6d76cf6a
commit 200d5ddc18
3 files changed
+6 -28

No files matched your search

-19
View File
@@ -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<uint8_t>(_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) {
+6 -5
View File
@@ -49,6 +49,7 @@
#include <lib/geo/geo.h>
#include <px4_platform_common/defines.h>
#include <uORB/Subscription.hpp>
#include <uORB/topics/geofence_result.h>
#include <uORB/topics/geofence_status.h>
#include <uORB/topics/home_position.h>
#include <uORB/topics/vehicle_global_position.h>
@@ -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(); }
@@ -373,10 +373,6 @@ TEST_P(ContGeofenceSourceTest, PublishesTheContGeofenceAction)
setParam("GF_CONT_ACTION", static_cast<int32_t>(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<int32_t>(geofence_result_s::GF_ACTION_TERMINATE));
EXPECT_EQ(checkAt(inside()).geofence_cont_action, geofence_result_s::GF_ACTION_WARN);
}
TEST_P(ContGeofenceSourceTest, HoldLoitersAtTheTriggerPosition)