From 7abc9ad72e595ecfd2b71d6b5bbf5e91f5a4f617 Mon Sep 17 00:00:00 2001 From: weidong Date: Mon, 5 Aug 2024 22:02:23 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=B8=8A=E4=B8=AA=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E4=B8=8D=E5=87=BA=E5=8D=95=E7=82=B9=E8=A7=A3?= =?UTF-8?q?=EF=BC=8C=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sideslope/calc/GNSSCalcFilterService.java | 34 +++++++++++-------- .../calc/SingleLineGNSSCalcService.java | 8 ++--- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/GNSSCalcFilterService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/GNSSCalcFilterService.java index 1f69681a..66303d92 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/GNSSCalcFilterService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/GNSSCalcFilterService.java @@ -63,6 +63,9 @@ public class GNSSCalcFilterService { public boolean isGoodGnssData(GnssCalcData newRecord, double[] referPos, List gnssHistoryRecords, float xyThreshold, float zThreshold, boolean isAdvFilter) { + boolean isGood = true; + + // 检查是不是坏点 GnssCalcData record0 = null; if(gnssHistoryRecords.size()>0) record0 = gnssHistoryRecords.get(0); @@ -72,25 +75,26 @@ public class GNSSCalcFilterService { if(Math.abs(record0.getB562e() - newRecord.getB562e())<0.001) { return false; } - - // 和最近一个滤波值相比,判断是否是好点 - boolean isGood =(referPos!=null && (Math.abs(newRecord.getB562e() - referPos[0]) <= xyThreshold && - Math.abs(newRecord.getB562n() - referPos[1]) <= xyThreshold && - Math.abs(newRecord.getB562d() - referPos[2]) <= zThreshold)); - logger.debug("{} point judge {}",newRecord.getDeviceid(), isGood); - //如果和参考点比无效,则和上一个点相比 - if(!isGood) { - isGood =(Math.abs(newRecord.getB562e() - record0.getB562e()) <= xyThreshold && - Math.abs(newRecord.getB562n() - record0.getB562n()) <= xyThreshold && - Math.abs(newRecord.getB562d() - record0.getB562d()) <= zThreshold); - // 如果是好点,对于增强算法还需和前2个比较 - if(isGood && isAdvFilter){ + //和上一个点相比,超过门限则认为无效 + if (Math.abs(newRecord.getB562e() - record0.getB562e()) > xyThreshold || + Math.abs(newRecord.getB562n() - record0.getB562n()) > xyThreshold || + Math.abs(newRecord.getB562d() - record0.getB562d()) > zThreshold) { + isGood = false; //记录为坏点,下次不参与滤波 + logger.debug("{} bad point",newRecord.getDeviceid()); + } + // 如果是好点,对于增强算法还需做进一步判断 + if(isGood && isAdvFilter){ + //和参考点比,如果是坏点,再和前二个点比如果还是坏点才认为是坏点 + isGood =(referPos!=null && (Math.abs(newRecord.getB562e() - referPos[0]) <= xyThreshold && + Math.abs(newRecord.getB562n() - referPos[1]) <= xyThreshold && + Math.abs(newRecord.getB562d() - referPos[2]) <= zThreshold)); + if(!isGood){ GnssCalcData record1 = null; if (gnssHistoryRecords.size() > 1) record1 = gnssHistoryRecords.get(1); isGood =(record1 == null || - (Math.abs(newRecord.getB562e() - record1.getB562e()) <= xyThreshold && + ((Math.abs(newRecord.getB562e() - record1.getB562e()) <= xyThreshold && Math.abs(newRecord.getB562n() - record1.getB562n()) <= xyThreshold && - Math.abs(newRecord.getB562d() - record1.getB562d()) <= zThreshold)); + Math.abs(newRecord.getB562d() - record1.getB562d()) <= zThreshold))); } logger.debug("{} point adv judge {}",newRecord.getDeviceid(), isGood); } diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java index 9dc8101e..caa578e1 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/calc/SingleLineGNSSCalcService.java @@ -215,8 +215,7 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService { // pps locationRecord.setPps(focusCalculator.getAvgDelayMs()); // 滤波后的结果 - double[] latestRpos = getLatestRpos(deviceId); - gnssCalcFilterService.calc(device, groupCalc, locationRecord, latestRpos); + gnssCalcFilterService.calc(device, groupCalc, locationRecord, referPos); // 记录本次位置,作为下次的参考 // 算法1:以上轮位置作为参考,跟随变化速度快 @@ -227,7 +226,8 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService { new double[]{locationRecord.getRpose(),locationRecord.getRposn(),locationRecord.getRposd()}); } else if(focusCalculator.getReferPoint() == null){ - if(latestRpos != null) focusCalculator.setReferPoint(latestRpos); + double[] latestPos = getLatestPos(deviceId); + if(latestPos != null) focusCalculator.setReferPoint(latestPos); else focusCalculator.setReferPoint(b562Result); } } @@ -292,7 +292,7 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService { logger.info("device paras changed"); } - double[] getLatestRpos(String deviceId){ + double[] getLatestPos(String deviceId){ QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("deviceid",deviceId); queryWrapper.ge("createtime",LocalDateTime.now().minusHours(12));