From d127e27168d07199b0d4d55c0a5d431761f490d1 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期三, 23 七月 2025 08:36:19 +0800
Subject: [PATCH] 保存一个版本

---
 zy-acs-manager/src/main/resources/agv.py |   51 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/zy-acs-manager/src/main/resources/agv.py b/zy-acs-manager/src/main/resources/agv.py
index 23d4dd6..ad188ed 100644
--- a/zy-acs-manager/src/main/resources/agv.py
+++ b/zy-acs-manager/src/main/resources/agv.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 import ast
 import multiprocessing
 import sys
@@ -19,29 +21,45 @@
 
 def getWaveScopeByCode_iterative(x, y, codeMatrix, cdaMatrix, radiusLen):
     """
-    浣跨敤骞垮害浼樺厛鎼滅储锛圔FS锛夋潵浠f浛閫掑綊锛屼互閬垮厤閫掑綊娣卞害杩囧ぇ鐨勯棶棰樸��
+    浣跨敤骞垮害浼樺厛鎼滅储锛圔FS锛夊苟璺熻釜鎵╁睍鏂瑰悜锛屼互閬垮厤閫掑綊娣卞害杩囧ぇ鍜屼笉蹇呰鐨勮祫婧愭氮璐广��
+    褰撻亣鍒� 'NONE' 鑺傜偣鏃讹紝浠呭湪褰撳墠鏂瑰悜涓婄户缁墿灞曘��
     """
     includeList = []
     existNodes = set()
     queue = deque()
 
-    originNode = {"x": x, "y": y}
-    currNode = {"x": x, "y": y}
-    queue.append(currNode)
+    # 鍒濆鑺傜偣锛屾病鏈夋柟鍚�
+    originNode = {"x": x, "y": y, "dir": None}
+    queue.append(originNode)
     existNodes.add((x, y))
 
     while queue:
         node = queue.popleft()
-        node_x, node_y = node['x'], node['y']
-        neighbors = [
-            (node_x + 1, node_y),
-            (node_x - 1, node_y),
-            (node_x, node_y + 1),
-            (node_x, node_y - 1)
-        ]
+        node_x, node_y, current_dir = node['x'], node['y'], node['dir']
 
-        for neighbor in neighbors:
-            nx, ny = neighbor
+        # 鏍规嵁褰撳墠鏂瑰悜鍐冲畾鎵╁睍鐨勬柟鍚�
+        if current_dir is None:
+            # 濡傛灉娌℃湁鏂瑰悜锛屽悜鍥涗釜鏂瑰悜鎵╁睍
+            neighbors = [
+                (node_x + 1, node_y, 'right'),
+                (node_x - 1, node_y, 'left'),
+                (node_x, node_y + 1, 'down'),
+                (node_x, node_y - 1, 'up')
+            ]
+        else:
+            # 濡傛灉鏈夋柟鍚戯紝浠呭湪璇ユ柟鍚戜笂鎵╁睍
+            if current_dir == 'right':
+                neighbors = [(node_x + 1, node_y, 'right')]
+            elif current_dir == 'left':
+                neighbors = [(node_x - 1, node_y, 'left')]
+            elif current_dir == 'down':
+                neighbors = [(node_x, node_y + 1, 'down')]
+            elif current_dir == 'up':
+                neighbors = [(node_x, node_y - 1, 'up')]
+            else:
+                neighbors = []
+
+        for nx, ny, direction in neighbors:
             # 妫�鏌ヨ竟鐣屾潯浠�
             if (nx < 0 or nx >= codeMatrix.shape[0] or ny < 0 or ny >= codeMatrix.shape[1]):
                 continue
@@ -52,8 +70,10 @@
             neighbor_code = codeMatrix[nx, ny]
 
             if neighbor_code == 'NONE':
-                queue.append({"x": nx, "y": ny})
+                # 閬囧埌 'NONE' 鑺傜偣锛岀户缁湪褰撳墠鏂瑰悜涓婃墿灞�
+                queue.append({"x": nx, "y": ny, "dir": direction})
             else:
+                # 妫�鏌ヨ窛绂绘潯浠�
                 o1Cda = convert_to_float_array(cdaMatrix[x, y])
                 o2Cda = convert_to_float_array(cdaMatrix[nx, ny])
 
@@ -65,7 +85,8 @@
                         "y": int(ny),
                         "code": str(codeMatrix[nx, ny])
                     })
-                    queue.append({"x": nx, "y": ny})
+                    # 闈� 'NONE' 鑺傜偣锛岄噸缃柟鍚�
+                    queue.append({"x": nx, "y": ny, "dir": None})
 
     return includeList
 

--
Gitblit v1.9.1