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.

Roundtrip Test Commit

parent 884f5d1d
/Brennenstuhl/nbproject/private/
/BrennenstuhlTobias/build/
\ No newline at end of file
/BrennenstuhlTobias/build/
/BrennenstuhlTobias/nbproject/private/
/BrennenstuhlTobias/dist/
\ No newline at end of file
libs.CopyLibs.classpath=\
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.CopyLibs.displayName=CopyLibs Task
libs.CopyLibs.prop-version=3.0
......@@ -42,14 +42,39 @@ is divided into following sections:
<property file="nbproject/private/configs/${config}.properties"/>
<property file="nbproject/private/private.properties"/>
</target>
<target depends="-pre-init,-init-private" name="-init-user">
<target name="-pre-init-libraries">
<property location=".\lib\nblibraries.properties" name="libraries.path"/>
<dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
<pathconvert dirsep="/" property="libraries.dir">
<path path="${libraries.dir.nativedirsep}"/>
</pathconvert>
<basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
<available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
</target>
<target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
<filterchain>
<replacestring from="$${base}" to="${libraries.dir}"/>
<escapeunicode/>
</filterchain>
</loadproperties>
</target>
<target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
<loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
<filterchain>
<replacestring from="$${base}" to="${libraries.dir}"/>
<escapeunicode/>
</filterchain>
</loadproperties>
</target>
<target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
<property file="${user.properties.file}"/>
<!-- The two properties below are usually overridden -->
<!-- by the active platform. Just a fallback. -->
<property name="default.javac.source" value="1.6"/>
<property name="default.javac.target" value="1.6"/>
</target>
<target depends="-pre-init,-init-private,-init-user" name="-init-project">
<target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
<property file="nbproject/configs/${config}.properties"/>
<property file="nbproject/project.properties"/>
</target>
......@@ -118,7 +143,7 @@ is divided into following sections:
<property name="dist.jlink.output" value="${dist.jlink.dir}/${application.title}"/>
<property name="module.name" value=""/>
</target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property,-init-modules-supported" name="-do-init">
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property,-init-modules-supported" name="-do-init">
<property name="platform.java" value="${java.home}/bin/java"/>
<available file="${manifest.file}" property="manifest.available"/>
<condition property="splashscreen.available">
......@@ -287,7 +312,7 @@ is divided into following sections:
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
......@@ -1046,7 +1071,7 @@ is divided into following sections:
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
<property name="ap.cmd.line.internal" value=""/>
</target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<!--
===================
COMPILATION SECTION
......
build.xml.data.CRC32=1325f395
build.xml.data.CRC32=b0ff226d
build.xml.script.CRC32=e1e614b9
build.xml.stylesheet.CRC32=f85dc8f2@1.93.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=1325f395
nbproject/build-impl.xml.script.CRC32=2a0f0eb3
nbproject/build-impl.xml.data.CRC32=b0ff226d
nbproject/build-impl.xml.script.CRC32=90573349
nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.93.0.48
......@@ -65,8 +65,8 @@ javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=13
javac.target=13
javac.source=14
javac.target=14
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
......
......@@ -11,5 +11,8 @@
<root id="test.src.dir"/>
</test-roots>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
!End!End of DIS capture file, Pdusave1.dislog.
!End!End of DIS capture file, Pdusave2.dislog.
!Begin!Beginning of DIS capture file, Pdusave3.dislog.
AAAAAAAAAAA=,BwABAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAbVXeQ=,BwACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
AAAAAcTqV0g=,BwBFAgAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAcuS3Xw=,BwBGDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
AAAAAdIkMcw=,BwBHDQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
AAAAAdmFxXA=,BwBIAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD6QAAAAA=
!End!End of DIS capture file, Pdusave3.dislog.
!End!End of DIS capture file, Pdusave5.dislog.
/*
* 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 edu.nps.moves.dis7.EntityStatePdu;
import edu.nps.moves.dis7.Pdu;
import edu.nps.moves.dis7.enumerations.DISPDUType;
import edu.nps.moves.dis7.util.PduFactory;
import java.nio.ByteBuffer;
import java.text.NumberFormat;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Tobias Brennenstuhl @ NPS
*/
public class CreateX3dInterpolators {
private byte[] bufferShort;
// -------------------- Begin Variables for Position Interpolator
private Boolean firstTimeStamp = true;
private int firstLocalTimeStamp = 0;
private double firstLocalX = 0;
private double firstLocalY = 0;
private double firstLocalZ = 0;
private LinkedHashMap<Double, Coordinates> 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 CreateX3dInterpolators() {
//3 significant digits equals milimeter position accuracy and 0.001 radians = 0.0572963266634555‬ degrees
coordinateNumberFormat.setMaximumFractionDigits(3);
}
public void addPointsToMap(byte[] localBufferShort) {
this.bufferShort = localBufferShort.clone();
if (bufferShort[2] == 1) {
//PDU Factory
PduFactory pduFactory = new PduFactory();
Pdu localPdu = null;
localPdu = pduFactory.createPdu(bufferShort);
// ToDO figure out how to do this! makeEntityStatePDU
EntityStatePdu localEspdu = pduFactory.makeEntityStatePdu();
//Put all the data we need into the localEspdu
ByteBuffer espduBuffer = ByteBuffer.wrap(bufferShort);
try {
localEspdu.unmarshal(espduBuffer);
} catch (Exception ex) {
Logger.getLogger(CreateX3dInterpolators.class.getName()).log(Level.SEVERE, null, ex);
}
double localTimeStamp = 0;
double localX = 0;
double localY = 0;
double localZ = 0;
double localPhi = 0;
double localPsi = 0;
double localTheta = 0;
//Store the first timestamp to subtract it from all others
//Same with X,Y,Z to create a local coordiante system
if (firstTimeStamp) {
firstLocalTimeStamp = localPdu.getTimestamp();
localTimeStamp = localPdu.getTimestamp();
firstLocalX = localEspdu.getEntityLocation().getX();
firstLocalY = localEspdu.getEntityLocation().getZ();
firstLocalZ = -1*localEspdu.getEntityLocation().getY();
firstTimeStamp = false;
}
localTimeStamp = localPdu.getTimestamp();
localX = localEspdu.getEntityLocation().getX();
localY = localEspdu.getEntityLocation().getZ();
localZ = -1*localEspdu.getEntityLocation().getY();
localPhi = localEspdu.getEntityOrientation().getPhi();
localPsi = localEspdu.getEntityOrientation().getPsi();
localTheta = localEspdu.getEntityOrientation().getTheta();
localTimeStamp = localTimeStamp - firstLocalTimeStamp;
localX = localX - firstLocalX;
localY = localY - firstLocalY;
localZ = localZ - firstLocalZ;
//Divide TimeStamp by 1,300,000 to get something close to a second per Unit.
//According to the DIS standard one tick is 3600/(2^31) seconds ~ 1.6764 µs
//1,300,000 was derived from a stream that is 61 seconds long. The number was adjusted to get a timesensor with 61 seconds
//ToDo find the real conversion between TimeStampDelta and seconds
localTimeStamp = localTimeStamp / 1300000;
//Only add to stream if it is an ESPDU
//ToDo: Add support for multiple Entities
if ((localPdu.getPduType() != null) && (localPdu.getPduType() == DISPDUType.ENTITY_STATE)) {
testMap.put((double) localTimeStamp, new Coordinates(localX, localY, localZ, localPhi, localPsi, localTheta));
}
}
}
public void makeX3dInterpolator() {
//Compression of the testMap.
//Remove all collinear points.
SlidingWindowCompression slidingWindowCompression = new SlidingWindowCompression(testMap);
TreeMap<Double, Coordinates> returnMap = new TreeMap<>();
//To turn of the compression just comment the next line out and the very next in.
returnMap = slidingWindowCompression.doSlidingWindow();
//returnMap.putAll(testMap);
//Writing all values from the KeyMap to a proper Position Interpolator String
System.out.println("Writing Position and Rotation Interpolator");
Set<Double> keys = returnMap.keySet();
//Set<Double> keys = tempKeyKeyValueSetPositionInterPolator.keySet();
String positionKey = "key = '";
String positionKeyValue = "keyValue = '";
String positionInterpolatorToCopy = "<PositionInterpolator DEF='EntityPosition' ";
String orientationKeyX = "key = '";
String orientationKeyValueX = "keyValue = '";
String orientationInterpolatorToCopyX = "<OrientationInterpolator DEF='EntityOrientationX' ";
String orientationKeyY = "key = '";
String orientationKeyValueY = "keyValue = '";
String orientationInterpolatorToCopyY = "<OrientationInterpolator DEF='EntityOrientationY' ";
String orientationKeyZ = "key = '";
String orientationKeyValueZ = "keyValue = '";
String orientationInterpolatorToCopyZ = "<OrientationInterpolator DEF='EntityOrientationZ' ";
//Find highest time to do the normalization
double lastTimeStamp = 0;
for (Double k : keys) {
if (k > lastTimeStamp) {
lastTimeStamp = k;
}
}
//Normalize all times in the set
var keyKeyValueSetPositionInterpolator = new LinkedHashMap<Double, String>();
var keyKeyValueSetOrientationInterpolatorX = new LinkedHashMap<Double, String>();
var keyKeyValueSetOrientationInterpolatorY = new LinkedHashMap<Double, String>();
var keyKeyValueSetOrientationInterpolatorZ = new LinkedHashMap<Double, String>();
for (Double k : keys) {
String localCoordinateString;
String localOrientationStringX;
String localOrientationStringY;
String localOrientationStringZ;
double tempX = returnMap.get(k).getX();
double tempY = returnMap.get(k).getY();
double tempZ = returnMap.get(k).getZ();
double tempPhi = returnMap.get(k).getPhi() / 6.28;
double tempPsi = returnMap.get(k).getPsi() / 6.28;
double tempTheta = returnMap.get(k).getTheta() / 6.28;
localCoordinateString = " " + coordinateNumberFormat.format(tempX) + " " + coordinateNumberFormat.format(tempY) + " " + coordinateNumberFormat.format(tempZ);
localOrientationStringX = " 1 0 0 " + coordinateNumberFormat.format(tempPhi);
localOrientationStringY = " 0 1 0 " + coordinateNumberFormat.format(tempPsi);
localOrientationStringZ = " 0 0 1 " + coordinateNumberFormat.format(tempTheta);
keyKeyValueSetPositionInterpolator.put(k / lastTimeStamp, localCoordinateString);
keyKeyValueSetOrientationInterpolatorX.put(k / lastTimeStamp, localOrientationStringX);
keyKeyValueSetOrientationInterpolatorY.put(k / lastTimeStamp, localOrientationStringY);
keyKeyValueSetOrientationInterpolatorZ.put(k / lastTimeStamp, localOrientationStringZ);
}
keys = keyKeyValueSetPositionInterpolator.keySet();
//Setting up the timeSensor
//Only one timeSensor for both interpolators is needed
String timeSensor = "<TimeSensor DEF='PduStreamClock' cycleInterval='";
timeSensor += lastTimeStamp;
timeSensor += "' loop = 'true'/>";
//Printing the timeSensor to the console
System.out.println(timeSensor);
//Setting up PositionInterpolator and OrientationInterpolator
for (Double k : keys) {
//System.out.println("Time: " + k + " Position (x,y,z) " + keyKeyValueSetPositionInterpolator.get(k));
//PositionInterpolator
positionKey += coordinateNumberFormat.format(k) + " ";
positionKeyValue += keyKeyValueSetPositionInterpolator.get(k) + " ";
//OrientationInterpolator for X
orientationKeyX += coordinateNumberFormat.format(k) + " ";
orientationKeyValueX += keyKeyValueSetOrientationInterpolatorX.get(k) + " ";
//OrientationInterpolator for Y
orientationKeyY += coordinateNumberFormat.format(k) + " ";
orientationKeyValueY += keyKeyValueSetOrientationInterpolatorY.get(k) + " ";
//OrientationInterpolator for Z
orientationKeyZ += coordinateNumberFormat.format(k) + " ";
orientationKeyValueZ += keyKeyValueSetOrientationInterpolatorZ.get(k) + " ";
}
positionKey += "' ";
positionKeyValue += "' ";
orientationKeyX += "' ";
orientationKeyValueX += "' ";
orientationKeyY += "' ";
orientationKeyValueY += "' ";
orientationKeyZ += "' ";
orientationKeyValueZ += "' ";
//PositionInterpolator
positionInterpolatorToCopy += positionKey + "\n";
positionInterpolatorToCopy += positionKeyValue;
positionInterpolatorToCopy += "/>";
//PositionInterpolator for X
orientationInterpolatorToCopyX += orientationKeyX + "\n";
orientationInterpolatorToCopyX += orientationKeyValueX;
orientationInterpolatorToCopyX += "/>";
//PositionInterpolator for Y
orientationInterpolatorToCopyY += orientationKeyY + "\n";
orientationInterpolatorToCopyY += orientationKeyValueY;
orientationInterpolatorToCopyY += "/>";
//PositionInterpolator for Z
orientationInterpolatorToCopyZ += orientationKeyY + "\n";
orientationInterpolatorToCopyZ += orientationKeyValueZ;
orientationInterpolatorToCopyZ += "/>";
//Printing PositionInterpolator to the console
System.out.println(positionInterpolatorToCopy);
//Printing OrientationInterpolator for X to the console
System.out.println(orientationInterpolatorToCopyX);
//Printing OrientationInterpolator for Y to the console
System.out.println(orientationInterpolatorToCopyY);
//Printing OrientationInterpolator for Z to the console
System.out.println(orientationInterpolatorToCopyZ);
}
}
/*
* 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 edu.nps.moves.dis7.EntityStatePdu;
import edu.nps.moves.dis7.Pdu;
import edu.nps.moves.dis7.enumerations.DISPDUType;
import edu.nps.moves.dis7.util.PduFactory;
import java.nio.ByteBuffer;
import java.text.NumberFormat;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Tobias Brennenstuhl @ NPS
*/
public class CreateX3dLineSet {
private byte[] bufferShort;
// -------------------- Begin Variables for Position Interpolator
private Boolean firstTimeStamp = true;
private int firstLocalTimeStamp = 0;
private double firstLocalX = 0;
private double firstLocalY = 0;
private double firstLocalZ = 0;
private LinkedHashMap<Double, Coordinates> 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() {
//3 significant digits equals milimeter position accuracy and 0.001 radians = 0.0572963266634555‬ degrees
coordinateNumberFormat.setMaximumFractionDigits(3);
}
public void addPointsToMap(byte[] localBufferShort) {
this.bufferShort = localBufferShort.clone();
if (bufferShort[2] == 1) {
//PDU Factory
PduFactory pduFactory = new PduFactory();
Pdu localPdu = null;
localPdu = pduFactory.createPdu(bufferShort);
// ToDO figure out how to do this! makeEntityStatePDU
EntityStatePdu localEspdu = pduFactory.makeEntityStatePdu();
//Put all the data we need into the localEspdu
ByteBuffer espduBuffer = ByteBuffer.wrap(bufferShort);
try {
localEspdu.unmarshal(espduBuffer);
} catch (Exception ex) {
Logger.getLogger(CreateX3dLineSet.class.getName()).log(Level.SEVERE, null, ex);
}
double localTimeStamp = 0;
double localX = 0;
double localY = 0;
double localZ = 0;
//TimeStamps for a lineSet is not needed but copied from X3DInterpolators to use them as key for the hashmap
// and the standard compression class can be used
//Store the first timestamp to subtract it from all others
//Same with X,Y,Z to create a local coordiante system
if (firstTimeStamp) {
firstLocalTimeStamp = localPdu.getTimestamp();
localTimeStamp = localPdu.getTimestamp();
firstLocalX = localEspdu.getEntityLocation().getX();
firstLocalY = localEspdu.getEntityLocation().getZ();
firstLocalZ = -1*localEspdu.getEntityLocation().getY();
firstTimeStamp = false;
}
localTimeStamp = localPdu.getTimestamp();
localX = localEspdu.getEntityLocation().getX();
localY = localEspdu.getEntityLocation().getZ();
localZ = -1*localEspdu.getEntityLocation().getY();
//Debug for printing X,Y,Z
//System.out.println(localX + " " + localY + " " + localZ);
localTimeStamp = localTimeStamp - firstLocalTimeStamp;
localX = localX - firstLocalX;
localY = localY - firstLocalY;
localZ = localZ - firstLocalZ;
//Divide TimeStamp by 1,300,000 to get something close to a second per Unit.
//According to the DIS standard one tick is 3600/(2^31) seconds ~ 1.6764 µs
//1,300,000 was derived from a stream that is 61 seconds long. The number was adjusted to get a timesensor with 61 seconds
//ToDo find the real conversion between TimeStampDelta and seconds
localTimeStamp = localTimeStamp / 1300000;
//Only add to stream if it is an ESPDU
//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));