[Plant Simulation Study #26] – AMR Routing Logic (3): Deadlock Resolution and Optimization

Implementing Logic to Prevent AMR Collision and Deadlock in Siemens Plant Simulation
๐ Overview
This post addresses the deadlock issue that occurred in the previous study ([Plant Simulation Study #25]) involving Autonomous Mobile Robots (AMRs).
It also demonstrates how to optimize the dynamic routing logic of AMRs in more complex environments.
๐ก Key Objectives
- Solve AMR deadlock problems at intersections
- Implement node selection logic that considers occupied states
- Verify efficient movement in a complex grid network
๐บ Watch the Video
๐ฅ [YouTube] Plant Simulation Study (26) – AMR Destination Routing Logic (3): Deadlock Resolution and Optimization
๐ https://youtu.be/wdn4ei89zZw
๐งฉ 1. Analyzing and Fixing the Cause of Deadlock
โ ๏ธ Problem

In the previous version, multiple AMRs would stop face-to-face at intersections, causing a complete deadlock.
The issue stemmed from AMRs’ DistanceCTRL zone being triggered during rotation, halting movement even when the path ahead was clear.
๐ง Solution Strategy
To eliminate this issue, the DistanceCTRL trigger during rotation was removed.
By disabling the zone check while turning, AMRs can now move smoothly without freezing mid-rotation.
๐ง Main Code Snippet
param IsInsideZone : boolean, ZoneNumber : integer
-- param DistanceIsBelowLimit: boolean
if ?.AGVPool /= void
////////////Delete here//////////////
/*if ZoneNumber = 1
var numMUInZone1 = ?.getSafetyZoneContent(1).dim
if IsInsideZone
if numMUInZone1 = 1 then ?.StoppingCounter += 1 end
else
if numMUInZone1 = 0 then ?.StoppingCounter -= 1 end
end
end*/
////////////////////////////////////
var numMUInZone2 = ?.getSafetyZoneContent(2).dim
if numMUInZone2 > 0
?.Speed := ?.Origin.speed * 0.01
if ?.curveSpeed /= -1
?.curveSpeed := ?.Origin.curveSpeed * 0.01
end
else
?.Speed := ?.Origin.Speed
if ?.curveSpeed /= -1
?.curveSpeed := ?.Origin.curveSpeed
end
end
end
โ By removing this small section, AMRs can move through intersections without triggering unintended stops — effectively preventing deadlock conditions.
โ๏ธ 2. Logic Implementation and Testing
๐จ Implementation
Modify the AMR_destination_move method with the updated logic.
When an AMR encounters an occupied node, it waits (waitfor) until the node becomes available, then continues its path automatically.
๐ฌ Simulation Results
- AMRs no longer collide or block each other at intersections.
- Occupied nodes are skipped automatically → Deadlock completely resolved.
- Smooth stop-and-go motion achieved through efficient pathfinding.
๐งญ 3. Testing in a Complex Grid Model
๐งฉ Extended Experiment
The same logic was applied to a large grid-based environment with multiple nodes and intersections.
๐ Results
- AMRs moved through the complex network without collisions or bottlenecks.
- Each robot maintained a safe distance and optimized its route dynamically.
- Verified a stable, deadlock-free flow under heavy traffic conditions.
๐งญ 4. Bonus: Auto-Generating and Connecting Nodes
Instead of manually creating nodes one by one, we implemented an automatic node generation script that builds an entire network based on variable inputs.
๐งฑ Node Generation Logic
for var i := 1 to ๋
ธ๋์ปฌ๋ผ์
for var p := 1 to ๋
ธ๋๋ก์ฐ์
var node := .ShuttleRack.M.duplicate(root)
node._3D.Position := [i * ๋
ธ๋๊ฐ๊ฐ๊ฒฉ ,- p * ๋
ธ๋๊ฐ๊ฐ๊ฒฉ ,0]
์ด๋๊ฐ๋ฅ๋
ธ๋[I,P] := node
DataTable[1,DataTable.ydim+1] := node
next
next
for var t1 := 1 to ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim
for var t2 := 1 to ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim
if t1 /= ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim and t2 /= ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1+1,t2])
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2+1])
elseif t1 = ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim and t2 /= ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2+1])
elseif t2 = ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim and t1 /= ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1+1,t2])
end
next
next
for var t1 := ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim downto 1
for var t2 := ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim downto 1
if t1 /= 1 and t2 /= 1
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1-1,t2])
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2-1])
elseif t1 = 1 and t2 /= 1
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2-1])
elseif t2 = 1 and t1 /= 1
.ShuttleRack.์ปค๋ฅํฐ.connect(์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2],์ด๋๊ฐ๋ฅ๋
ธ๋[t1-1,t2])
end
next
next
๐งน Node Deletion Logic
for var t1 := 1 to ์ด๋๊ฐ๋ฅ๋
ธ๋.xdim
for var t2 := 1 to ์ด๋๊ฐ๋ฅ๋
ธ๋.ydim
์ด๋๊ฐ๋ฅ๋
ธ๋[t1,t2].deleteObject
next
next
dataTable.delete
โจ Conclusion
This study demonstrates a simple yet powerful method to prevent AMR deadlocks in Siemens Plant Simulation by refining node-based logic and eliminating DistanceCTRL triggers during rotation.
It also shows how to automatically generate node networks through parameterized logic, making model scalability much easier.
โ Key Takeaways
- Disable DistanceCTRL trigger during AMR rotation
- Automatically create and connect nodes using parameters
- Achieve full deadlock-free and optimized AMR pathfinding
๐ท๏ธ Tags / SEO Keywords
#PlantSimulation #AMR #Deadlock #RoutingLogic #DigitalTwin #Simulation #SmartFactory #SiemensTecnomatix #Optimization