| | |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | public static final boolean OPEN_TURN_COST_WEIGHT = Boolean.FALSE; |
| | | public static final boolean OPEN_TURN_COST_WEIGHT = Boolean.TRUE; |
| | | |
| | | public static final int WEIGHT_CALC_FACTOR = 1; |
| | | |
| | |
| | | if (!Cools.isEmpty(blackList) && blackList.contains(node.getCodeData())) { |
| | | continue; |
| | | } |
| | | // 特殊情况,当blackList有且只有一个元素且为startNode时 |
| | | // 说明blackList已经知道当前导航起始点和目标点为相邻节点 |
| | | // 但是当前blackList的任务是不让系统走相邻的最短路径,所以才会有下面的判断和continue |
| | | if (blackList.size() == 1 && blackList.get(0).equals(start.getCodeData())) { |
| | | if (isEndNode && currentNode.getCodeData().equals(start.getCodeData())) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // 节点被占用 |
| | | DynamicNode dynamicNode = dynamicMatrix[node.getX()][node.getY()]; |
| | |
| | | if (!vehicle.equals(DynamicNodeType.ACCESS.val)) { |
| | | if (!vehicle.equals(agvNo)) { |
| | | |
| | | // 存在车辆,且为已经避让的车,则权重值增加 |
| | | // 如果存在车辆,则增加权重 2 或者 3,因为拐点会增加权重 1 |
| | | // vehicle已经为当前segment做过了避让,且避让任务已完成,则权重值增加 |
| | | if (null != segment) { |
| | | if (!Cools.isEmpty(jamService.getJamFromSegmentByAvo(segment, vehicle))) { |
| | | weight += WEIGHT_CALC_FACTOR; |
| | | weight += (WEIGHT_CALC_FACTOR * 3); |
| | | } else { |
| | | weight += (WEIGHT_CALC_FACTOR * 2); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // G + H + T (对启发函数增加去拐点方案calcNodeTurnCost) |
| | | int gCost = calcNodeCost(currentNode, node) * (OPEN_TURN_COST_WEIGHT ? calcNodeTurnCost(currentNode, node, end) : 1); |
| | | int gCost = calcNodeCost(currentNode, node); |
| | | |
| | | if (OPEN_TURN_COST_WEIGHT) { |
| | | gCost += calcNodeTurnCost(currentNode, node, end); |
| | | } |
| | | |
| | | //进行计算对 G, F, H 等值 |
| | | node.setWeight(weight); |
| | |
| | | || nextNode.getX() == currNode.getParent().getX() |
| | | || nextNode.getY() == currNode.getParent().getY() |
| | | ) { |
| | | return 1; |
| | | return 0; |
| | | } |
| | | |
| | | // 拐向终点的点 |
| | | if (nextNode.getX() == endNode.getX() || nextNode.getY() == endNode.getY()) { |
| | | return 2; |
| | | return 1; |
| | | } |
| | | |
| | | // 普通拐点 |
| | | /* |
| | | 拐点判断逻辑 |
| | | 拿到父节点和下一节点 |
| | | 通过判断父节点和下一节点的x数据和y数据都不相同时,则表明当前坐标是一个拐点 |
| | | */ |
| | | return 3; |
| | | return 1; |
| | | } |
| | | |
| | | } |