Skip to content

Commit 8393f46

Browse files
authored
Ekf2 add jamming to gnss checks (#26085)
* add jamming check to gnss checks * keep original order of gnss_check params for default backwards compability
1 parent 1345b35 commit 8393f46

File tree

8 files changed

+43
-4
lines changed

8 files changed

+43
-4
lines changed

msg/EstimatorStatus.msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ uint8 GPS_CHECK_FAIL_MAX_VERT_DRIFT = 7 # 7 : maximum allowed vertical position
1616
uint8 GPS_CHECK_FAIL_MAX_HORZ_SPD_ERR = 8 # 8 : maximum allowed horizontal speed fail - requires stationary vehicle
1717
uint8 GPS_CHECK_FAIL_MAX_VERT_SPD_ERR = 9 # 9 : maximum allowed vertical velocity discrepancy fail
1818
uint8 GPS_CHECK_FAIL_SPOOFED = 10 # 10 : GPS signal is spoofed
19+
uint8 GPS_CHECK_FAIL_JAMMED = 11 # 11 : GPS signal is jammed
1920

2021
uint64 control_mode_flags # Bitmask to indicate EKF logic state
2122
uint8 CS_TILT_ALIGN = 0 # 0 - true if the filter tilt alignment is complete

src/modules/commander/HealthAndArmingChecks/checks/estimatorCheck.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ void EstimatorChecks::checkEstimatorStatus(const Context &context, Report &repor
272272
_gnss_spoofed = false;
273273
}
274274

275+
if (estimator_status.gps_check_fail_flags & (1 << estimator_status_s::GPS_CHECK_FAIL_JAMMED)) {
276+
if (!_gnss_jammed) {
277+
_gnss_jammed = true;
278+
279+
if (reporter.mavlink_log_pub()) {
280+
mavlink_log_critical(reporter.mavlink_log_pub(), "GNSS signal jammed\t");
281+
}
282+
283+
events::send(events::ID("check_estimator_gnss_warning_jamming"), {events::Log::Alert, events::LogInternal::Info},
284+
"GNSS signal jammed");
285+
}
286+
287+
} else {
288+
_gnss_jammed = false;
289+
}
290+
275291
if (!context.isArmed() && ekf_gps_check_fail) {
276292
NavModesMessageFail required_modes;
277293
events::Log log_level;
@@ -435,6 +451,18 @@ void EstimatorChecks::checkEstimatorStatus(const Context &context, Report &repor
435451
events::ID("check_estimator_gps_spoofed"),
436452
log_level, "GPS signal spoofed");
437453

454+
} else if (estimator_status.gps_check_fail_flags & (1 << estimator_status_s::GPS_CHECK_FAIL_JAMMED)) {
455+
message = "Preflight%s: GPS signal jammed";
456+
/* EVENT
457+
* @description
458+
* <profile name="dev">
459+
* Can be configured with <param>EKF2_GPS_CHECK</param> and <param>COM_ARM_WO_GPS</param>.
460+
* </profile>
461+
*/
462+
reporter.armingCheckFailure(required_modes, health_component_t::gps,
463+
events::ID("check_estimator_gps_jammed"),
464+
log_level, "GPS signal jammed");
465+
438466
} else {
439467
if (!ekf_gps_fusion) {
440468
// Likely cause unknown

src/modules/commander/HealthAndArmingChecks/checks/estimatorCheck.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class EstimatorChecks : public HealthAndArmingCheckBase
103103

104104
bool _gps_was_fused{false};
105105
bool _gnss_spoofed{false};
106+
bool _gnss_jammed{false};
106107

107108
bool _nav_failure_imminent_warned{false};
108109

src/modules/ekf2/EKF/aid_sources/gnss/gnss_checks.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ bool GnssChecks::runSimplifiedChecks(const gnssSample &gnss)
9191
_check_fail_status.flags.sacc = (gnss.sacc > 10.f);
9292

9393
_check_fail_status.flags.spoofed = gnss.spoofed;
94+
_check_fail_status.flags.jammed = gnss.jammed;
9495

9596
bool passed = true;
9697

@@ -99,7 +100,8 @@ bool GnssChecks::runSimplifiedChecks(const gnssSample &gnss)
99100
(_check_fail_status.flags.hacc && isCheckEnabled(GnssChecksMask::kHacc)) ||
100101
(_check_fail_status.flags.vacc && isCheckEnabled(GnssChecksMask::kVacc)) ||
101102
(_check_fail_status.flags.sacc && isCheckEnabled(GnssChecksMask::kSacc)) ||
102-
(_check_fail_status.flags.spoofed && isCheckEnabled(GnssChecksMask::kSpoofed))
103+
(_check_fail_status.flags.spoofed && isCheckEnabled(GnssChecksMask::kSpoofed)) ||
104+
(_check_fail_status.flags.jammed && isCheckEnabled(GnssChecksMask::kJammed))
103105
) {
104106
passed = false;
105107
}
@@ -126,6 +128,7 @@ bool GnssChecks::runInitialFixChecks(const gnssSample &gnss)
126128
_check_fail_status.flags.sacc = (gnss.sacc > _params.ekf2_req_sacc);
127129

128130
_check_fail_status.flags.spoofed = gnss.spoofed;
131+
_check_fail_status.flags.jammed = gnss.jammed;
129132

130133
runOnGroundGnssChecks(gnss);
131134

@@ -153,7 +156,8 @@ bool GnssChecks::runInitialFixChecks(const gnssSample &gnss)
153156
(_check_fail_status.flags.vdrift && isCheckEnabled(GnssChecksMask::kVdrift)) ||
154157
(_check_fail_status.flags.hspeed && isCheckEnabled(GnssChecksMask::kHspd)) ||
155158
(_check_fail_status.flags.vspeed && isCheckEnabled(GnssChecksMask::kVspd)) ||
156-
(_check_fail_status.flags.spoofed && isCheckEnabled(GnssChecksMask::kSpoofed))
159+
(_check_fail_status.flags.spoofed && isCheckEnabled(GnssChecksMask::kSpoofed)) ||
160+
(_check_fail_status.flags.jammed && isCheckEnabled(GnssChecksMask::kJammed))
157161
) {
158162
passed = false;
159163
}

src/modules/ekf2/EKF/aid_sources/gnss/gnss_checks.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class GnssChecks final
6363
uint16_t hspeed : 1; ///< 8 - true if horizontal speed is excessive (can only be used when stationary on ground)
6464
uint16_t vspeed : 1; ///< 9 - true if vertical speed error is excessive
6565
uint16_t spoofed: 1; ///< 10 - true if the GNSS data is spoofed
66+
uint16_t jammed : 1; ///< 11 - true if the GNSS data is jammed
6667
} flags;
6768
uint16_t value;
6869
};
@@ -108,7 +109,8 @@ class GnssChecks final
108109
kHspd = (1 << 7),
109110
kVspd = (1 << 8),
110111
kSpoofed = (1 << 9),
111-
kFix = (1 << 10)
112+
kFix = (1 << 10),
113+
kJammed = (1 << 11)
112114
};
113115

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

