Skip to content

Commit bbd8005

Browse files
committed
- Provided initial real-time RFI and Spoofing analysis tools and visualization (tool efficacy has not yet been evaluated and is based on previously observed EW indicators)
- added a single view "GNSS Risk" meter that provides a simple overall risk level
1 parent 2b795a9 commit bbd8005

20 files changed

Lines changed: 1389 additions & 85 deletions

torgi/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ dependencies {
5252

5353
viewerImplementation 'com.github.PhilJay:MPAndroidChart:v3.0.3' //for charts
5454
viewerImplementation 'org.osmdroid:osmdroid-android:6.0.2'
55+
viewerImplementation 'org.apache.commons:commons-math3:3.0' //for statistical analysis
5556
implementation 'mil.nga.geopackage:geopackage-android:3.0.2'
5657
implementation 'com.android.support:appcompat-v7:27.1.1'
5758
viewerImplementation 'com.android.support.constraint:constraint-layout:1.1.3'

torgi/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
<activity
2020
android:name=".ui.MainActivity"
21-
android:label="@string/app_name">
21+
android:label="@string/app_name"
22+
android:launchMode="singleTask">
2223
<intent-filter>
2324
<action android:name="android.intent.action.MAIN" />
2425
<category android:name="android.intent.category.LAUNCHER" />

torgi/src/main/java/org/sofwerx/torgi/gnss/Constellation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public enum Constellation {
1414

1515
private int value;
1616

17-
public static int size() { return Constellation.size(); }
17+
private static final int size = values().length;
18+
19+
public static int size() { return size; }
1820

1921
Constellation(int value) {
2022
this.value = value;

torgi/src/main/java/org/sofwerx/torgi/gnss/DataPoint.java

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package org.sofwerx.torgi.gnss;
22

3+
import android.util.Log;
4+
5+
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
6+
37
import java.util.ArrayList;
48

59
/**
610
* Represents relevant EW indicator values at one place in spacetime
711
*/
812
public class DataPoint {
13+
private final static String TAG="TORGI.EW";
914
private SpaceTime spaceTime;
1015
private ArrayList<SatMeasurement> measurements = null;
1116

@@ -26,15 +31,91 @@ public GNSSEWValues getAverageMeasurements() {
2631
return SatMeasurement.getAverage(measurements);
2732
}
2833

29-
//TODO hey dummy! maybe calculate the difference from baseline as well
34+
public ArrayList<GNSSEWValues> getAllGNSSEWValues() {
35+
if ((measurements == null) || measurements.isEmpty())
36+
return null;
37+
ArrayList<GNSSEWValues> valuesList = new ArrayList<>();
38+
for (SatMeasurement measurement:measurements) {
39+
if (measurement.getValues() != null)
40+
valuesList.add(measurement.getValues());
41+
}
42+
if (valuesList.isEmpty())
43+
valuesList = null;
44+
return valuesList;
45+
}
46+
47+
/**
48+
* Gets the average difference between values and baseline
49+
* @return
50+
*/
51+
public GNSSEWValues getAverageDifference() {
52+
return SatMeasurement.getAverageDifference(measurements);
53+
}
54+
55+
public ArrayList<SatMeasurement> getMeasurementsByConstellation(Constellation con) {
56+
if ((measurements != null) && !measurements.isEmpty() && (con != null)) {
57+
ArrayList<SatMeasurement> conMeas = null;
58+
for (SatMeasurement measurement:measurements) {
59+
if ((measurement.getSat() != null) && (measurement.getSat().getConstellation() == con)) {
60+
if (conMeas == null)
61+
conMeas = new ArrayList<>();
62+
conMeas.add(measurement);
63+
}
64+
}
65+
return conMeas;
66+
}
67+
return null;
68+
}
3069

3170
/**
3271
* Gets the average GNSSEWValues for each constellation
33-
* @return array with index corresponding to the constellation number of the constellation
72+
* @return array with the average value with index corresponding to the constellation number of the constellation
3473
*/
3574
public GNSSEWValues[] getAverageMeasurementsByConstellation() {
3675
GNSSEWValues[] values = new GNSSEWValues[Constellation.size()];
3776

77+
if ((measurements != null) && !measurements.isEmpty()) {
78+
Constellation con;
79+
ArrayList<SatMeasurement> conMeas;
80+
for (int i=0;i<values.length;i++) {
81+
con = Constellation.get(i);
82+
conMeas = getMeasurementsByConstellation(con);
83+
values[i] = SatMeasurement.getAverage(conMeas);
84+
}
85+
}
86+
87+
return values;
88+
}
89+
90+
public float getAllBaselinesCN0SD() {
91+
if ((measurements != null) && !measurements.isEmpty()) {
92+
ArrayList<GNSSEWValues> valuesWithCN0s = new ArrayList<>();
93+
for (SatMeasurement measurement:measurements) {
94+
if ((measurement.getValues() != null) && !Float.isNaN(measurement.getValues().getCn0()))
95+
valuesWithCN0s.add(measurement.getValues());
96+
}
97+
if (!valuesWithCN0s.isEmpty()) {
98+
double[] values = new double[valuesWithCN0s.size()];
99+
for (int i=0;i<values.length;i++) {
100+
values[i] = valuesWithCN0s.get(i).getCn0();
101+
}
102+
StandardDeviation devCal = new StandardDeviation();
103+
float stdDev = (float)devCal.evaluate(values);
104+
Log.d(TAG,"C/N0 stdDev across all satellites == "+Float.toString(stdDev));
105+
return stdDev;
106+
}
107+
}
108+
Log.d(TAG,"Could not compute C/N0 stdDev across all satellites");
109+
return Float.NaN;
110+
}
111+
112+
/**
113+
* Gets the difference between baseline and current GNSSEWValues for each constellation
114+
* @return array with the average difference between value and baseline with index corresponding to the constellation number of the constellation
115+
*/
116+
public GNSSEWValues[] getAverageDifferenceFromBaselineByConstellation() {
117+
GNSSEWValues[] values = new GNSSEWValues[Constellation.size()];
118+
38119
if ((measurements != null) && !measurements.isEmpty()) {
39120
Constellation con;
40121
ArrayList<SatMeasurement> conMeas;
@@ -48,7 +129,7 @@ public GNSSEWValues[] getAverageMeasurementsByConstellation() {
48129
conMeas.add(measurement);
49130
}
50131
}
51-
values[i] = SatMeasurement.getAverage(conMeas);
132+
values[i] = SatMeasurement.getAverageDifference(conMeas);
52133
}
53134
}
54135

0 commit comments

Comments
 (0)