forked from XiaoGongWei/MG_APP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQPPPModel.cpp
1628 lines (1546 loc) · 75.8 KB
/
QPPPModel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "QPPPModel.h"
QStringList QPPPModel::searchFilterFile(QString floder_path, QStringList filers)
{
QDir floder_Dir(floder_path);
QStringList all_file_path;
floder_Dir.setFilter(QDir::Files | QDir::NoSymLinks);
floder_Dir.setNameFilters(filers);
QFileInfoList file_infos = floder_Dir.entryInfoList();
for(int i = 0;i < file_infos.length();i++)
{
QFileInfo file_info = file_infos.at(i);
if(file_info.fileName() != "." || file_info.fileName() != "..")
all_file_path.append(file_info.absoluteFilePath());
}
return all_file_path;
}
//Run the specified directory file
QPPPModel::QPPPModel(QString files_path, QTextEdit *pQTextEdit, QString Method, QString Satsystem,
QString TropDelay, double CutAngle, bool isKinematic, QString Smooth_Str)
{
// Display for GUI
mp_QTextEditforDisplay = pQTextEdit;
//Initialize variables
initVar();
m_run_floder = files_path + PATHSEG;
m_App_floder = QCoreApplication::applicationDirPath() + PATHSEG;
// find files
QStringList tempFilters,
OFileNamesList, Sp3FileNamesList, ClkFileNamesList, ErpFileNamesList,
AtxFileNamesList, BlqFileNamesList, GrdFileNamesList;
// find obs files
tempFilters.clear();
tempFilters.append("*.*o");
OFileNamesList = searchFilterFile(m_run_floder, tempFilters);
// find sp3 files
tempFilters.clear();
tempFilters.append("*.sp3");
Sp3FileNamesList = searchFilterFile(m_run_floder, tempFilters);
// find clk files
tempFilters.clear();
tempFilters.append("*.clk");
ClkFileNamesList = searchFilterFile(m_run_floder, tempFilters);
// find erp files
tempFilters.clear();
tempFilters.append("*.erp");
ErpFileNamesList = searchFilterFile(m_run_floder, tempFilters);
// find Atx files
tempFilters.clear();
tempFilters.append("*.atx");
QStringList run_floder, app_floder;
run_floder = searchFilterFile(m_run_floder, tempFilters);
app_floder = searchFilterFile(m_App_floder, tempFilters);
AtxFileNamesList.append(run_floder);
AtxFileNamesList.append(app_floder);
run_floder.clear();
app_floder.clear();
// find blq files
tempFilters.clear();
tempFilters.append("*.blq");
run_floder = searchFilterFile(m_run_floder, tempFilters);
app_floder = searchFilterFile(m_App_floder, tempFilters);
BlqFileNamesList.append(run_floder);
BlqFileNamesList.append(app_floder);
run_floder.clear();
app_floder.clear();
// find grd files
tempFilters.clear();
tempFilters.append("*.grd");
run_floder = searchFilterFile(m_run_floder, tempFilters);
app_floder = searchFilterFile(m_App_floder, tempFilters);
GrdFileNamesList.append(run_floder);
GrdFileNamesList.append(app_floder);
run_floder.clear();
app_floder.clear();
// get want file
// o file
QString OfileName = "", erpFile = "", blqFile = "", atxFile = "", grdFile = "";
if (!OFileNamesList.isEmpty())
{
OfileName = OFileNamesList.at(0);
m_haveObsFile = true;
}
else
{
ErroTrace("QPPPModel::QPPPModel: Cant not find Obsvertion file.");
m_haveObsFile = false;
}
if(!ErpFileNamesList.isEmpty()) erpFile = ErpFileNamesList.at(0);
if(!AtxFileNamesList.isEmpty()) atxFile = AtxFileNamesList.at(0);
if(!BlqFileNamesList.isEmpty()) blqFile = BlqFileNamesList.at(0);
if(!GrdFileNamesList.isEmpty()) grdFile = GrdFileNamesList.at(0);
// use defualt config
setConfigure(Method, Satsystem, TropDelay, CutAngle, isKinematic, Smooth_Str);
// save data to QPPPModel
initQPPPModel(OfileName, Sp3FileNamesList, ClkFileNamesList, erpFile, blqFile, atxFile, grdFile);
}
void QPPPModel::setConfigure(QString Method, QString Satsystem, QString TropDelay, double CutAngle, bool isKinematic, QString Smooth_Str)
{
// Configure
m_Solver_Method = Method;// m_Solver_Method value can be "SRIF" or "Kalman"
m_CutAngle = CutAngle;// (degree)
m_SatSystem = Satsystem;// GPS, GLONASS, BDS, and Galieo are used respectively: the letters G, R, C, E
m_TropDelay = TropDelay;// The tropospheric model m_TropDelay can choose Sass, Hopfiled, UNB3m
//Setting up the file system SystemStr:"G"(Turn on the GPS system);"GR":(Turn on the GPS+GLONASS system);"GRCE" (Open all), etc.
//GPS, GLONASS, BDS, and Galieo are used respectively: the letters G, R, C, E
setSatlitSys(Satsystem);
m_sys_str = Satsystem;
m_sys_num = getSystemnum();
// set filter Model
if(isKinematic)
{
m_KalmanClass.setModel(QKalmanFilter::KALMAN_MODEL::PPP_KINEMATIC);// set Kinematic model
m_SRIFAlgorithm.setModel(SRIFAlgorithm::SRIF_MODEL::PPP_KINEMATIC);
m_minSatFlag = 5;// Dynamic Settings 4 or 1???, Static Settings 1
}
else
{
m_KalmanClass.setModel(QKalmanFilter::KALMAN_MODEL::PPP_STATIC);// set static model
m_SRIFAlgorithm.setModel(SRIFAlgorithm::SRIF_MODEL::PPP_STATIC);
m_minSatFlag = 1;// Dynamic Settings 1, Static Settings 1
}
if("Smooth" == Smooth_Str)
{
m_KalmanClass.setSmoothRange(QKalmanFilter::KALMAN_SMOOTH_RANGE::SMOOTH);
m_SRIFAlgorithm.setSmoothRange(SRIFAlgorithm::SRIF_SMOOTH_RANGE::SMOOTH);
m_isSmoothRange = true;
}
else if("NoSmooth" == Smooth_Str)
{
m_KalmanClass.setSmoothRange(QKalmanFilter::KALMAN_SMOOTH_RANGE::NO_SMOOTH);
m_SRIFAlgorithm.setSmoothRange(SRIFAlgorithm::SRIF_SMOOTH_RANGE::NO_SMOOTH);
m_isSmoothRange = false;
}
m_isKinematic = isKinematic;
}
//Initialization operation
void QPPPModel::initVar()
{
for (int i = 0;i < 3;i++)
m_ApproxRecPos[0] = 0;
m_OFileName = "";
multReadOFile = 1000;
m_leapSeconds = 0;
m_isConnect = false;
m_run_floder = "";
m_haveObsFile = false;
m_isRuned = false;
m_save_images_path = "";
m_iswritre_file = false;
m_minSatFlag = 4;// Dynamic Settings 4 or 1, Static Settings 1 in setConfigure()
m_isSmoothRange = false;
m_clock_jump_type = 0;
}
//Constructor
void QPPPModel::initQPPPModel(QString OFileName,QStringList Sp3FileNames,QStringList ClkFileNames,QString ErpFileName,QString BlqFileName,QString AtxFileName,QString GrdFileName)
{
if(!m_haveObsFile) return ;// if not have observation file.
//Set up multi-system data
//Initial various classes
m_ReadSP3Class.setSP3FileNames(Sp3FileNames);
m_ReadClkClass.setClkFileNames(ClkFileNames);
m_ReadOFileClass.setObsFileName(OFileName);
m_ReadTropClass.setTropFileNames(GrdFileName,"GMF", m_TropDelay);// Default tropospheric model projection function GMF
m_ReadAntClass.setAntFileName(AtxFileName);
m_TideEffectClass.setTideFileName(BlqFileName,ErpFileName);// for OCEAN and Erp tide
m_ReadAntClass.m_CmpClass.readRepFile(ErpFileName);// for compute sun and moon position
qCmpGpsT.readRepFile(ErpFileName);// safe operation
//Save file name
m_OFileName = OFileName;
m_Sp3FileNames = Sp3FileNames;
m_ClkFileNames = ClkFileNames;
m_ErpFileName = ErpFileName;
//Various class settings
int obsTime[5] = {0};
double Seconds = 0,ObsJD = 0;
m_ReadOFileClass.getApproXYZ(m_ApproxRecPos);//Obtain the approximate coordinates of the O file
m_ReadOFileClass.getFistObsTime(obsTime,Seconds);//Get the initial observation time
ObsJD = qCmpGpsT.computeJD(obsTime[0],obsTime[1],obsTime[2],obsTime[3],obsTime[4],Seconds);
m_ReadAntClass.setObsJD(m_ReadOFileClass.getAntType(),ObsJD);//Set the antenna effective time
m_TideEffectClass.setStationName(m_ReadOFileClass.getMakerName());//Setting the tide requires a station name
//Search products and download
int GPS_Week = 0, GPS_Day = 0;
qCmpGpsT.YMD2GPSTime(obsTime[0],obsTime[1],obsTime[2],obsTime[3],obsTime[4],Seconds, &GPS_Week, &GPS_Day);
//If there is no product, it is necessary to make up such products.
if(Sp3FileNames.isEmpty() || ClkFileNames.isEmpty() || ErpFileName.isEmpty())
{
connectHost();
}
if(Sp3FileNames.isEmpty())
{
m_Sp3FileNames = downProducts(m_run_floder, GPS_Week, GPS_Day, "sp3");
m_ReadSP3Class.setSP3FileNames(m_Sp3FileNames);
}
if(ClkFileNames.isEmpty())
{
m_ClkFileNames = downProducts(m_run_floder, GPS_Week, GPS_Day, "clk");
m_ReadClkClass.setClkFileNames(m_ClkFileNames);
}
if(ErpFileName.isEmpty())
{
m_ErpFileName = downErpFile(m_run_floder, GPS_Week, GPS_Day, "erp");
m_TideEffectClass.setTideFileName(BlqFileName,m_ErpFileName);
m_ReadAntClass.m_CmpClass.readRepFile(ErpFileName);// for compute sun and moon position
qCmpGpsT.readRepFile(m_ErpFileName);
}
//Get skip seconds
m_leapSeconds = qCmpGpsT.getLeapSecond(obsTime[0],obsTime[1],obsTime[2],obsTime[3],obsTime[4],Seconds);
//Read the required calculation file module (time consuming)
if(m_haveObsFile)
{
m_ReadAntClass.getAllData();//Read all data from satellites and receivers
m_TideEffectClass.getAllData();//Read tide data
m_ReadTropClass.getAllData();//Read grd files for later tropospheric calculations
m_ReadSP3Class.getAllData();//Read the entire SP3 file
m_ReadClkClass.getAllData();//Read the clock error file for later calculation
}
}
// get matrix B and observer L
void QPPPModel::Obtaining_equation(QVector< SatlitData > &currEpoch, double *ApproxRecPos, MatrixXd &mat_B, VectorXd &Vct_L, MatrixXd &mat_P, bool isSmoothRange)
{
int epochLenLB = currEpoch.length();
MatrixXd B, P;
VectorXd L, sys_len;
sys_len.resize(m_sys_str.length());
B.resize(epochLenLB,3 + m_sys_num);
P.resize(epochLenLB,epochLenLB);
L.resize(epochLenLB);
sys_len.setZero();
B.setZero();
L.setZero();
P.setIdentity();
bool is_find_base_sat = false;
for (int i = 0; i < epochLenLB;i++)
{
SatlitData oneSatlit = currEpoch.at(i);
double li = 0,mi = 0,ni = 0,p0 = 0,dltaX = 0,dltaY = 0,dltaZ = 0;
dltaX = oneSatlit.X - ApproxRecPos[0];
dltaY = oneSatlit.Y - ApproxRecPos[1];
dltaZ = oneSatlit.Z - ApproxRecPos[2];
p0 = qSqrt(dltaX*dltaX+dltaY*dltaY+dltaZ*dltaZ);
li = dltaX/p0;mi = dltaY/p0;ni = dltaZ/p0;
//Computational B matrix
//P3 pseudorange code matrix
B(i, 0) = li;B(i, 1) = mi;B(i, 2) = ni; B(i, 3) = -1;// base system satlite clk must exist
// debug by xiaogongwei 2019.04.03 for ISB
for(int k = 1; k < m_sys_str.length();k++)
{
if(m_sys_str[k] == oneSatlit.SatType)
{
B(i,3+k) = -1;
sys_len[k] = 1;//good no zeros cloumn in B,sys_lenmybe 0 1 1 0
}
}
// debug by xiaogongwei 2019.04.10 is exist base system satlite clk
if(m_sys_str[0] == oneSatlit.SatType)
is_find_base_sat = true;
//Calculating the L matrix
double dlta = 0;//Correction of each
dlta = - oneSatlit.StaClock + oneSatlit.SatTrop - oneSatlit.Relativty -
oneSatlit.Sagnac - oneSatlit.TideEffect - oneSatlit.AntHeight;
//Pseudorange code PP3
if(isSmoothRange)
{// add by xiaogongwei 2018.11.20
L(i) = p0 - oneSatlit.PP3_Smooth + dlta;
// Computing weight matrix P
// if(oneSatlit.UTCTime.epochNum > 30 && oneSatlit.PP3_Smooth_NUM < 30 )//
// P(i, i) = 0.0001;
// else
P(i, i) = 1 / oneSatlit.PP3_Smooth_Q;//Smooth pseudorange????
}
else
{
L(i) = p0 - oneSatlit.PP3 + dlta;
// Computing weight matrix P
P(i, i) = oneSatlit.SatWight;//Pseudo-range right
}
}//B, L is calculated
// save data to mat_B
mat_B = B;
Vct_L = L;
mat_P = P;
// debug by xiaogongwei 2019.04.04
int no_zero = sys_len.size() - 1 - sys_len.sum();
if(no_zero > 0 || !is_find_base_sat)
{
int new_hang = B.rows() + no_zero, new_lie = B.cols(), flag = 0;
if(!is_find_base_sat) new_hang++; // debug by xiaogongwei 2019.04.10 is exist base system satlite clk
mat_B.resize(new_hang,new_lie);
mat_P.resize(new_hang,new_hang);
Vct_L.resize(new_hang);
mat_B.setZero();
Vct_L.setZero();
mat_P.setIdentity();
// debug by xiaogongwei 2019.04.10 is exist base system satlite clk
if(!is_find_base_sat)
{
for(int i = 0;i < B.rows();i++)
B(i, 3) = 0;
mat_B(mat_B.rows() - 1, 3) = 1;// 3 is conntain [dx,dy,dz]
}
mat_B.block(0,0,B.rows(),B.cols()) = B;
mat_P.block(0,0,P.rows(),P.cols()) = P;
Vct_L.head(L.rows()) = L;
for(int i = 1; i < sys_len.size();i++)
{
if(0 == sys_len[i])
{
mat_B(epochLenLB+flag, 3+i) = 1;// 3 is conntain [dx,dy,dz]
flag++;
}
}
}//if(no_zero > 0)
}
void QPPPModel::SimpleSPP(QVector < SatlitData > &prevEpochSatlitData, QVector < SatlitData > &epochSatlitData, double *spp_pos)
{
double p_HEN[3] = {0};
m_ReadOFileClass.getAntHEN(p_HEN);//Get the antenna high
GPSPosTime epochTime;//Obtaining observation time
if(epochSatlitData.length() > 0)
epochTime = epochSatlitData.at(0).UTCTime;//Obtaining observation time
else
return ;
Vector3d tempPos3d, diff_3d;
tempPos3d[0] = spp_pos[0]; tempPos3d[1] = spp_pos[1]; tempPos3d[2] = spp_pos[2];
QVector< SatlitData > store_currEpoch;
int max_iter = 20;
for(int iterj = 0; iterj < max_iter; iterj++)
{
QVector< SatlitData > currEpoch;
// get every satilite data
for (int i = 0;i < epochSatlitData.length();i++)
{
SatlitData tempSatlitData = epochSatlitData.at(i);//Store calculated corrected satellite data
//Test whether the carrier and pseudorange are abnormal and terminate in time.
if(!(tempSatlitData.L1&&tempSatlitData.L2&&tempSatlitData.C1&&tempSatlitData.C2))
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("Lack of observations"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//When seeking GPS
double m_PrnGpst = qCmpGpsT.YMD2GPSTime(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds);
// Read satellite clock error from CLK file
double stalitClock = 0;//Unit m
// Note: Time is the signal transmission time(m_PrnGpst - tempSatlitData.C2/M_C)
getCLKData(tempSatlitData.PRN,tempSatlitData.SatType,m_PrnGpst - tempSatlitData.C2/M_C,&stalitClock);
tempSatlitData.StaClock = stalitClock;
//Obtain the coordinates of the epoch satellite from the SP3 data data
double pXYZ[3] = {0},pdXYZ[3] = {0}, sp3Clk = 0.0;//Unit m
// Note: Time is the signal transmission time(m_PrnGpst - tempSatlitData.C2/M_C - tempSatlitData.StaClock/M_C)
getSP3Pos(m_PrnGpst - tempSatlitData.C2/M_C - tempSatlitData.StaClock/M_C,tempSatlitData.PRN,
tempSatlitData.SatType,pXYZ,pdXYZ, &sp3Clk);//Obtain the precise ephemeris coordinates of the satellite launch time(Obtain the precise ephemeris coordinates of the satellite launch time tempSatlitData.StaClock/M_C Otherwise it will cause a convergence gap of 20cm)
tempSatlitData.X = pXYZ[0];tempSatlitData.Y = pXYZ[1];tempSatlitData.Z = pXYZ[2];
// tempSatlitData.StaClock = sp3Clk;// Use igu to do real-time PPP need to use sp3 clock difference replacement, the directory must have the same day clk file, but the clk file data is not used
//Calculate the satellite's high sitting angle (as the receiver approximates the target)
double EA[2]={0};
getSatEA(tempSatlitData.X,tempSatlitData.Y,tempSatlitData.Z,spp_pos,EA);
tempSatlitData.EA[0] = EA[0];tempSatlitData.EA[1] = EA[1];
EA[0] = EA[0]*MM_PI/180;EA[1] = EA[1]*MM_PI/180;//Go to the arc to facilitate the calculation below
tempSatlitData.SatWight = 0.01;// debug xiaogongwei 2018.11.16
getWight(tempSatlitData);
//Test the state of the precise ephemeris and the clock difference and whether the carrier and pseudorange are abnormal, and terminate the XYZ or the satellite with the clock difference of 0 in time.
if (!(tempSatlitData.X&&tempSatlitData.Y&&tempSatlitData.Z&&tempSatlitData.StaClock))
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("Can't calculate the orbit and clock offset"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//Quality control (height angle pseudorange difference)
if (qAbs(tempSatlitData.C1 - tempSatlitData.C2) > 50)
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("C1-C2>50"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
if(spp_pos[0] !=0 && tempSatlitData.EA[0] < m_CutAngle)
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("elevation angle is " + QString::number(tempSatlitData.EA[0],'f',2)
+ " less " + QString::number(m_CutAngle,'f',2) +errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//At the time of SPP, the five satellites with poor GEO orbit in front of Beidou are not removed.
// if(tempSatlitData.SatType == 'C' && tempSatlitData.PRN <=5 )
// continue;
//Calculate the wavelength (mainly for multiple systems)
double F1 = tempSatlitData.Frq[0],F2 = tempSatlitData.Frq[1];
if(F1 == 0 || F2 == 0) continue;//Frequency cannot be 0
//Computational relativity correction
double relative = 0;
if(spp_pos[0] !=0 ) relative = getRelativty(tempSatlitData.SatType,pXYZ,spp_pos,pdXYZ);
tempSatlitData.Relativty = relative;
//Calculate the autobiographic correction of the earth
double earthW = 0;
earthW = getSagnac(tempSatlitData.X,tempSatlitData.Y,tempSatlitData.Z,spp_pos);
tempSatlitData.Sagnac = 0;
if(spp_pos[0] !=0 ) tempSatlitData.Sagnac = earthW;
//Calculate tropospheric dry delay!!!
double MJD = qCmpGpsT.computeJD(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds) - 2400000.5;//Simplified Julian Day
//Calculate and save the annual accumulation date
double TDay = qCmpGpsT.YearAccDay(epochTime.Year,epochTime.Month,epochTime.Day);
double p_BLH[3] = {0},mf = 0, TropZPD = 0;;
qCmpGpsT.XYZ2BLH(spp_pos[0], spp_pos[1], spp_pos[2], p_BLH);
if(spp_pos[0] !=0 ) getTropDelay(MJD,TDay,EA[0],p_BLH,&mf, NULL, &TropZPD);
tempSatlitData.SatTrop = TropZPD;
tempSatlitData.StaTropMap = mf;
if(spp_pos[0] !=0 ) tempSatlitData.StaTropMap = mf;
//Calculate antenna high offset correction Antenna Height
tempSatlitData.AntHeight = 0;
if( spp_pos[0] !=0 )
tempSatlitData.AntHeight = p_HEN[0]*qSin(EA[0]) + p_HEN[1]*qCos(EA[0])*qSin(EA[1]) + p_HEN[2]*qCos(EA[0])*qCos(EA[1]);
//Receiver L1 L2 offset correction
double Lamta1 = M_C/F1,Lamta2 = M_C/F2;
double L1Offset = 0,L2Offset = 0;
if( spp_pos[0] !=0 ) getRecvOffset(EA,tempSatlitData.SatType,L1Offset,L2Offset, tempSatlitData.wantObserType);
tempSatlitData.L1Offset = L1Offset/Lamta1;
tempSatlitData.L2Offset = L2Offset/Lamta2;
//Satellite antenna phase center correction
double SatL12Offset[2] = {0};
if( spp_pos[0] !=0 )
getSatlitOffset(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds - tempSatlitData.C2/M_C,
tempSatlitData.PRN,tempSatlitData.SatType,pXYZ,spp_pos, SatL12Offset, tempSatlitData.wantObserType);//pXYZ saves satellite coordinates
tempSatlitData.SatL1Offset = SatL12Offset[0]/Lamta1;
tempSatlitData.SatL2Offset = SatL12Offset[1]/Lamta2;
//Calculate tide correction
tempSatlitData.TideEffect = 0;
//Calculate antenna phase winding
double AntWindup = 0,preAntWindup = 0;
//Find the previous epoch. Is there a satellite present? The deposit is stored in preAntWindup or preAntWindup=0.
if( spp_pos[0] !=0 )
{
preAntWindup = getPreEpochWindUp(prevEpochSatlitData,tempSatlitData.PRN,tempSatlitData.SatType);//Get the previous epoch of WindUp
AntWindup = getWindup(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds - tempSatlitData.C2/M_C,
pXYZ,spp_pos,preAntWindup,m_ReadAntClass.m_sunpos);
}
tempSatlitData.AntWindup = AntWindup;
//Computation to eliminate ionospheric pseudorange and carrier combinations (here absorbed receiver carrier deflection and WindUp) add SatL1Offset and SatL1Offset by xiaogongwei 2019.04.12
double alpha1 = (F1*F1)/(F1*F1 - F2*F2),alpha2 = (F2*F2)/(F1*F1 - F2*F2);
tempSatlitData.LL3 = alpha1*(tempSatlitData.L1 + tempSatlitData.L1Offset + tempSatlitData.SatL1Offset - tempSatlitData.AntWindup)*Lamta1
- alpha2*(tempSatlitData.L2 + tempSatlitData.L2Offset + tempSatlitData.SatL2Offset - tempSatlitData.AntWindup)*Lamta2;//Eliminate ionospheric carrier LL3
tempSatlitData.PP3 = alpha1*(tempSatlitData.C1 + Lamta1*tempSatlitData.L1Offset + Lamta1*tempSatlitData.SatL1Offset)
- alpha2*(tempSatlitData.C2 + Lamta2 *tempSatlitData.L2Offset + Lamta2*tempSatlitData.SatL2Offset);//Eliminate ionospheric carrier PP3
// save data to currEpoch
currEpoch.append(tempSatlitData);
}
// judge satilite number large 4
if(currEpoch.length() < 5)
{
memset(spp_pos, 0, 3*sizeof(double));// debug by xiaogongwei 2019.09.25
epochSatlitData = currEpoch;// debug by xiaogongwei 2019.04.10
return ;
}
// get equation
MatrixXd mat_B, mat_P;
VectorXd Vct_L, Xk;
Vector3d XYZ_Pos;
Obtaining_equation( currEpoch, spp_pos, mat_B, Vct_L, mat_P);// debug xiaogongwei 2018.11.16
// slover by least square
Xk = (mat_B.transpose()*mat_P*mat_B).inverse()*mat_B.transpose()*mat_P*Vct_L;
XYZ_Pos[0] = tempPos3d[0] + Xk[0];
XYZ_Pos[1] = tempPos3d[1] + Xk[1];
XYZ_Pos[2] = tempPos3d[2] + Xk[2];
diff_3d = XYZ_Pos - tempPos3d;
tempPos3d = XYZ_Pos;// save slover pos
// update spp_pos
spp_pos[0] = XYZ_Pos[0]; spp_pos[1] = XYZ_Pos[1]; spp_pos[2] = XYZ_Pos[2];
// debug by xiaogongwei 2018.11.17
if(diff_3d.cwiseAbs().maxCoeff() < 1)
{
store_currEpoch = currEpoch;
break;
}
if(diff_3d.cwiseAbs().maxCoeff() > 2e7 || !isnormal(diff_3d[0]) || iterj == max_iter - 1)
{
memset(spp_pos, 0, 3*sizeof(double));
epochSatlitData = currEpoch;// debug by xiaogongwei 2019.09.25
return ;
}
}// for(int iterj = 0; iterj < 20; iterj++)
// add Pesudorange smoothed by xiaogongwei 2018.11.20
MatrixXd mat_B, mat_P;
VectorXd Vct_L, Xk_smooth;
//Monitor satellite quality and cycle slip
// getGoodSatlite(prevEpochSatlitData,store_currEpoch, m_CutAngle);
if(store_currEpoch.length() < m_minSatFlag)
{
memset(spp_pos, 0, 3*sizeof(double));// debug by xiaogongwei 2019.09.25
epochSatlitData = store_currEpoch;// debug by xiaogongwei 2019.04.10
return ;
}
if(m_isSmoothRange)
{
m_QPseudoSmooth.SmoothPesudoRange(prevEpochSatlitData, store_currEpoch);
Obtaining_equation( store_currEpoch, spp_pos, mat_B, Vct_L, mat_P, true);// debug xiaogongwei 2018.11.16
// slover by least square
Xk_smooth = (mat_B.transpose()*mat_P*mat_B).inverse()*mat_B.transpose()*mat_P*Vct_L;
// update spp_pos
spp_pos[0] += Xk_smooth[0]; spp_pos[1] += Xk_smooth[1]; spp_pos[2] += Xk_smooth[2];
// use spp_pos update mat_B Vct_L
Obtaining_equation( store_currEpoch, spp_pos, mat_B, Vct_L, mat_P, true);// debug xiaogongwei 2019.03.28
}
else
{// Safe operation
for(int i = 0; i < store_currEpoch.length(); i++)
{
store_currEpoch[i].PP3_Smooth = store_currEpoch[i].PP3;
store_currEpoch[i].PP3_Smooth_NUM = 1;
store_currEpoch[i].PP3_Smooth_Q = 1 / store_currEpoch[i].SatWight;
}
Obtaining_equation( store_currEpoch, spp_pos, mat_B, Vct_L, mat_P, false);
}
// Qulity control. add by xiaogongwei 2019.05.06
VectorXd delate_flag;
// int max_iter1 = 10;
// Assuming that SPP has only one gross error, use if is not while, filtering uses while loop to eliminate Debug by xiaogongwei 2019.05.06
while(m_qualityCtrl.VtPVCtrl_C(mat_B, Vct_L, mat_P, delate_flag, store_currEpoch.length()))
{
QVector<int> del_val;
int sat_len = store_currEpoch.length();
for(int i = sat_len - 1; i >= 0;i--)
{
if(0 != delate_flag[i])
del_val.append(i);
}
// max_iter1--;
// if(max_iter1 <= 0) break;
// delete gross Errors
int del_len = del_val.length();
if(sat_len - del_len >= 5)
{
for(int i = 0; i < del_len;i++)
store_currEpoch.remove(del_val[i]);
sat_len = store_currEpoch.length();// update epochLenLB
//update spp_pos
Obtaining_equation( store_currEpoch, spp_pos, mat_B, Vct_L, mat_P, m_isSmoothRange);
MatrixXd mat_Q = (mat_B.transpose()*mat_P*mat_B).inverse();
VectorXd x_solver = mat_Q*mat_B.transpose()*mat_P*Vct_L;
spp_pos[0] += x_solver[0]; spp_pos[1] += x_solver[1]; spp_pos[2] += x_solver[2];
}
else
{
memset(spp_pos, 0, 3*sizeof(double));// debug by xiaogongwei 2019.09.25
break;
}
}
// change epochSatlitData !!!!!!
epochSatlitData = store_currEpoch;
}
//Read O files, sp3 files, clk files, and various error calculations, Kalman filtering ......................
//isDisplayEveryEpoch represent is disply every epoch information?(ENU or XYZ)
void QPPPModel::Run(bool isDisplayEveryEpoch)
{
if(!m_haveObsFile) return ;// if not have observation file.
QTime myTime; // set timer
myTime.start();// start timer
//Externally initialize fixed variables to speed up calculations
double p_HEN[3] = {0};//Get the antenna high
m_ReadOFileClass.getAntHEN(p_HEN);
//Traversing data one by one epoch, reading O file data
QString disPlayQTextEdit = "";// display for QTextEdit
QVector < SatlitData > prevEpochSatlitData;//Store satellite data of an epoch, use cycle slip detection(Put it on top, otherwise read multReadOFile epochs, the life cycle will expire when reading)
double spp_pos[3] = {0};// store SPP pos and
memcpy(spp_pos, m_ApproxRecPos, 3*sizeof(double));
double store_epoch_ZHD = 0;// dbug by xiaogongwei 2018.12.24 store ZHD of epoch
int epoch_num = 0, continue_bad_epoch = 0;//Record the first epoch
bool isInitSpp = false;
if(spp_pos[0] !=0 ) isInitSpp = true;
while (!m_ReadOFileClass.isEnd())
{
QVector< QVector < SatlitData > > multepochSatlitData;//Store multiple epochs
m_ReadOFileClass.getMultEpochData(multepochSatlitData,multReadOFile);//Read multReadOFile epochs
//Multiple epoch cycles
for (int epoch = 0; epoch < multepochSatlitData.length();epoch++)
{
QVector< SatlitData > epochSatlitData;//Temporary storage of uncalculated data for each epoch satellite
QVector< SatlitData > epochResultSatlitData;// Store each epoch satellite to calculate the correction data
store_epoch_ZHD = 0; // clear store_epoch_ZHD for epoch
epochSatlitData = multepochSatlitData.at(epoch);
if(epochSatlitData.length() == 0) continue;
GPSPosTime epochTime;
if(epochSatlitData.length() > 0)
epochTime= epochSatlitData.at(0).UTCTime;//Obtain the observation time (the epoch stores the observation time for each satellite)
//Set the epoch of the satellite
for(int i = 0;i < epochSatlitData.length();i++)
epochSatlitData[i].UTCTime.epochNum = epoch_num;
if(epoch_num == 74)
{// Debug for epoch
//2018-12- 8 13: 4: 0.0000000
int a = 0;
}
// use spp compute postion and smooth pesudorange
if(!isInitSpp || m_isKinematic)
SimpleSPP(prevEpochSatlitData, epochSatlitData, spp_pos);
else
memcpy(spp_pos, m_ApproxRecPos, 3*sizeof(double));
if(!isnormal(spp_pos[0]))
memset(spp_pos, 0, 3*sizeof(double));
// The number of skipping satellites is less than m_minSatFlag
// update at 2018.10.17 for less m_minSatFlag satellites at the begin observtion
if(epochSatlitData.length() < m_minSatFlag || spp_pos[0] == 0)
{
if(m_isKinematic&&continue_bad_epoch++ > 8)
{
prevEpochSatlitData.clear();// Exception reinitialization
continue_bad_epoch = 0;
}
// set residual as zeros
for(int i = 0;i < epochSatlitData.length();i++)
{
epochSatlitData[i].VLL3 = 0; epochSatlitData[i].VPP3 = 0;
}
disPlayQTextEdit = "GPST: " + QString::number(epochTime.Hours) + ":" + QString::number(epochTime.Minutes)
+ ":" + QString::number(epochTime.Seconds) ;
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
disPlayQTextEdit = "Satellite number: " + QString::number(epochSatlitData.length())
+ " jump satellites number is less than 5.";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
// translation to ENU
VectorXd ENU_Vct;
double spp_vct[3] = {0};
int param_len = 3*epochSatlitData.length() + 32;
ENU_Vct.resize(param_len);
ENU_Vct.fill(0);
// debug by xiaogongwei 2019.02.21
MatrixXd P;
P.resize(param_len, param_len);
P.setZero();
saveResult2Class(ENU_Vct, spp_vct, epochTime, epochSatlitData, epoch_num, &P);
epoch_num++;
continue;
}
//An epoch cycle begins
for (int i = 0;i < epochSatlitData.length();i++)
{
SatlitData tempSatlitData = epochSatlitData.at(i);//Store calculated corrected satellite data
//Test whether the carrier and pseudorange are abnormal and terminate in time.
if(!(tempSatlitData.L1&&tempSatlitData.L2&&tempSatlitData.C1&&tempSatlitData.C2))
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("Lack of observations"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//When seeking GPS
double m_PrnGpst = qCmpGpsT.YMD2GPSTime(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds);
// Read satellite clock error from CLK file
double stalitClock = 0.0;
// Note: Time is the signal transmission time(m_PrnGpst - tempSatlitData.C2/M_C)
getCLKData(tempSatlitData.PRN,tempSatlitData.SatType,m_PrnGpst - tempSatlitData.C2/M_C,&stalitClock);
tempSatlitData.StaClock = stalitClock;
//Obtain the coordinates of the epoch satellite from the SP3 data data
double pXYZ[3] = {0},pdXYZ[3] = {0}, sp3Clk = 0.0;//Unit m
// Note: Time is the signal transmission time(m_PrnGpst - tempSatlitData.C2/M_C - tempSatlitData.StaClock/M_C)
getSP3Pos(m_PrnGpst - tempSatlitData.C2/M_C - tempSatlitData.StaClock/M_C,tempSatlitData.PRN,
tempSatlitData.SatType,pXYZ,pdXYZ, &sp3Clk);//Obtain the precise ephemeris coordinates of the satellite launch time(Here we need to subtract the satellite clock error. tempSatlitData.StaClock/M_C Otherwise it will cause a convergence gap of 20cm)
tempSatlitData.X = pXYZ[0];tempSatlitData.Y = pXYZ[1];tempSatlitData.Z = pXYZ[2];
// tempSatlitData.StaClock = sp3Clk;// Use igu to do real-time PPP need to use sp3 clock difference replacement, the directory must have the same day clk file, but the clk file data is not used
//Test the state of the precise ephemeris and the clock difference and whether the carrier and pseudorange are abnormal, and terminate the XYZ or the satellite with the clock difference of 0 in time.
if (!(tempSatlitData.X&&tempSatlitData.Y&&tempSatlitData.Z&&tempSatlitData.StaClock))
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("Can't calculate the orbit and clock offset"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//PPP removes 5 satellites with poor GEO orbit in front of Beidou
if(tempSatlitData.SatType == 'C' && tempSatlitData.PRN <= 5)
{
QString errorline;
ErrorMsg(errorline);
tempSatlitData.badMsg.append("remove GEO of Beidou"+errorline);
m_writeFileClass.allBadSatlitData.append(tempSatlitData);
continue;
}
//Calculate the wavelength (mainly for multiple systems)
double F1 = tempSatlitData.Frq[0],F2 = tempSatlitData.Frq[1];
if(F1 == 0 || F2 == 0) continue;//Frequency cannot be 0
//Computational relativity correction
double relative = 0;
relative = getRelativty(tempSatlitData.SatType,pXYZ,spp_pos,pdXYZ);
tempSatlitData.Relativty = relative;
//Calculate the satellite's high sitting angle (as the receiver approximates the target)
double EA[2]={0};
getSatEA(tempSatlitData.X,tempSatlitData.Y,tempSatlitData.Z,spp_pos,EA);
tempSatlitData.EA[0] = EA[0];tempSatlitData.EA[1] = EA[1];
EA[0] = EA[0]*MM_PI/180;EA[1] = EA[1]*MM_PI/180;//Go to the arc to facilitate the calculation below
getWight(tempSatlitData);
//Calculate the autobiographic correction of the earth
double earthW = 0;
earthW = getSagnac(tempSatlitData.X,tempSatlitData.Y,tempSatlitData.Z,spp_pos);
tempSatlitData.Sagnac = earthW;
//Calculate tropospheric dry delay
double MJD = qCmpGpsT.computeJD(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds) - 2400000.5;//Simplified Julian Day
//Calculate and save the annual accumulation date
double TDay = qCmpGpsT.YearAccDay(epochTime.Year,epochTime.Month,epochTime.Day);
double p_BLH[3] = {0},mf = 0, TropZHD_s = 0;
qCmpGpsT.XYZ2BLH(spp_pos[0], spp_pos[1], spp_pos[2], p_BLH);
if(0 == store_epoch_ZHD)
getTropDelay(MJD,TDay,EA[0],p_BLH,&mf, &TropZHD_s, NULL, &store_epoch_ZHD);
else
getTropDelay(MJD,TDay,EA[0],p_BLH,&mf, &TropZHD_s, NULL);
tempSatlitData.SatTrop = TropZHD_s;
tempSatlitData.StaTropMap = mf;
tempSatlitData.UTCTime.TropZHD = store_epoch_ZHD;
//Calculate antenna high offset correction Antenna Height
tempSatlitData.AntHeight = p_HEN[0]*qSin(EA[0]) + p_HEN[1]*qCos(EA[0])*qSin(EA[1]) + p_HEN[2]*qCos(EA[0])*qCos(EA[1]);
//Receiver L1 L2 offset correction
double Lamta1 = M_C/F1,Lamta2 = M_C/F2;
double L1Offset = 0,L2Offset = 0;
getRecvOffset(EA,tempSatlitData.SatType,L1Offset,L2Offset, tempSatlitData.wantObserType);
tempSatlitData.L1Offset = L1Offset/Lamta1;
tempSatlitData.L2Offset = L2Offset/Lamta2;
//Satellite antenna phase center correction store data to (m_ReadAntClass.m_sunpos,m_ReadAntClass.m_moonpos,m_ReadAntClass.m_gmst)
// and update sunpos and moonpos
double SatL12Offset[2] = {0};
getSatlitOffset(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds - tempSatlitData.C2/M_C,
tempSatlitData.PRN,tempSatlitData.SatType,pXYZ,spp_pos, SatL12Offset, tempSatlitData.wantObserType);//pXYZ saves satellite coordinates
tempSatlitData.SatL1Offset = SatL12Offset[0] / Lamta1;
tempSatlitData.SatL2Offset = SatL12Offset[1] / Lamta2;
//Calculate tide correction
double effctDistance = 0;
effctDistance = getTideEffect(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds,spp_pos,EA,
m_ReadAntClass.m_sunpos,m_ReadAntClass.m_moonpos,m_ReadAntClass.m_gmst);
tempSatlitData.TideEffect = effctDistance;
//Calculate antenna phase winding
double AntWindup = 0,preAntWindup = 0;
//Find the previous epoch. Is there a satellite present? The deposit is stored in preAntWindup or preAntWindup=0.
preAntWindup = getPreEpochWindUp(prevEpochSatlitData,tempSatlitData.PRN,tempSatlitData.SatType);//Get the previous epoch of WindUp
AntWindup = getWindup(epochTime.Year,epochTime.Month,epochTime.Day,
epochTime.Hours,epochTime.Minutes,epochTime.Seconds - tempSatlitData.C2/M_C,
pXYZ,spp_pos,preAntWindup,m_ReadAntClass.m_sunpos);
tempSatlitData.AntWindup = AntWindup;
//Computation to eliminate ionospheric pseudorange and carrier combinations (here absorbed receiver carrier deflection and WindUp) add SatL1Offset and SatL1Offset by xiaogongwei 2019.04.12
double alpha1 = (F1*F1)/(F1*F1 - F2*F2),alpha2 = (F2*F2)/(F1*F1 - F2*F2);
tempSatlitData.LL3 = alpha1*(tempSatlitData.L1 + tempSatlitData.L1Offset + tempSatlitData.SatL1Offset - tempSatlitData.AntWindup)*Lamta1
- alpha2*(tempSatlitData.L2 + tempSatlitData.L2Offset + tempSatlitData.SatL2Offset - tempSatlitData.AntWindup)*Lamta2;//Eliminate ionospheric carrier LL3
tempSatlitData.PP3 = alpha1*(tempSatlitData.C1 + Lamta1*tempSatlitData.L1Offset + Lamta1*tempSatlitData.SatL1Offset)
- alpha2*(tempSatlitData.C2 + Lamta2 *tempSatlitData.L2Offset + Lamta2*tempSatlitData.SatL2Offset);//Eliminate ionospheric carrier PP3
//Save an epoch satellite data
epochResultSatlitData.append(tempSatlitData);
}//End of an epoch. for (int i = 0;i < epochSatlitData.length();i++)
//Monitor satellite quality and cycle slip
getGoodSatlite(prevEpochSatlitData,epochResultSatlitData, m_CutAngle);
//Satellite number not sufficient
if(epochResultSatlitData.length() < m_minSatFlag)
{
if(m_isKinematic&&continue_bad_epoch++ > 8)
{
prevEpochSatlitData.clear();// Exception reinitialization
continue_bad_epoch = 0;
}
// set residual as zeros
for(int i = 0;i < epochSatlitData.length();i++)
{
epochSatlitData[i].VLL3 = 0; epochSatlitData[i].VPP3 = 0;
}
// display clock jump
disPlayQTextEdit = "Valid Satellite Number: " + QString::number(epochResultSatlitData.length()) + ENDLINE +
"Waring: ***************Satellite number not sufficient*****************";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
// translation to ENU
VectorXd ENU_Vct;
double spp_vct[3] = {0};
int param_len = 3*epochResultSatlitData.length() + 32;
ENU_Vct.resize(param_len);
ENU_Vct.fill(0);
MatrixXd P;
P.resize(param_len, param_len);
P.setZero();
saveResult2Class(ENU_Vct, spp_vct, epochTime, epochResultSatlitData, epoch_num, &P);
epoch_num++;
continue;
}
// Choose solve method Kalman or SRIF
MatrixXd P;
VectorXd X;//Respectively dX, dY, dZ, dT (zenith tropospheric residual), dVt (receiver clock error), N1, N2...Nm (fuzzy)[dx,dy,dz,dTrop,dClock,N1,N2,...Nn]
double spp_vct[3] = {0};// save spp pos
bool is_filter_good = false;
X.resize(5+epochResultSatlitData.length());
X.setZero();
// store spp position
spp_vct[0] = spp_pos[0]; spp_vct[1] = spp_pos[1]; spp_vct[2] = spp_pos[2];
if (!m_Solver_Method.compare("SRIF", Qt::CaseInsensitive))
is_filter_good = m_SRIFAlgorithm.SRIFforStatic(prevEpochSatlitData,epochResultSatlitData,spp_pos,X,P);
else
is_filter_good = m_KalmanClass.KalmanforStatic(prevEpochSatlitData,epochResultSatlitData,spp_pos,X,P);
//Save the last epoch satellite data
if(is_filter_good)
{
prevEpochSatlitData = epochResultSatlitData;
continue_bad_epoch = 0;
}
else
{
continue_bad_epoch++;
memset(spp_vct, 0, 3*sizeof(double));
memset(spp_pos, 0, 3*sizeof(double));
X.setZero();
}
//Output calculation result(print result)
// display every epoch results
if(isDisplayEveryEpoch)
{
int Valid_SatNumber = epochResultSatlitData.length();
// display epoch number
disPlayQTextEdit = "Epoch Number: " + QString::number(epoch_num);
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
//
disPlayQTextEdit = "GPST: " + QString::number(epochTime.Hours) + ":" + QString::number(epochTime.Minutes)
+ ":" + QString::number(epochTime.Seconds) + ENDLINE + "Satellite number: " + QString::number(epochSatlitData.length());
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
// display ENU or XYZ
disPlayQTextEdit = "Valid Satellite Number: " + QString::number(Valid_SatNumber) + ENDLINE
+ "Estimated coordinates: [ " + QString::number(spp_pos[0], 'f', 4) + "," + QString::number(spp_pos[1], 'f', 4) + ","
+ QString::number(spp_pos[2], 'f', 4) + " ]" + ENDLINE;
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
}
//Save each epoch X data to prepare for writing a file
// translation to ENU
VectorXd ENU_Vct;
ENU_Vct = X;// [dx,dy,dz,dTrop,dClock,N1,N2,...Nn]
//ENU_Vct[0] = P(1,1); ENU_Vct[1] = P(2,2); ENU_Vct[2] = P(3,3);
ENU_Vct[0] = spp_pos[0]; ENU_Vct[1] = spp_pos[1]; ENU_Vct[2] = spp_pos[2];
saveResult2Class(ENU_Vct, spp_vct, epochTime, epochResultSatlitData, epoch_num, &P);
epoch_num++;//Increase in epoch
}//End of multiple epochs. (int n = 0; n < multepochSatlitData.length();n++)
// clear multepochSatlitData
multepochSatlitData.clear();
}//Arrive at the end of the file. while (!m_ReadOFileClass.isEnd())
// time end
float m_diffTime = myTime.elapsed() / 1000.0;
if(isDisplayEveryEpoch)
{
disPlayQTextEdit = "The Elapse Time: " + QString::number(m_diffTime) + "s";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
}
//Write result to file
writeResult2File();
m_isRuned = true;// Determine whether the operation is complete.
}
// The edit box automatically scrolls, adding one row or more lines at a time.
void QPPPModel::autoScrollTextEdit(QTextEdit *textEdit,QString &add_text)
{
if(textEdit == NULL) return ;
int m_Display_Max_line = 99999;
//Add line character and refresh edit box.
QString insertText = add_text + ENDLINE;
textEdit->insertPlainText(insertText);
//Keep the editor in the last line of the cursor.
QTextCursor cursor=textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(cursor);
textEdit->repaint();
QApplication::processEvents();
//If you exceed a certain number of lines, empty it.
if(textEdit->document()->lineCount() > m_Display_Max_line)
{
textEdit->clear();
}
}
bool QPPPModel::connectHost()
{
if(m_isConnect) return true;
QString ftp_link = "cddis.gsfc.nasa.gov", user_name = "anonymous", user_password = "";//ftp information
int Port = 21;
ftpClient.FtpSetUserInfor(user_name, user_password);
ftpClient.FtpSetHostPort(ftp_link, Port);
m_isConnect = true;
return true;
}
//download Get erp file
// productType: "erp"
// GPS_Week: is GPS week.
QString QPPPModel::downErpFile(QString store_floder_path, int GPS_Week, int GPS_day, QString productType)
{
QString erp_path_name = "";
if(!m_isConnect)
return erp_path_name;
QString igs_short_path = "/pub/gps/products/", igs_productCompany = "igs";// set path of products
QString gbm_short_path = "/pub/gps/products/mgex/", gbm_productCompany = "gbm";// set path of products
QString igs_path_string = "", igs_erp_name = "";
//net file path
igs_path_string.append(igs_short_path);
igs_path_string.append(QString::number(GPS_Week));
igs_path_string.append("/");
// file name
igs_erp_name.append(igs_productCompany);
igs_erp_name.append(QString::number(GPS_Week));
igs_erp_name.append(QString::number(7));
igs_erp_name.append(".erp.Z");
// down load begin
bool is_down_igs = false;
QString disPlayQTextEdit = "download start!";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
QString igs_erp_path = igs_path_string + igs_erp_name,
igs_temp_local_file = store_floder_path + igs_erp_name;
if(!ftpClient.FtpGet(igs_erp_path, igs_temp_local_file))
{
disPlayQTextEdit = "download: " + igs_erp_path + " bad!";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
is_down_igs = false;
}
else
{
disPlayQTextEdit = "download: " + igs_erp_path + " success!";
autoScrollTextEdit(mp_QTextEditforDisplay, disPlayQTextEdit);// display for QTextEdit
is_down_igs = true;
}
// save products file to fileList
QString temp_local_file;
if(is_down_igs)
temp_local_file = igs_temp_local_file;
// umcompress ".Z"
QFileInfo fileinfo(temp_local_file);
if(0 != fileinfo.size())
{
MyCompress compress;
compress.UnCompress(temp_local_file, store_floder_path);
}
// return file path + name
int extend_name = temp_local_file.lastIndexOf(".");
erp_path_name = temp_local_file.mid(0, extend_name);
if(!is_down_igs) erp_path_name = "";
return erp_path_name;
}
//download Get sp3, clk file
// productType: "sp3", "clk"
// GPS_Week, GPS_Day: is GPS week and day.
// fileList: if fileList least 3. down new product and change fileList
QStringList QPPPModel::downProducts(QString store_floder_path, int GPS_Week, int GPS_day, QString productType)
{
QString igs_short_path = "/pub/gps/products/", igs_productCompany = "igs";// set path of products
QString gbm_short_path = "/pub/gps/products/mgex/", gbm_productCompany = "gbm";// set path of products
QStringList fileList;
fileList.clear();
if(!m_isConnect) return fileList;
//get fileList
QStringList net_fileList, igs_net_fileList;
net_fileList.clear();
igs_net_fileList.clear();
QString tempStr = "", fileName = "", disPlayQTextEdit = "";
QStringList three_fileNames, igs_three_fileNames;
//download "sp3", "clk"
for(int i = -1;i < 2; i++)
{