diff --git a/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java b/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java index 31a9256..340d2ac 100644 --- a/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java +++ b/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java @@ -106,25 +106,21 @@ /** * 区域覆盖-已校验 - * 2A - * 30 - * 02 - * 01 - * 00 固定00 + * 2A 48 02 01 00 * 03 参与机器人个数 * 01 02 05 机器人IDs - * 4D 1C E6 48 经度 - * 18 7F 6E 5D 纬度 - * 4D 1C E6 48 经度 - * 18 81 40 65 纬度 - * 4D 1C E6 48 经度 - * 18 83 12 6E 纬度 - * 01 轮廓点数 - * 5A 0C 圆形区域半径 - * 01 轮廓标志位 - * 4D 15 9F 14 18 经度 - * 76 54 A9 E8 38 纬度 - * 0A 帧尾 + * 4D 1C E6 48 18 7F 6E 5D 目标经纬度 + * 4D 1C E6 48 18 81 40 65 目标经纬度 + * 4D 1C E6 48 18 83 12 6E 目标经纬度 + * 04 轮廓点数 + * 00 00 区域半径 + * 00 标志位 + * 4D 1B 14 40 18 7B CA 4B 区域经纬度 + * 4D 1E B8 51 18 7B CA 4B 区域经纬度 + * 4D 1E B8 51 18 7F 6E 5D 区域经纬度 + * 4D 1B 14 40 18 7F 6E 5D 区域经纬度 + * D6 2E 校验位 + * 0A 帧尾 */ public static String decodeRobotRegion(byte[] bytes) { Map regionMap = new HashMap<>(7); @@ -147,24 +143,24 @@ int targetSize = count * (4 + 4); byte[] targetBytes = new byte[targetSize]; //起始5个字节,机器人个数1个字节 - System.arraycopy(bytes, 5 + idsBytes.length + 1, targetBytes, 0, targetSize); + System.arraycopy(bytes, 5 + 1 + idsBytes.length, targetBytes, 0, targetBytes.length); regionMap.put("robotTargets", formatLngLat(targetBytes)); - regionMap.put("pointCount", bytes[5 + idsBytes.length + targetBytes.length + 1]); + int pointCount = bytes[5 + 1 + idsBytes.length + targetBytes.length]; + regionMap.put("pointCount", pointCount); byte[] radiusBytes = new byte[2]; - System.arraycopy(bytes, 5 + idsBytes.length + targetBytes.length + 1 + 1, radiusBytes, 0, 2); + System.arraycopy(bytes, 5 + 1 + idsBytes.length + targetBytes.length + 1, radiusBytes, 0, radiusBytes.length); regionMap.put("regionRadius", covertTargetDistance(radiusBytes)); - int contour = bytes[5 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length + 1]; - regionMap.put("contour", contour); + regionMap.put("contour", bytes[5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length]); //经度(4)、纬度(4) - int regionSize = contour * (4 + 4); + int regionSize = pointCount * (4 + 4); byte[] regionBytes = new byte[regionSize]; System.arraycopy(bytes, - 5 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length + 1 + 1, - regionBytes, 0, regionSize); + 5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length + 1, + regionBytes, 0, regionBytes.length); regionMap.put("regionPoints", formatLngLat(regionBytes)); return JSON.toJSONString(regionMap); } @@ -173,7 +169,7 @@ * 路径规划-已校验 */ public static String decodeRobotRoute(byte[] bytes) { - Map routeMap = new HashMap<>(2); + Map routeMap = new HashMap<>(5); byte[] countBytes = new byte[2]; System.arraycopy(bytes, 5, countBytes, 0, 2); @@ -231,22 +227,15 @@ /** * 航路点任务-已校验 - * 2A 帧头 - * 2B 帧长度 - * 03 帧类型 - * 02 子类型 + * 2A 2B 03 02 * 01 机器人ID * 00 64 任务深度 * 04 航路点个数 - * 4D A5 3B 06 经度1 - * 0C 58 17 4F 纬度1 - * 4C F2 38 5E 经度2 - * 0C 5B 20 08 纬度2 - * 4D AB 4C 78 经度3 - * 0C 5E 28 C2 纬度3 - * 4C F8 49 D1 经度4 - * 0C 61 31 7B 纬度4 - * A5 95 CRC16校验码 + * 4D A5 3B 06 0C 58 17 4F 经纬度 + * 4C F2 38 5E 0C 5B 20 08 经纬度 + * 4D AB 4C 78 0C 5E 28 C2 经纬度 + * 4C F8 49 D1 0C 61 31 7B 经纬度 + * A5 95 校验码 * 0A 帧尾 */ public static String decodeTaskRoute(byte[] bytes) { @@ -426,11 +415,11 @@ for (int i = 0; i < targetBytes.length; i += 8) { PointDTO point = new PointDTO(); byte[] lngBytes = new byte[4]; - System.arraycopy(targetBytes, i, lngBytes, 0, 4); + System.arraycopy(targetBytes, i, lngBytes, 0, lngBytes.length); point.setLng(covertLngLat(lngBytes)); byte[] latBytes = new byte[4]; - System.arraycopy(targetBytes, i + lngBytes.length, latBytes, 0, 4); + System.arraycopy(targetBytes, i + lngBytes.length, latBytes, 0, latBytes.length); point.setLat(covertLngLat(latBytes)); pointList.add(point); @@ -584,6 +573,4 @@ ) / (Math.pow(2, 31) - 1); return 180 * per; } - - -} +} \ No newline at end of file