1、上个算法导致不出单点解,回退

This commit is contained in:
weidong 2024-08-05 22:02:23 +08:00
parent ebcf103019
commit 7abc9ad72e
2 changed files with 23 additions and 19 deletions

View File

@ -63,6 +63,9 @@ public class GNSSCalcFilterService {
public boolean isGoodGnssData(GnssCalcData newRecord, double[] referPos, List<GnssCalcData> gnssHistoryRecords, public boolean isGoodGnssData(GnssCalcData newRecord, double[] referPos, List<GnssCalcData> gnssHistoryRecords,
float xyThreshold, float zThreshold, boolean isAdvFilter) { float xyThreshold, float zThreshold, boolean isAdvFilter) {
boolean isGood = true;
// 检查是不是坏点
GnssCalcData record0 = null; GnssCalcData record0 = null;
if(gnssHistoryRecords.size()>0) record0 = gnssHistoryRecords.get(0); if(gnssHistoryRecords.size()>0) record0 = gnssHistoryRecords.get(0);
@ -72,25 +75,26 @@ public class GNSSCalcFilterService {
if(Math.abs(record0.getB562e() - newRecord.getB562e())<0.001) { if(Math.abs(record0.getB562e() - newRecord.getB562e())<0.001) {
return false; return false;
} }
//和上一个点相比超过门限则认为无效
// 和最近一个滤波值相比判断是否是好点 if (Math.abs(newRecord.getB562e() - record0.getB562e()) > xyThreshold ||
boolean isGood =(referPos!=null && (Math.abs(newRecord.getB562e() - referPos[0]) <= 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.getB562n() - referPos[1]) <= xyThreshold &&
Math.abs(newRecord.getB562d() - referPos[2]) <= zThreshold)); Math.abs(newRecord.getB562d() - referPos[2]) <= zThreshold));
logger.debug("{} point judge {}",newRecord.getDeviceid(), isGood); if(!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){
GnssCalcData record1 = null; GnssCalcData record1 = null;
if (gnssHistoryRecords.size() > 1) record1 = gnssHistoryRecords.get(1); if (gnssHistoryRecords.size() > 1) record1 = gnssHistoryRecords.get(1);
isGood =(record1 == null || 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.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); logger.debug("{} point adv judge {}",newRecord.getDeviceid(), isGood);
} }

View File

@ -215,8 +215,7 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService {
// pps // pps
locationRecord.setPps(focusCalculator.getAvgDelayMs()); locationRecord.setPps(focusCalculator.getAvgDelayMs());
// 滤波后的结果 // 滤波后的结果
double[] latestRpos = getLatestRpos(deviceId); gnssCalcFilterService.calc(device, groupCalc, locationRecord, referPos);
gnssCalcFilterService.calc(device, groupCalc, locationRecord, latestRpos);
// 记录本次位置作为下次的参考 // 记录本次位置作为下次的参考
// 算法1以上轮位置作为参考跟随变化速度快 // 算法1以上轮位置作为参考跟随变化速度快
@ -227,7 +226,8 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService {
new double[]{locationRecord.getRpose(),locationRecord.getRposn(),locationRecord.getRposd()}); new double[]{locationRecord.getRpose(),locationRecord.getRposn(),locationRecord.getRposd()});
} }
else if(focusCalculator.getReferPoint() == null){ 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); else focusCalculator.setReferPoint(b562Result);
} }
} }
@ -292,7 +292,7 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService {
logger.info("device paras changed"); logger.info("device paras changed");
} }
double[] getLatestRpos(String deviceId){ double[] getLatestPos(String deviceId){
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>(); QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("deviceid",deviceId); queryWrapper.eq("deviceid",deviceId);
queryWrapper.ge("createtime",LocalDateTime.now().minusHours(12)); queryWrapper.ge("createtime",LocalDateTime.now().minusHours(12));