Skip to content

Commit b1b5459

Browse files
committed
fixing trackers synchronization in truncateEnvelope and reverseEnvelope functions.
1 parent 73eb0e3 commit b1b5459

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/java/se/oru/coordination/coordination_oru/TrajectoryEnvelopeCoordinator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,10 @@ public boolean truncateEnvelope(int robotID, boolean ensureDynamicFeasibility) {
13161316
}
13171317

13181318
TrajectoryEnvelope te = this.getCurrentTrajectoryEnvelope(robotID);
1319-
AbstractTrajectoryEnvelopeTracker tet = this.trackers.get(robotID);
1319+
AbstractTrajectoryEnvelopeTracker tet = null;
1320+
synchronized(trackers) {
1321+
tet = this.trackers.get(robotID);
1322+
}
13201323

13211324
int earliestStoppingPathIndex = -1;
13221325

@@ -1326,10 +1329,7 @@ public boolean truncateEnvelope(int robotID, boolean ensureDynamicFeasibility) {
13261329

13271330
//Check if you were already slowing down to stop in your critical point.
13281331
int lastCommunicatedCP = -1;
1329-
synchronized (trackers) {
1330-
//if (breakingPathIndex == 0) trackers.get(robotID).resetStartingTimeInMillis();
1331-
lastCommunicatedCP = communicatedCPs.get(trackers.get(robotID)).getFirst();
1332-
}
1332+
lastCommunicatedCP = communicatedCPs.get(tet).getFirst();
13331333
earliestStoppingPathIndex = (lastCommunicatedCP != -1) ? Math.min(lastCommunicatedCP, earliestStoppingPathIndex) : earliestStoppingPathIndex;
13341334

13351335
//Compute and add new TE, remove old TE (both driving and final parking)
@@ -1359,18 +1359,18 @@ public boolean reverseEnvelope(int robotID) {
13591359
}
13601360

13611361
TrajectoryEnvelope te = this.getCurrentTrajectoryEnvelope(robotID);
1362-
AbstractTrajectoryEnvelopeTracker tet = this.trackers.get(robotID);
1362+
AbstractTrajectoryEnvelopeTracker tet = null;
1363+
synchronized(trackers) {
1364+
tet = this.trackers.get(robotID);
1365+
}
13631366

13641367
int earliestStoppingPathIndex = -1;
13651368

13661369
if (!(tet instanceof TrajectoryEnvelopeTrackerDummy)) {
13671370
earliestStoppingPathIndex = this.getForwardModel(robotID).getEarliestStoppingPathIndex(te, this.getRobotReport(robotID));
13681371
//Check if you were already slowing down to stop in your critical point.
13691372
int lastCommunicatedCP = -1;
1370-
synchronized (trackers) {
1371-
//if (breakingPathIndex == 0) trackers.get(robotID).resetStartingTimeInMillis();
1372-
lastCommunicatedCP = communicatedCPs.get(trackers.get(robotID)).getFirst();
1373-
}
1373+
lastCommunicatedCP = communicatedCPs.get(tet).getFirst();
13741374
earliestStoppingPathIndex = (lastCommunicatedCP != -1) ? Math.min(lastCommunicatedCP, earliestStoppingPathIndex) : earliestStoppingPathIndex;
13751375

13761376
if (earliestStoppingPathIndex != -1) {

0 commit comments

Comments
 (0)