2026.2.9 小车避让
This commit is contained in:
@@ -99,17 +99,10 @@ public class PathFinder {
|
||||
Collections.reverse(path);
|
||||
|
||||
|
||||
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 使用 A* 算法查找从起点到终点的最短路径。
|
||||
*
|
||||
@@ -203,7 +196,9 @@ public class PathFinder {
|
||||
|
||||
// 如果终点不可达
|
||||
if (gCost[endX][endY] == Integer.MAX_VALUE) {
|
||||
return null;
|
||||
List<int[]> path = new ArrayList<>();
|
||||
path.add(new int[]{-1, -1});
|
||||
return path;
|
||||
}
|
||||
|
||||
// 回溯路径
|
||||
@@ -272,14 +267,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提取路径中的拐点(1→2 或 2→1 的边界点)
|
||||
*
|
||||
@@ -315,15 +302,12 @@ public class PathFinder {
|
||||
List<int[]> collect = inflectionPoints.stream().distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
return collect;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 使用 BFS 查找从起点开始,路径上所有点的值为 2,直到终点(值为 1 或 2)的最短路径。
|
||||
*
|
||||
@@ -398,9 +382,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提取路径中的拐点:
|
||||
* - 区域类型转换点(1 ↔ 2)
|
||||
@@ -507,7 +488,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 计算路径
|
||||
List<int[]> path = findShortestPath(grid, startPoint[0], startPoint[1], srcSite.getStartPoint()[0], srcSite.getStartPoint()[1]);
|
||||
if (path == null) {
|
||||
@@ -515,7 +495,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查路径冲突
|
||||
boolean blocked = tarSites.stream()
|
||||
.filter(other -> other != car)
|
||||
@@ -572,7 +551,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查路径冲突
|
||||
boolean blocked = tarSites.stream()
|
||||
.filter(other -> other != car)
|
||||
@@ -605,7 +583,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 空载查找最佳,使用情景
|
||||
* 小车不载货,一个原点(目标点),多个目标点(原点)
|
||||
@@ -625,7 +602,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 计算路径
|
||||
List<int[]> path = findShortestPath(grid, startPoint[0], startPoint[1], srcSite.getStartPoint()[0], srcSite.getStartPoint()[1]);
|
||||
if (path == null) {
|
||||
@@ -634,7 +610,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查路径冲突
|
||||
boolean blocked = tarSites.stream()
|
||||
.filter(other -> other != car)
|
||||
@@ -669,7 +644,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* 同层多车选择最优
|
||||
@@ -743,9 +717,6 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static Site findOptimalCarForDestinationByFull(
|
||||
int[][] grid, int endX, int endY, List<Site> cars) {
|
||||
// 创建网格副本
|
||||
@@ -878,7 +849,4 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -570,6 +570,16 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
// endSite="07050"+deviceSrgv.getCurrFloor();
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
//处理地图
|
||||
int[][] emptyMap = roadCacheService.handleMap(arrByRoadSite, deviceSrgv);
|
||||
|
||||
//计算最短路径
|
||||
List<int[]> shortestPath = PathFinder.findShortestPath(emptyMap, arrByRoadSite.get(startSite).getX(), arrByRoadSite.get(startSite).getY(), arrByRoadSite.get(endSite).getX(), arrByRoadSite.get(endSite).getY());
|
||||
|
||||
if (shortestPath.size() == 1 && shortestPath.get(0)[0] == -1 && shortestPath.get(0)[1] == -1) {
|
||||
shortestPath = null;
|
||||
String endBlockAgv = null;
|
||||
DeviceSrgv endBlockDevice = null;
|
||||
// TODO 通过arrByRoadSite 中的站点 查询是否存在其他车的站点,如果存在则生成其他车到避让点的队列
|
||||
@@ -627,16 +637,12 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
taskB.setCreateDate(DateUtil.now());
|
||||
wcsSagvQueueMapper.insertWcsSrgvQueue(taskB);
|
||||
taskCache++;
|
||||
log.info("目标点 {} 被小车 {} 占用,已调度其前往避让点 {}", endSite, endBlockAgv, "02050"+endBlockDevice.getCurrFloor());
|
||||
log.info("目标点 {" + deviceSrgv.getCurrSite() + "} 被小车 {" + deviceSrgv.getDeviceId() + "} 占用,已调度其前往避让点 {}", endSite, endBlockAgv, "02050" + endBlockDevice.getCurrFloor());
|
||||
// 当前车等待下一轮调度(待阻挡车移开后自然可达)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//处理地图
|
||||
int[][] emptyMap = roadCacheService.handleMap(arrByRoadSite, deviceSrgv);
|
||||
|
||||
//计算最短路径
|
||||
List<int[]> shortestPath = PathFinder.findShortestPath(emptyMap, arrByRoadSite.get(startSite).getX(), arrByRoadSite.get(startSite).getY(), arrByRoadSite.get(endSite).getX(), arrByRoadSite.get(endSite).getY());
|
||||
|
||||
//判断是否能规划出最短路径
|
||||
if (shortestPath == null || shortestPath.isEmpty()) {
|
||||
@@ -697,9 +703,11 @@ public class BaseSRgvThread implements Runnable, SRgvThreadInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//获取拐点路径
|
||||
List<int[]> trun = PathFinder.extractInflectionPoints2(shortestPath);
|
||||
|
||||
|
||||
// 路径点拼接
|
||||
StringBuilder pathBuilder = new StringBuilder();
|
||||
if (!shortestPath.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user