Commit 6e86235f authored by Jean Meurice's avatar Jean Meurice
Browse files

Navigation bug fix

parent 00e946ee
Pipeline #381486 passed with stage
in 1 minute and 34 seconds
......@@ -77,6 +77,7 @@ public class SimpleNetwork implements EventTarget, SimulatorModule {
});
} else {
SimpleNetworkNodeInfo target = ipToNode.get(event.msg.target.addr);
if (target == null) throw new IllegalArgumentException("Sending to Unknown IP: "+event.msg.target.addr);
if (inRange(target, sender)) {
target.component.process(recvEvent);
}
......
......@@ -25,10 +25,10 @@
<properties>
<!-- USE THIS VARIABLE TO SET THE VERSION OF THIS PROJECT AND ALL SUB PROJECTS -->
<revision>3.1.3</revision>
<revision>3.1.4</revision>
<!-- USE THESE TO SET THE VERSIONS OF THE DEPENDENCIES FOR ALL THE SUB-PROJECTS -->
<commons.version>2.0.12</commons.version>
<commons.version>2.0.13</commons.version>
<controller.version>1.1.0</controller.version>
<assembly.plugin>2.5.4</assembly.plugin>
......
......@@ -155,30 +155,29 @@ public class Navigation extends EEComponent {
if (index < 0) return;
Path p = currentPath.get();
int size = Math.min(TRAJ_ARRAY_LENGTH, p.getLength()-index);
currentTrajSize = size;
double x[] = new double[TRAJ_ARRAY_LENGTH];
double y[] = new double[TRAJ_ARRAY_LENGTH];
int j = 0;
for (int i = 0; i < size; ++j){
double vx = 0, vy = 0;
if (j > 0) {
double dist = 0;
do {
vx = p.trajectoryX[index+i];
vy = p.trajectoryY[index+i];
dist = currentTraj[i-1].distance(vx, vy);
++i;
} while(dist < 0.01 && i < size); // Search the next traj point that is not too near the last
if (i >= size) break;
} else ++i;
x[j] = vx;
y[j] = vy;
currentTraj[j].x = x[j];
currentTraj[j].y = y[j];
int pointCount = 0;
for (int i = 0; i < size; ++i){
double vx = p.trajectoryX[index+i];
double vy = p.trajectoryY[index+i];
// Only add the point if it is far enough from the last
if (pointCount > 0) {
double dist = currentTraj[pointCount-1].distance(vx, vy);
if (dist < 0.01) continue; // Skip
}
x[pointCount] = vx;
y[pointCount] = vy;
currentTraj[pointCount].x = x[pointCount];
currentTraj[pointCount].y = y[pointCount];
++pointCount;
}
sendMessage(time, trajectoryLengthMsg, j);
sendMessage(time, trajectoryXMsg, x, 8*j);
sendMessage(time.plus(Duration.ofMillis(10)), trajectoryYMsg, y, 8*j);
currentTrajSize = pointCount;
sendMessage(time, trajectoryLengthMsg, currentTrajSize);
sendMessage(time, trajectoryXMsg, x, 8*currentTrajSize);
sendMessage(time.plus(Duration.ofMillis(10)), trajectoryYMsg, y, 8*currentTrajSize);
}
private int getNearestSegment(Vec2 pos) {
......
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