| | |
| | | if (fastPath != null) { |
| | | return fastPath; |
| | | } |
| | | return planSpaceTimePath(startCode, endCode, constraints, null, null); |
| | | long defaultStartTime = System.currentTimeMillis(); |
| | | return planSpaceTimePath(startCode, endCode, constraints, null, null, defaultStartTime); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * @param constraints 静态约束条件 |
| | | * @param spaceTimeOccupancyMap 时空占用表 |
| | | * @param physicalConfig CTU物理配置 |
| | | * @param startTimeMs 起始时间(毫秒) |
| | | * @return 规划的路径 |
| | | */ |
| | | public PlannedPath planSpaceTimePath(String startCode, String endCode, |
| | | List<double[]> constraints, |
| | | Map<String, String> spaceTimeOccupancyMap, |
| | | CTUPhysicalConfig physicalConfig) { |
| | | CTUPhysicalConfig physicalConfig, |
| | | long startTimeMs) { |
| | | // 验证输入 |
| | | if (!isValidPathPoint(startCode) || !isValidPathPoint(endCode)) { |
| | | System.out.println("无效的路径点: " + startCode + " 或 " + endCode); |
| | |
| | | // 时空A*算法实现 |
| | | PlannedPath result = spaceTimeAStarSearch( |
| | | startCode, endCode, startCoord, endCoord, |
| | | constraints, spaceTimeOccupancyMap, physicalConfig |
| | | constraints, spaceTimeOccupancyMap, physicalConfig, startTimeMs |
| | | ); |
| | | |
| | | if (result != null) { |
| | |
| | | * @param constraints 约束条件 |
| | | * @param occupancyMap 时空占用表 |
| | | * @param physicalConfig 物理配置 |
| | | * @param startTimeMs 起始时间(毫秒) |
| | | * @return 规划的路径 |
| | | */ |
| | | private PlannedPath spaceTimeAStarSearch(String startCode, String endCode, |
| | | int[] startCoord, int[] endCoord, |
| | | List<double[]> constraints, |
| | | Map<String, String> occupancyMap, |
| | | CTUPhysicalConfig physicalConfig) { |
| | | CTUPhysicalConfig physicalConfig, |
| | | long startTimeMs) { |
| | | |
| | | // 使用优先队列实现开放列表 |
| | | PriorityQueue<SpaceTimeAStarNode> openSet = new PriorityQueue<>( |
| | |
| | | Map<String, Double> gScores = new HashMap<>(); |
| | | Map<String, SpaceTimeAStarNode> cameFrom = new HashMap<>(); |
| | | |
| | | // 起始时间 |
| | | long startTime = System.currentTimeMillis(); |
| | | long startTime = startTimeMs; |
| | | |
| | | // 初始化起始节点 |
| | | SpaceTimeAStarNode startNode = new SpaceTimeAStarNode( |