| | |
| | | String next = pathListPart.get(i); |
| | | |
| | | Code nextCode = codeService.getCacheByData(next); |
| | | // 车头朝前的下一个行走方向 |
| | | Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal); |
| | | |
| | | // 反向角 |
| | | final double oppLastDir = (lastDirection + 180) % 360; |
| | | // 是否倒退行走 |
| | | boolean reverse = false; |
| | | |
| | | // 巷道逻辑 |
| | | if (!laneBuilder.isInitialized()) { |
| | |
| | | LaneDto lastLaneDto = laneBuilder.search(lastCode.getData()); |
| | | LaneDto nextLaneDto = laneBuilder.search(nextCode.getData()); |
| | | // 进入巷道角度 |
| | | Double laneDir = laneService.getLaneDirection(nextLaneDto); |
| | | // 第一次进入此巷道 |
| | | boolean firstEnteringLane = null != laneDir && ( |
| | | lastLaneDto == null |
| | | || !Objects.equals(lastLaneDto.getHashCode(), nextLaneDto.getHashCode()) |
| | | ); |
| | | |
| | | boolean reverse = false; |
| | | Double lastLaneDir = laneService.getLaneDirection(lastLaneDto); |
| | | Double nextLaneDir = laneService.getLaneDirection(nextLaneDto); |
| | | |
| | | // 巷道强制转弯,优先级 > workDirection |
| | | if (firstEnteringLane) { |
| | | // final double oppLaneDir = (laneDir + 180) % 360; |
| | | if (!lastDirection.equals(laneDir)) { |
| | | if (null != nextLaneDir) { |
| | | final double oppNextLaneDir = (nextLaneDir + 180) % 360; |
| | | |
| | | if (!lastDirection.equals(nextLaneDir)) { |
| | | if (!lastCode.getCornerBool()) { |
| | | throw new CoolException(agvNo + "号小车进入巷道需调整方向为 " + laneDir + "°,请推至转弯点手动调整"); |
| | | throw new CoolException(agvNo + "号小车进入巷道需调整方向为 " + nextLaneDir + "°,请推至转弯点手动调整"); |
| | | } |
| | | // turn |
| | | actionList.add(new Action( |
| | |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | (double) mapService.spinDirection(lastCode).val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(laneDir), // 动作参数 |
| | | String.valueOf(nextLaneDir), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | lastDirection = laneDir; |
| | | lastDirection = nextLaneDir; |
| | | |
| | | if (nextDirection.equals(oppNextLaneDir)) { |
| | | reverse = true; |
| | | } |
| | | } else { |
| | | if (nextDirection.equals(oppNextLaneDir)) { |
| | | nextDirection = nextLaneDir; |
| | | reverse = true; |
| | | } |
| | | } |
| | | |
| | | nextDirection = nextLaneDir; |
| | | } else if (null != lastLaneDir) { |
| | | final double oppLastLaneDir = (lastLaneDir + 180) % 360; |
| | | if (nextDirection.equals(oppLastLaneDir)) { |
| | | reverse = true; |
| | | } |
| | | nextDirection = lastLaneDir; |
| | | |
| | | if (!lastDirection.equals(nextDirection)) { |
| | | if (!lastCode.getCornerBool()) { |
| | | throw new CoolException(agvNo + "号小车离开巷道需调整方向为 " + nextDirection + "°,请推至转弯点手动调整"); |
| | | } |
| | | } |
| | | } else { |
| | | |
| | |
| | | // 初始方向值补丁 |
| | | if (first) { |
| | | if (Cools.isEmpty(actionList) || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | Double firstTurnDir = workDirection; |
| | | |
| | | // 巷道逻辑 |
| | | if (!laneBuilder.isInitialized()) { |
| | | throw new CoolException("lanes are not initialized"); |
| | | } |
| | | LaneDto lastLaneDto = laneBuilder.search(lastCode.getData()); |
| | | // 进入巷道角度 |
| | | Double lastLaneDir = laneService.getLaneDirection(lastLaneDto); |
| | | if (lastLaneDir != null) { |
| | | firstTurnDir = lastLaneDir; |
| | | } |
| | | |
| | | if (!lastDirection.equals(firstTurnDir)) { |
| | | if (!lastCode.getCornerBool()) { |
| | | throw new CoolException(agvNo + "号小车方向错误,请推至转弯点手动调整"); |
| | | } |
| | | } |
| | | |
| | | // turn |
| | | actionList.add(new Action( |
| | | null, // 编号 |
| | |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | (double) mapService.spinDirection(lastCode).val, // 属性值 |
| | | lastCode.getData(), // 地面码 |
| | | String.valueOf(workDirection), // 动作参数 |
| | | String.valueOf(firstTurnDir), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | actionPrepareSts, // 动作进度 |
| | | agvId, // AGV |
| | | now // 工作时间 |
| | | )); |
| | | |
| | | lastDirection = workDirection; |
| | | lastDirection = firstTurnDir; |
| | | |
| | | } |
| | | first = false; |
| | |
| | | AGV_06_DOWN agv_06_down = new AGV_06_DOWN(); |
| | | agv_06_down.setSerialNo(agv_06_up.getSerialNo()); |
| | | agv_06_down.setActionCode(agv_06_up.getActionCode()); |
| | | agv_06_down.setResult(success ? 1 : 0); |
| | | |
| | | //agv_06_down.setResult(success ? 1 : 0); |
| | | agv_06_down.setResult(1); |
| | | redis.push(RedisConstant.AGV_PATH_DOWN_FLAG, AgvProtocol.build(protocol.getAgvNo()).setMessageBody(agv_06_down)); |
| | | } |
| | | |