1、上个算法导致不出单点解——找到bug,selectOne的条件少了limit 1

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

View File

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

View File

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