Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib/failure_injection/FailureInjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ bool process_gnss(const Config &config, uint8_t uorb_instance, sensor_gps_s &sen
int32_t fix_type = sensor_gps_s::FIX_TYPE_2D;
param_get(fix_type_handle, &fix_type);
sensor_gps.fix_type = (uint8_t)fix_type;

static const param_t jamming_state_handle = param_find("SYS_FAIL_GPS_JAM");

int32_t jamming_state = sensor_gps_s::JAMMING_STATE_UNKNOWN;
param_get(jamming_state_handle, &jamming_state);

if (jamming_state != sensor_gps_s::JAMMING_STATE_UNKNOWN) {
sensor_gps.jamming_state = (uint8_t)jamming_state;
}
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/failure_injection/FailureInjection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ void process_battery(const Config &config, uint8_t instance, battery_status_s &b
/**
* GNSS counterpart to process(): on FAILURE_UNIT_SENSOR_GPS for the receiver publishing on the
* given 0-based uORB instance, Off and Stuck behave as in the generic process() and Wrong reports
* the fix type selected by SYS_FAIL_GPS_WRG while leaving the position untouched.
* the fix type selected by SYS_FAIL_GPS_WRG and the jamming state selected by SYS_FAIL_GPS_JAM
* while leaving the position untouched.
*
* @param uorb_instance 0-based uORB instance of the publisher (not the 1-based failure instance).
* @return false if the sensor_gps publication must be suppressed (Off), true otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void EstimatorChecks::checkGps(const Context &context, Report &reporter, const s
*/
reporter.armingCheckFailure(NavModes::None, health_component_t::gps,
events::ID("check_estimator_gps_jamming_critical"),
events::Log::Warning, "GPS jamming detected");
events::Log::Notice, "GPS jamming detected");

if (reporter.mavlink_log_pub()) {
mavlink_log_warning(reporter.mavlink_log_pub(), "GPS jamming detected\t");
Expand Down
26 changes: 25 additions & 1 deletion src/modules/ekf2/EKF/aid_sources/gnss/gnss_checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ class GnssChecks final
uint16_t value;
};

/**
* Fail-status flags (gps_check_fail_status_u layout) of the checks enabled by EKF2_GPS_CHECK.
* The param bit order (GnssChecksMask) and the status bit order are not parallel, so they are
* mapped one by one: a positional shift silently misassigns every check that is appended to
* one of the two enums but not the other.
*/
uint16_t getEnabledChecksFailStatusMask() const
{
gps_check_fail_status_u mask{};
mask.flags.fix = isCheckEnabled(GnssChecksMask::kFix);
mask.flags.nsats = isCheckEnabled(GnssChecksMask::kNsats);
mask.flags.pdop = isCheckEnabled(GnssChecksMask::kPdop);
mask.flags.hacc = isCheckEnabled(GnssChecksMask::kHacc);
mask.flags.vacc = isCheckEnabled(GnssChecksMask::kVacc);
mask.flags.sacc = isCheckEnabled(GnssChecksMask::kSacc);
mask.flags.hdrift = isCheckEnabled(GnssChecksMask::kHdrift);
mask.flags.vdrift = isCheckEnabled(GnssChecksMask::kVdrift);
mask.flags.hspeed = isCheckEnabled(GnssChecksMask::kHspd);
mask.flags.vspeed = isCheckEnabled(GnssChecksMask::kVspd);
mask.flags.spoofed = isCheckEnabled(GnssChecksMask::kSpoofed);
mask.flags.jammed = isCheckEnabled(GnssChecksMask::kJammed);
return mask.value;
}

void resetHard()
{
_initial_checks_passed = false;
Expand Down Expand Up @@ -113,7 +137,7 @@ class GnssChecks final
kJammed = (1 << 11)
};

bool isCheckEnabled(GnssChecksMask check) { return (_params.check_mask & static_cast<int32_t>(check)); }
bool isCheckEnabled(GnssChecksMask check) const { return (_params.check_mask & static_cast<int32_t>(check)); }

bool runSimplifiedChecks(const gnssSample &gnss);
bool runInitialFixChecks(const gnssSample &gnss);
Expand Down
1 change: 1 addition & 0 deletions src/modules/ekf2/EKF/ekf.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ class Ekf final : public EstimatorInterface

const GnssChecks::gps_check_fail_status_u &gps_check_fail_status() const { return _gnss_checks.getFailStatus(); }
const decltype(GnssChecks::gps_check_fail_status_u::flags) &gps_check_fail_status_flags() const { return _gnss_checks.getFailStatus().flags; }
uint16_t gps_check_fail_status_enabled_mask() const { return _gnss_checks.getEnabledChecksFailStatusMask(); }

bool gps_checks_passed() const { return _gnss_checks.passed(); };

Expand Down
5 changes: 2 additions & 3 deletions src/modules/ekf2/EKF2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,9 +1948,8 @@ void EKF2::PublishStatus(const hrt_abstime &timestamp)
_ekf.getOutputTrackingError().copyTo(status.output_tracking_error);

#if defined(CONFIG_EKF2_GNSS)
// only report enabled GPS check failures (the param indexes are shifted by 1 bit, because they don't include
// the GPS Fix bit, which is always checked)
status.gps_check_fail_flags = _ekf.gps_check_fail_status().value & (((uint16_t)_params->ekf2_gps_check << 1) | 1);
// only report enabled GPS check failures
status.gps_check_fail_flags = _ekf.gps_check_fail_status().value & _ekf.gps_check_fail_status_enabled_mask();
#endif // CONFIG_EKF2_GNSS

status.control_mode_flags = _ekf.control_status().value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class FailureInjectionManager : public ModuleBase, public ModuleParams, public p
(ParamInt<px4::params::SYS_FAIL_RC_INST>) _param_sys_fail_rc_inst,
// Consumed via param_find() in failure_injection::process_gnss(); registered
// here so it is marked used and shows up in the GCS parameter list.
(ParamInt<px4::params::SYS_FAIL_GPS_WRG>) _param_sys_fail_gps_wrg
(ParamInt<px4::params::SYS_FAIL_GPS_WRG>) _param_sys_fail_gps_wrg,
(ParamInt<px4::params::SYS_FAIL_GPS_JAM>) _param_sys_fail_gps_jam
)
};
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,19 @@ parameters:
3: "Fix: 3D"
5: "Fix: RTK float"
6: "Fix: RTK fixed"
SYS_FAIL_GPS_JAM:
description:
short: GPS Wrong-failure jamming state
long: |-
GNSS jamming state reported by the addressed receiver while a GPS 'wrong'
failure injection is active. The reported position is left untouched, so
'Detected' simulates a receiver that still delivers a valid fix while
reporting interference. Leave at 'Unchanged' to keep the simulated
receiver's own jamming state.
type: enum
default: 0
values:
0: Unchanged
1: OK
2: Mitigated
3: Detected
Loading