From 6807e50ebfcc9328f06c6b5e977323a2e9d50f57 Mon Sep 17 00:00:00 2001 From: Federico Pecora Date: Wed, 15 Jan 2020 15:08:24 +0100 Subject: [PATCH] Added method to check if there is a deadlock or non-live situation --- .../TrajectoryEnvelopeCoordinator.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/se/oru/coordination/coordination_oru/TrajectoryEnvelopeCoordinator.java b/src/main/java/se/oru/coordination/coordination_oru/TrajectoryEnvelopeCoordinator.java index d3f9f8205..7efaa9e54 100644 --- a/src/main/java/se/oru/coordination/coordination_oru/TrajectoryEnvelopeCoordinator.java +++ b/src/main/java/se/oru/coordination/coordination_oru/TrajectoryEnvelopeCoordinator.java @@ -89,6 +89,8 @@ public abstract class TrajectoryEnvelopeCoordinator extends AbstractTrajectoryEn //True if waiting for deadlocks to happen. protected boolean staticReplan = false; + protected boolean isDeadlocked = false; + /** * Set whether the coordinator should try to break deadlocks by attempting to re-plan * the path of one of the robots involved in an unsafe cycle. @@ -315,6 +317,15 @@ private HashSet computeClosestDependencies(HashMaptrue iff there is currently a deadlock, or the situation is + * such that a deadlock will occur (non-live state). + */ + public boolean isDeadlocked() { + return this.isDeadlocked; + } + private HashMap> findCurrentCycles(HashMap> currentDeps, HashMap> artificialDeps, HashSet reversibleDeps, HashMap currentReports, Set robotIDs) { HashMap> allDeps = new HashMap>(); @@ -338,6 +349,8 @@ private HashMap> findCurrentCycles(HashMap g = depsToGraph(currentDependencies); List> unsafeCycles = findSimpleUnsafeCycles(g); + if (unsafeCycles.size() > 0) this.isDeadlocked = true; + // ... keep tracks of size and old cycles for statistics List> unsafeCyclesNew = new ArrayList>(); unsafeCyclesNew.addAll(unsafeCycles);