Skip to content

Commit 79c089d

Browse files
committed
Add GPS resilience toolbar indicator
1 parent b2a3bb6 commit 79c089d

3 files changed

Lines changed: 168 additions & 0 deletions

File tree

src/FirmwarePlugin/FirmwarePlugin.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const QVariantList &FirmwarePlugin::toolIndicators(const Vehicle*)
204204
if (_toolIndicatorList.isEmpty()) {
205205
_toolIndicatorList = QVariantList({
206206
QVariant::fromValue(QUrl::fromUserInput("qrc:/qml/QGroundControl/Toolbar/VehicleGPSIndicator.qml")),
207+
QVariant::fromValue(QUrl::fromUserInput("qrc:/qml/QGroundControl/Toolbar/GPSResilienceIndicator.qml")),
207208
QVariant::fromValue(QUrl::fromUserInput("qrc:/qml/QGroundControl/Toolbar/TelemetryRSSIIndicator.qml")),
208209
QVariant::fromValue(QUrl::fromUserInput("qrc:/qml/QGroundControl/Toolbar/RCRSSIIndicator.qml")),
209210
QVariant::fromValue(QUrl::fromUserInput("qrc:/qml/QGroundControl/Controls/BatteryIndicator.qml")),

src/UI/toolbar/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ qt_add_qml_module(ToolbarModule
1010
EscIndicatorPage.qml
1111
GCSControlIndicator.qml
1212
GimbalIndicator.qml
13+
GPSResilienceIndicator.qml
1314
JoystickIndicator.qml
1415
ModeIndicator.qml
1516
MultiVehicleSelector.qml
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/****************************************************************************
2+
*
3+
* (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4+
*
5+
* QGroundControl is licensed according to the terms in the file
6+
* COPYING.md in the root of the source code directory.
7+
*
8+
****************************************************************************/
9+
10+
import QtQuick
11+
import QtQuick.Layouts
12+
13+
import QGroundControl
14+
import QGroundControl.Controls
15+
16+
//-------------------------------------------------------------------------
17+
//-- GPS Resilience Indicator
18+
Item {
19+
id: control
20+
width: height
21+
anchors.top: parent.top
22+
anchors.bottom: parent.bottom
23+
visible: showIndicator
24+
25+
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
26+
property var _gpsAggregate: _activeVehicle ? _activeVehicle.gpsAggregate : null
27+
28+
property var qgcPal: QGroundControl.globalPalette
29+
30+
property bool showIndicator: _activeVehicle && _gpsAggregate && (
31+
(_gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255) ||
32+
(_gpsAggregate.spoofingState.value > 0 && _gpsAggregate.spoofingState.value < 255) ||
33+
(_gpsAggregate.jammingState.value > 0 && _gpsAggregate.jammingState.value < 255)
34+
)
35+
36+
// Authentication Icon (Outer/Bottom Layer)
37+
QGCColoredImage {
38+
id: authIcon
39+
width: parent.height * 0.95
40+
height: parent.height * 0.95
41+
anchors.centerIn: parent
42+
source: "/qmlimages/GpsAuthentication.svg"
43+
fillMode: Image.PreserveAspectFit
44+
sourceSize.height: height
45+
color: _authColor()
46+
visible: _gpsAggregate && _gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255
47+
}
48+
49+
// Interference Icon (Inner/Top Layer)
50+
QGCColoredImage {
51+
id: interfIcon
52+
width: parent.height * 0.55
53+
height: parent.height * 0.55
54+
anchors.centerIn: parent
55+
source: "/qmlimages/GpsInterference.svg"
56+
fillMode: Image.PreserveAspectFit
57+
sourceSize.height: height
58+
color: _interfColor()
59+
visible: _gpsAggregate && (Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value) > 0) && (Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value) < 255)
60+
}
61+
62+
function _authColor() {
63+
if (!_gpsAggregate) return qgcPal.colorGrey;
64+
switch (_gpsAggregate.authenticationState.value) {
65+
case 1: return qgcPal.colorYellow; // Initializing
66+
case 2: return qgcPal.colorRed; // Error
67+
case 3: return qgcPal.colorGreen; // OK
68+
default: return qgcPal.colorGrey; // Unknown or Disabled
69+
}
70+
}
71+
72+
function _interfColor() {
73+
if (!_gpsAggregate) return qgcPal.colorGrey;
74+
let maxState = Math.max(_gpsAggregate.spoofingState.value, _gpsAggregate.jammingState.value);
75+
switch (maxState) {
76+
case 1: return qgcPal.colorGreen; // Not spoofed/jammed
77+
case 2: return qgcPal.colorOrange; // Mitigated
78+
case 3: return qgcPal.colorRed; // Detected
79+
default: return qgcPal.colorGrey; // Unknown
80+
}
81+
}
82+
83+
MouseArea {
84+
anchors.fill: parent
85+
onClicked: mainWindow.showIndicatorDrawer(resiliencePopup, control)
86+
}
87+
88+
Component {
89+
id: resiliencePopup
90+
ToolIndicatorPage {
91+
showExpand: expandedComponent ? true : false
92+
contentComponent: resilienceContent
93+
}
94+
}
95+
96+
Component {
97+
id: resilienceContent
98+
ColumnLayout {
99+
spacing: ScreenTools.defaultFontPixelHeight / 2
100+
101+
// Unified GPS Resilience Status
102+
SettingsGroupLayout {
103+
heading: qsTr("GPS Resilience Status")
104+
showDividers: true
105+
106+
LabelledLabel {
107+
label: qsTr("GPS Jamming")
108+
labelText: _gpsAggregate ? (_gpsAggregate.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
109+
visible: _gpsAggregate && _gpsAggregate.jammingState.value > 0 && _gpsAggregate.jammingState.value < 255
110+
}
111+
112+
LabelledLabel {
113+
label: qsTr("GPS Spoofing")
114+
labelText: _gpsAggregate ? (_gpsAggregate.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
115+
visible: _gpsAggregate && _gpsAggregate.spoofingState.value > 0 && _gpsAggregate.spoofingState.value < 255
116+
}
117+
118+
LabelledLabel {
119+
label: qsTr("GPS Authentication")
120+
labelText: _gpsAggregate ? (_gpsAggregate.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
121+
visible: _gpsAggregate && _gpsAggregate.authenticationState.value > 0 && _gpsAggregate.authenticationState.value < 255
122+
}
123+
}
124+
125+
// GPS 1 Details
126+
SettingsGroupLayout {
127+
heading: qsTr("GPS 1 Details")
128+
showDividers: true
129+
visible: _activeVehicle && _activeVehicle.gps && _activeVehicle.gps.lock.value > 0
130+
131+
LabelledLabel {
132+
label: qsTr("Jamming")
133+
labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
134+
}
135+
LabelledLabel {
136+
label: qsTr("Spoofing")
137+
labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
138+
}
139+
LabelledLabel {
140+
label: qsTr("Authentication")
141+
labelText: (_activeVehicle && _activeVehicle.gps) ? (_activeVehicle.gps.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
142+
}
143+
}
144+
145+
// GPS 2 Details
146+
SettingsGroupLayout {
147+
heading: qsTr("GPS 2 Details")
148+
showDividers: true
149+
visible: _activeVehicle && _activeVehicle.gps2 && _activeVehicle.gps2.lock.value > 0
150+
151+
LabelledLabel {
152+
label: qsTr("Jamming")
153+
labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.jammingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
154+
}
155+
LabelledLabel {
156+
label: qsTr("Spoofing")
157+
labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.spoofingState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
158+
}
159+
LabelledLabel {
160+
label: qsTr("Authentication")
161+
labelText: (_activeVehicle && _activeVehicle.gps2) ? (_activeVehicle.gps2.authenticationState.enumStringValue || qsTr("n/a")) : qsTr("n/a")
162+
}
163+
}
164+
}
165+
}
166+
}

0 commit comments

Comments
 (0)