src/modules/ekf2/EKF/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct gnssSample {
202202
float yaw_acc{}; ///< 1-std yaw error (rad)
203203
float yaw_offset{}; ///< Heading/Yaw offset for dual antenna GPS - refer to description for GPS_YAW_OFFSET
204204
bool spoofed{}; ///< true if GNSS data is spoofed
205+
bool jammed{}; ///< true if GNSS data is jammed
205206
};
206207

207208
struct magSample {

src/modules/ekf2/EKF2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,7 @@ void EKF2::UpdateGpsSample(ekf2_timestamps_s &ekf2_timestamps)
24732473
.yaw_acc = vehicle_gps_position.heading_accuracy,
24742474
.yaw_offset = vehicle_gps_position.heading_offset,
24752475
.spoofed = vehicle_gps_position.spoofing_state == sensor_gps_s::SPOOFING_STATE_DETECTED,
2476+
.jammed = vehicle_gps_position.jamming_state == sensor_gps_s::JAMMING_STATE_DETECTED,
24762477
};
24772478

24782479
_ekf.setGpsData(gnss_sample, pps_compensation);

src/modules/ekf2/params_gnss.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ parameters:
128128
8: Vertical speed offset (EKF2_REQ_VDRIFT)
129129
9: Spoofing
130130
10: GPS fix type (EKF2_REQ_FIX)
131+
11: Jamming
131132
default: 2047
132133
min: 0
133-
max: 2047
134+
max: 4095
134135
EKF2_REQ_EPH:
135136
description:
136137
short: Required EPH to use GPS

0 commit comments

Comments
 (0)