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

๋ฐ˜์‘ํ˜•

[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

๋ฐ˜์‘ํ˜•