Fix for wakes on internal data

#bug
This commit is contained in:
Calum
2017-05-04 13:20:50 +12:00
parent c7b6261602
commit fd8ed92f88
4 changed files with 69 additions and 10 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ public class App extends Application
}
//Change the StreamReceiver in this else block to change the default data source.
else{
sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
sr = new StreamReceiver("localhost", 8085, "RaceStream");
}
sr.start();
+3 -2
View File
@@ -214,18 +214,19 @@ public class BoatGroup extends RaceObject{
pixelVelocityY = dy / expectedUpdateInterval;
rotationalGoal = rotation;
calculateRotationalVelocity();
if (wakeGenerationDelay > 0) {
wake.rotate(rotationalGoal);
rotateTo(rotationalGoal); //Need to test with this removed.
rotationalVelocity = 0;
wakeGenerationDelay--;
} else {
wake.setRotationalVelocity(rotationalVelocity, currentRotation, boat.getVelocity());
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal, boat.getVelocity());
}
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
} else {
setToInitialLocation = true;
rotationalGoal = rotation;;
rotationalGoal = rotation;
moveTo(newXValue, newYValue, rotation);
}
}
+4 -3
View File
@@ -54,14 +54,15 @@ class Wake extends Group {
void setRotationalVelocity (double rotationalVelocity, double rotationGoal, double velocity) {
sum -= Math.abs(velocities[(velocityIndices[0] + 10) % 13]);
sum += Math.abs(rotationalVelocity);
// System.out.println("sum = " + sum);
max = Math.max(max, rotationalVelocity);
// System.out.println("max = " + max);
if (sum < (max / 3))
rotate (rotationGoal); //In relatively straight segments the wake snaps to match the boats current position.
//This stops the wake from eventually becoming out of sync with the boat.
if (Math.abs(rotationalVelocity) > 0.5) {
//This accounts for rogue rotations that are greater than what would be realistic. Value is kinda rough.
//Basically just for our internal mock.
if (Math.abs(rotationalVelocity) > 0.05) {
rotationalVelocity = 0;
rotate(rotationGoal);
}
//Update the index of the array of recent velocities that each wake uses. Each wake is 3 velocities behind the
//next smallest wake.