执行任务
This commit is contained in:
@@ -130,6 +130,21 @@ class MissionExecutorV3:
|
||||
grid = mission_config.get("grid", [])
|
||||
positions = mission_config.get("positions", [])
|
||||
|
||||
# 如果 grid 为空,从 machines 重建
|
||||
if not grid or all(not any(rw) if isinstance(rw, list) else True for rw in grid):
|
||||
try:
|
||||
cfg_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "data")
|
||||
with open(os.path.join(cfg_dir, "machines_config.json")) as jf:
|
||||
machines = json.load(jf)
|
||||
grid = [[False] * cols for _ in range(rows)]
|
||||
for m in machines:
|
||||
r = int(m.get("row", 0))
|
||||
c = int(m.get("col", 0))
|
||||
if 0 <= r < rows and 0 <= c < cols:
|
||||
grid[r][c] = True
|
||||
except Exception:
|
||||
grid = [[False] * cols for _ in range(rows)]
|
||||
|
||||
# 1. 生成蛇形路径
|
||||
path = MissionExecutorV3._build_snake_path(rows, cols, grid)
|
||||
if not path:
|
||||
|
||||
Reference in New Issue
Block a user