Please review any and all PUBLIC repositories, groups and associate files. These allow anyone on the Internet to access without authentication. Repository and group owners are responsible for their content and permission settings. Go to your project(s), click on Settings > General and expand the "Visibility, project features, permissions" to change this setting.

DIS reference logs updated

parent 053700de
Future Work:
- add support for multiple entities
- connect to Framework that autogenerates nodes (instead of string output)
- add ANT build script for Unit-Testing
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PduStreamTools;
import com.google.common.primitives.Longs;
......@@ -22,6 +17,13 @@ import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
/**
* RecorderPlainText.java created on Mar 2, 2020 MOVES Institute Naval Postgraduate
* School, Monterey, CA, USA www.nps.edu
*
* @author Mike Bailey, jmbailey@nps.edu
* @author Tobias Brennenstuhl, tobias.brennenstuhl.gy@nps.edu
*/
public class RecorderPlainText implements PduReceiver
{
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PduStreamTools;
/**
* This class is a holder for coordinates and angles of ESPDUs to store them in
* HashMaps
*
* @author Tobias Brennenstuhl
* @author Tobias Brennenstuhl @ NPS
*/
public class Coordinates {
public class X3DCoordinates {
private double x;
private double y;
......@@ -20,7 +15,7 @@ public class Coordinates {
private double psi;
private double theta;
public Coordinates(double x, double y, double z, double phi, double psi, double theta) {
public X3DCoordinates(double x, double y, double z, double phi, double psi, double theta) {
this.setX(x);
this.setY(y);
this.setZ(z);
......@@ -30,7 +25,7 @@ public class Coordinates {
}
public Coordinates() {
public X3DCoordinates() {
this.setX(0.0);
this.setY(0.0);
this.setZ(0.0);
......
......@@ -22,7 +22,7 @@ import java.util.logging.Logger;
*
* @author Tobias Brennenstuhl @ NPS
*/
public class CreateX3dLineSet {
public class X3DCreateLineSet {
private byte[] bufferShort;
......@@ -34,13 +34,13 @@ public class CreateX3dLineSet {
private double firstLocalY = 0;
private double firstLocalZ = 0;
private LinkedHashMap<Double, Coordinates> testMap = new LinkedHashMap<>();
private LinkedHashMap<Double, X3DCoordinates> testMap = new LinkedHashMap<>();
//Setting up a NumberFormatter for limitting the decimal count to 3
private NumberFormat coordinateNumberFormat = NumberFormat.getInstance(new Locale("en", "US"));
// -------------------- End Variables for Position Interpolator
public CreateX3dLineSet() {
public X3DCreateLineSet() {
//3 significant digits equals milimeter position accuracy and 0.001 radians = 0.0572963266634555‬ degrees
coordinateNumberFormat.setMaximumFractionDigits(3);
......@@ -66,7 +66,7 @@ public class CreateX3dLineSet {
try {
localEspdu.unmarshal(espduBuffer);
} catch (Exception ex) {
Logger.getLogger(CreateX3dLineSet.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(X3DCreateLineSet.class.getName()).log(Level.SEVERE, null, ex);
}
double localTimeStamp = 0;
......@@ -112,7 +112,7 @@ public class CreateX3dLineSet {
//ToDo: Add support for multiple Entities
if ((localPdu.getPduType() != null) && (localPdu.getPduType() == DISPDUType.ENTITY_STATE)) {
testMap.put((double) localTimeStamp, new Coordinates(localX, localY, localZ, 0.0, 0.0, 0.0));
testMap.put((double) localTimeStamp, new X3DCoordinates(localX, localY, localZ, 0.0, 0.0, 0.0));
}
}
......@@ -123,9 +123,9 @@ public class CreateX3dLineSet {
//Compression of the testMap.
//Remove all collinear points.
SlidingWindowCompression regression = new SlidingWindowCompression(testMap);
X3DSlidingWindowCompression regression = new X3DSlidingWindowCompression(testMap);
TreeMap<Double, Coordinates> returnMap = new TreeMap<>();
TreeMap<Double, X3DCoordinates> returnMap = new TreeMap<>();
//To turn of the compression just comment the next line out and the very next in.
returnMap = regression.doSlidingWindow();
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PduStreamTools;
import static java.lang.Math.pow;
......@@ -15,48 +10,33 @@ import java.util.TreeMap;
/**
*
* @author tobia
* @author Tobias Brennenstuhl @ NPS
*/
public class SlidingWindowCompression {
public class X3DSlidingWindowCompression {
private LinkedHashMap<Double, Coordinates> localMap;
private LinkedHashMap<Double, X3DCoordinates> localMap;
public SlidingWindowCompression(LinkedHashMap<Double, Coordinates> localHashMap) {
public X3DSlidingWindowCompression(LinkedHashMap<Double, X3DCoordinates> localHashMap) {
//copy the given HashMap to a localMap
this.localMap = new LinkedHashMap<>();
Set<Double> keys = localHashMap.keySet();
for (Double k : keys) {
localMap.put(k, localHashMap.get(k));
}
//System.out.println("DISTools.Regression.<init>()");
}
public TreeMap<Double, Coordinates> doSlidingWindow() {
public TreeMap<Double, X3DCoordinates> doSlidingWindow() {
System.out.println("DISTools.Regression.doRegression()");
//Check whether points could be deleted to compress the stream
//https://www.crashkurs-statistik.de/einfache-lineare-regression/
TreeMap<Double, Coordinates> streamMap = new TreeMap<>();
Set<Double> keys = localMap.keySet();
TreeMap<Double, X3DCoordinates> streamMap = new TreeMap<>();
//Copy LinkedHashMap into TreeMap to be able to pull the first element.
streamMap.putAll(localMap);
TreeMap<Double, Coordinates> returnMap = new TreeMap<>();
TreeMap<Double, X3DCoordinates> returnMap = new TreeMap<>();
//TreeMap of slidingWindows will store all of the points that are currently processed
//use .pullFirstEntry() to get rid of the points at the beginning.
TreeMap<Double, Coordinates> slidingWindow = new TreeMap<>();
boolean addToWindow = true;
TreeMap<Double, X3DCoordinates> slidingWindow = new TreeMap<>();
while (streamMap.size() > 0) {
slidingWindow.put(streamMap.firstEntry().getKey(), streamMap.get(streamMap.firstEntry().getKey()));
......@@ -74,52 +54,36 @@ public class SlidingWindowCompression {
List<Double> phiList = new ArrayList<>();
List<Double> psiList = new ArrayList<>();
List<Double> thetaList = new ArrayList<>();
Double[] k = new Double[slidingWindowKeys.size()];
slidingWindowKeys.toArray(k);
for (int i = 0; i < slidingWindow.size(); i++) {
//Fix Loop to fill Arrays
tList.add(i, k[i]);
phiList.add(i, slidingWindow.get(k[i]).getPhi());
phiList.add(i, slidingWindow.get(k[i]).getPhi());
psiList.add(i, slidingWindow.get(k[i]).getPsi());
thetaList.add(i, slidingWindow.get(k[i]).getTheta());
xList.add(i, slidingWindow.get(k[i]).getX());
yList.add(i, slidingWindow.get(k[i]).getY());
zList.add(i, slidingWindow.get(k[i]).getZ());
}
//calculate triangle according to the homepage
//Calculate Area of Triangle
//Credit: http://www.ambrsoft.com/TrigoCalc/Line3D/LineColinear.htm
for (int i = 0; i < slidingWindow.size(); i++) {
//Calculate Area of Triangle
//http://www.ambrsoft.com/TrigoCalc/Line3D/LineColinear.htm
double a = sqrt(pow(xList.get(1) - xList.get(0), 2) + pow(yList.get(1) - yList.get(0), 2) + pow(zList.get(1) - zList.get(0), 2));
double b = sqrt(pow(xList.get(i) - xList.get(0), 2) + pow(yList.get(i) - yList.get(0), 2) + pow(zList.get(i) - zList.get(0), 2));
double c = sqrt(pow(xList.get(i) - xList.get(1), 2) + pow(yList.get(i) - yList.get(1), 2) + pow(zList.get(i) - zList.get(1), 2));
double s = (a + b + c) / 2;
double areaA = sqrt(s * (s - a) * (s - b) * (s - c));
if ((areaA >= 0.1) || (tList.get(i) - tList.get(0) >= 4.0)) {
//@Debug
//System.out.println("Threshold met. Break");
//grab the first and the last point from the sliding window and push it to the returnMap
Coordinates firstPoint = new Coordinates();
X3DCoordinates firstPoint = new X3DCoordinates();
firstPoint.setX(xList.get(0));
firstPoint.setY(yList.get(0));
firstPoint.setZ(zList.get(0));
......@@ -127,8 +91,7 @@ public class SlidingWindowCompression {
firstPoint.setPsi(psiList.get(0));
firstPoint.setTheta(thetaList.get(0));
//ToDo add the angles to the Coordinates
Coordinates lastPoint = new Coordinates(xList.get(i), yList.get(i), zList.get(i), phiList.get(i), psiList.get(i), thetaList.get(i));
X3DCoordinates lastPoint = new X3DCoordinates(xList.get(i), yList.get(i), zList.get(i), phiList.get(i), psiList.get(i), thetaList.get(i));
returnMap.put(tList.get(0), firstPoint);
returnMap.put(tList.get(i), lastPoint);
......@@ -142,7 +105,6 @@ public class SlidingWindowCompression {
phiList.clear();
psiList.clear();
thetaList.clear();
break;
}
......@@ -150,22 +112,15 @@ public class SlidingWindowCompression {
if ((areaA <= 0.1) && (tList.get(i) - tList.get(0) <= 4.0) && streamMap.size() == 0) {
//System.out.println("StreamMap empty. All points left will be added. Break");
//grab the first and the last point from the regression test and push it to the returnMap
//grab the first and the last point from the siding window and push it to the returnMap
for (int j = 0; j < slidingWindow.size(); j++) {
//ToDo: Add the angles to the coordinates
Coordinates leftPoints = new Coordinates(xList.get(j), yList.get(j), zList.get(j), phiList.get(j), psiList.get(j), thetaList.get(j));
X3DCoordinates leftPoints = new X3DCoordinates(xList.get(j), yList.get(j), zList.get(j), phiList.get(j), psiList.get(j), thetaList.get(j));
returnMap.put(tList.get(j), leftPoints);
}
break;
}
//System.out.println("Area of Triangle: " + areaA);
}
}
......@@ -175,12 +130,6 @@ public class SlidingWindowCompression {
return returnMap;
}
;
private void calcValues() {
}
;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment