-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathSRIFAlgorithm.cpp
1640 lines (1532 loc) · 63.9 KB
/
SRIFAlgorithm.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
//============================================================================
// Name : SRIFAlgorithm.cpp
// Author : xiaogongwei
// Version :
// Copyright : Copyright attributed to David
// Description : Hello World in C++, Ansi-style
//============================================================================
#include "SRIFAlgorithm.h"
SRIFAlgorithm::SRIFAlgorithm() {
// TODO Auto-generated constructor stub
initVar();
}
SRIFAlgorithm::~SRIFAlgorithm() {
// TODO Auto-generated destructor stub
}
void SRIFAlgorithm::initVar()
{
this->m_initSRIF = false;
this->m_isInitPara = false;
this->m_isInitWhite = false;
m_SPP_Pos[0] = 0; m_SPP_Pos[1] = 0; m_SPP_Pos[2] = 0;
m_Xk.resize(32);// XiaoGongWei Update:2018.12.02
m_init_Xk.resize(32);// XiaoGongWei Update:2018.12.02
m_Xk.setZero();// XiaoGongWei Update:2018.12.02
m_init_Xk.setZero();// XiaoGongWei Update:2018.12.02
m_const_param = 4;// [dx,dy,dz,mf,clki]
m_sys_num = 1;
m_sys_str = "G";
m_LP_whight = 1e6;
m_xyz_dynamic_Qw = 1e6; m_zwd_Qw = 3e-8; m_clk_Qw = 1e6; m_amb_Qw = 1e-16; m_ion_Qw = 0.1;
m_xyz_dynamic_Pk = 1e6; m_zwd_Pk = 10; m_clk_Pk = 1e6; m_amb_Pk = 1e6; m_ion_Pk = 10;
}
void SRIFAlgorithm::setFilterParams(QVector<QStringList> Qw_Pk_LPacc)
{
if(Qw_Pk_LPacc.length() >= 2){
QStringList Qw_StrList = Qw_Pk_LPacc.at(0),Pk_StrList = Qw_Pk_LPacc.at(1);
if(Qw_StrList.length() < 5) return ; if(Pk_StrList.length() < 5) return ;
// set Qw
m_xyz_dynamic_Qw = Qw_StrList.at(0).toDouble(); m_zwd_Qw = Qw_StrList.at(1).toDouble();
m_clk_Qw = Qw_StrList.at(2).toDouble(); m_amb_Qw = Qw_StrList.at(3).toDouble();
m_ion_Qw = Qw_StrList.at(4).toDouble();
// set Pk
m_xyz_dynamic_Pk = Pk_StrList.at(0).toDouble(); m_zwd_Pk = Pk_StrList.at(1).toDouble();
m_clk_Pk= Pk_StrList.at(2).toDouble(); m_amb_Pk = Pk_StrList.at(3).toDouble();
m_ion_Pk = Pk_StrList.at(4).toDouble();
}
if(Qw_Pk_LPacc.length() >= 3){
QStringList LP_StrList = Qw_Pk_LPacc.at(2);
double LP_ratio = 1e3;
if(LP_StrList.length() == 2 && LP_StrList.at(0).toDouble() != 0 )
LP_ratio = LP_StrList.at(1).toDouble() / LP_StrList.at(0).toDouble();
m_LP_whight = LP_ratio * LP_ratio;// set m_LP_whight
}
// some time Qw as denominator,such as 1/Qw; so Qw must not zero
double myEps = 1e-16;
if(0 == m_xyz_dynamic_Qw) m_xyz_dynamic_Qw = myEps;
if(0 == m_zwd_Qw) m_zwd_Qw = myEps; if(0 == m_clk_Qw) m_clk_Qw = myEps;
if(0 == m_amb_Qw) m_amb_Qw = myEps; if(0 == m_ion_Qw) m_ion_Qw = myEps;
}
//
void SRIFAlgorithm::setModel(SRIF_MODEL model_type)
{
m_SRIF_MODEL = model_type;
m_sys_num = getSystemnum();
m_sys_str = getSatlitSys();
switch (model_type)
{
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_const_param = 3 + m_sys_num;//[dx,dy,dz,mf]
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_const_param = 4 + m_sys_num;//[dx,dy,dz,mf,clki]
break;
default:
m_const_param = 4+1;
break;
}
}
//Initialize SRIF
void SRIFAlgorithm::initSRIFPara(QVector< SatlitData > &currEpoch,MatrixXd &B,VectorXd &L)
{
int epochLenLB = currEpoch.length();
//Fk_1 initialization
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Phi.resize(m_const_param, m_const_param);
m_Phi.setIdentity(m_const_param, m_const_param);
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Phi.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Phi.setIdentity(m_const_param+epochLenLB,m_const_param+epochLenLB);
break;
default:
break;
}
//Initial state covariance matrix m_Q initialization(not used)
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Q.resize(m_const_param,m_const_param);
m_Q.setZero();
for(int i = 3; i < m_const_param;i++) m_Q(i,i) = m_clk_Pk;// for clock
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Q.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Q.setZero();
m_Q(0,0) = m_xyz_dynamic_Pk;m_Q(1,1) = m_xyz_dynamic_Pk;m_Q(2,2) = m_xyz_dynamic_Pk;
m_Q(3,3) = m_zwd_Pk;
for(int i = 4; i < m_const_param;i++) m_Q(i,i) = m_clk_Pk; // for clock
for (int i = 0;i < epochLenLB;i++) m_Q(m_const_param+i,m_const_param+i) = m_amb_Pk;// for Ambiguity
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
//Chole decomposition of m_Rwk covariance inverse
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Rwk.resize(m_const_param,m_const_param);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
for(int i = 3; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw);// for clock
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Rwk.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
m_Rwk(3,3) = sqrt(1/m_zwd_Qw);//Zenith tropospheric residual variance
for(int i = 4; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw); // for clock
for(int i = m_const_param;i < m_const_param+epochLenLB;i++)// for Ambiguity
m_Rwk(i,i) = sqrt(1/m_amb_Qw);
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// juge is kinematic
if(m_SRIF_MODEL == SRIF_MODEL::SPP_KINEMATIC || m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
{
m_Rwk(0,0) = sqrt(1/m_xyz_dynamic_Qw);
m_Rwk(1,1) = sqrt(1/m_xyz_dynamic_Qw);
m_Rwk(2,2) = sqrt(1/m_xyz_dynamic_Qw);
}
// init m_G of m_Rwk
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_G.resize(m_const_param,m_const_param);
m_G.setIdentity();
// for(int i = 3; i < m_const_param;i++) m_G(i,i) = 1;// for clock
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_G.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_G.setIdentity();
// m_G(3,3) = 1;//Zenith troposphere
// for(int i = 4; i < m_const_param;i++) m_G(i,i) = 1; // for clock
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// if(m_SRIF_MODEL == SRIF_MODEL::SPP_KINEMATIC || m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
// {
// m_G(0,0) = 1;
// m_G(1,1) = 1;
// m_G(2,2) = 1;
// }
//Xk initialization, least squares initialization
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Xk.resize(m_const_param);
m_Xk.setZero();
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Xk.resize(epochLenLB+m_const_param);
m_Xk.setZero();
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// init SRIF
m_Rp = B.transpose()*B;
m_Zp = B.transpose()*L;
m_Xk = m_Rp.inverse()*m_Zp;
m_init_Xk = m_Xk;
this->m_isInitPara = true;//Not initialized after
}
//Initialize SRIF for nocombination
void SRIFAlgorithm::initSRIFPara_NoCombination(QVector< SatlitData > &currEpoch,MatrixXd &B,VectorXd &L)
{
int epochLenLB = currEpoch.length();
//Fk_1 initialization
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Phi.resize(m_const_param+epochLenLB, m_const_param+epochLenLB);
m_Phi.setIdentity();
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Phi.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Phi.setIdentity();
break;
default:
break;
}
//Initial state covariance matrix m_Q initialization(not used)
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Q.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Q.setZero();
for(int i = 3; i < m_const_param;i++) m_Q(i,i) = m_clk_Pk;// for clock
for(int i = m_const_param; i < m_const_param+epochLenLB;i++) m_Q(i,i) = m_ion_Pk;// for ION
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Q.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Q.setZero();
m_Q(0,0) = m_xyz_dynamic_Pk;m_Q(1,1) = m_xyz_dynamic_Pk;m_Q(2,2) = m_xyz_dynamic_Pk;
m_Q(3,3) = m_zwd_Pk;
for(int i = 4; i < m_const_param;i++) m_Q(i,i) = m_clk_Pk; // for clock
for (int i = m_const_param;i < m_const_param+epochLenLB;i++) m_Q(i,i) = m_ion_Pk;// for ION
for (int i = m_const_param+epochLenLB;i < m_const_param+3*epochLenLB;i++) m_Q(i,i) = m_amb_Pk;// for AMB
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
//Chole decomposition of m_Rwk covariance inverse
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Rwk.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
for(int i = 3; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw);// for clock
for(int i = m_const_param; i < m_const_param+epochLenLB;i++) m_Rwk(i,i) = sqrt(1/m_ion_Qw);// for ION
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Rwk.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
m_Rwk(3,3) = sqrt(1/m_zwd_Qw);//Zenith tropospheric residual variance
for(int i = 4; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw); // for clock
for(int i = m_const_param;i < m_const_param+epochLenLB;i++) m_Rwk(i,i) = sqrt(1/m_ion_Qw);// for ION
for(int i = m_const_param+epochLenLB;i < m_const_param+3*epochLenLB;i++) m_Rwk(i,i) = sqrt(1/m_amb_Qw);// for AMB
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// juge is kinematic
if(m_SRIF_MODEL == SRIF_MODEL::SPP_KINEMATIC || m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
{
m_Rwk(0,0) = 1/m_xyz_dynamic_Qw;
m_Rwk(1,1) = 1/m_xyz_dynamic_Qw;
m_Rwk(2,2) = 1/m_xyz_dynamic_Qw;
}
// init m_G of m_Rwk
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_G.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_G.setIdentity();
// for(int i = 3; i < m_const_param;i++) m_G(i,i) = 1;// for clock
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_G.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_G.setIdentity();
// m_G(3,3) = 1;//Zenith troposphere
// for(int i = 4; i < m_const_param;i++) m_G(i,i) = 1; // for clock
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// if(m_SRIF_MODEL == SRIF_MODEL::SPP_KINEMATIC || m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
// {
// m_G(0,0) = 1;
// m_G(1,1) = 1;
// m_G(2,2) = 1;
// }
//Xk initialization, least squares initialization
switch (m_SRIF_MODEL) {
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
m_Xk.resize(m_const_param+epochLenLB);
m_Xk.setZero();
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
m_Xk.resize(m_const_param+3*epochLenLB);
m_Xk.setZero();
break;
default:
ErroTrace("QKalmanFilter::initKalman Bad.");
break;
}
// init SRIF
m_Rp = B.transpose()*B;
m_Zp = B.transpose()*L;
m_Xk = m_Rp.inverse()*m_Zp;
m_init_Xk = m_Xk;
this->m_isInitPara = true;//Not initialized after
}
//Change the size of the SRIF parameter (only PPP can change paramater)
void SRIFAlgorithm::changeSRIFPara( QVector< SatlitData > &epochSatlitData,QVector< int >oldPrnFlag, int preEpochLen)
{
int epochLenLB = epochSatlitData.length();
m_Phi.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Phi.setZero();
m_Phi.setIdentity(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Phi_Inv = m_Phi.inverse();
//Xk_1 change
VectorXd tempXk_1 = m_Xk;
m_Xk.resize(epochLenLB+m_const_param);
m_Xk.setZero();
//Xk.resize(epochLenLB+5);
for (int i = 0;i < m_const_param;i++)
m_Xk(i) = tempXk_1(i);
for (int i = 0;i<epochLenLB;i++)
{
if (oldPrnFlag.at(i)!=-1)//Save the old satellite ambiguity
m_Xk(m_const_param+i) = tempXk_1(oldPrnFlag.at(i)+m_const_param);
else
{//New satellite ambiguity calculation
SatlitData oneStalit = epochSatlitData.at(i);
m_Xk(m_const_param+i) = (oneStalit.PP3 - oneStalit.LL3)/M_GetLamta3(oneStalit.Frq[0],oneStalit.Frq[1]);
}
}
//m_Rwk system noise initialization
m_Rwk.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
m_Rwk(3,3) = sqrt(1/m_zwd_Qw);//Zenith tropospheric residual variance 3e-8
for(int i = 4; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw); // for clock
for(int i = m_const_param;i < m_const_param+epochLenLB;i++)// for Ambiguity
m_Rwk(i,i) = sqrt(1/m_amb_Qw);
// juge is kinematic
if(m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
{
m_Rwk(0,0) = sqrt(1/m_xyz_dynamic_Qw);
m_Rwk(1,1) = sqrt(1/m_xyz_dynamic_Qw);
m_Rwk(2,2) = sqrt(1/m_xyz_dynamic_Qw);
}
// init m_G of m_Rwk
m_G.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_G.setIdentity();
//Reset Rk_1 observation noise matrix (reset on the outside, no need to repeat reset here)
//The saved state covariance matrix Pk_1 is increased or decreased (here is more complicated, the main idea is to take out old satellite data, and initialize the new satellite data)
MatrixXd tempPk_1 = m_Rp, tempZp_1 = m_Zp;
m_Rp.resize(m_const_param+epochLenLB,m_const_param+epochLenLB);
m_Rp.setZero();
m_Zp.resize(m_const_param+epochLenLB,1);
m_Zp.setZero();
//If the number of satellites changes
//if satlite number lost, should change tempZp_1 first!
QVector< int > lost_satNum;//store lost satlite number
for (int i = 0;i < preEpochLen;i++)
{
bool is_find = false;
for(int j = 0;j < epochLenLB;j++)
{
int flag = oldPrnFlag.at(j);
if(i == flag)
{
is_find = true;
break;
}
}
if(!is_find) lost_satNum.append(i);
}
// if have lost number change tempZp_1(previous epoch m_Xk sored in tempXk_1)
for(int i = 0; i < lost_satNum.length();i++)
{
int lostNumber = lost_satNum.at(i) + m_const_param;// 5 is The first five parameters
if(lostNumber + 1 > tempPk_1.cols()) break;
for(int k = 0; k < tempZp_1.rows();k++)
{
tempZp_1(k, 0) = tempZp_1(k, 0) - tempPk_1(k, lostNumber)*tempXk_1(lostNumber,0);
}
}
for (int i = 0;i < m_const_param;i++)
{
for (int j = 0;j < m_const_param;j++)
m_Rp(i,j) = tempPk_1(i,j);
m_Zp(i,0) = tempZp_1(i,0);
}
for (int n = 0; n < epochLenLB;n++)
{
int flag = oldPrnFlag.at(n);
if ( flag != -1)//Description: The previous epoch contains this satellite data and needs to be taken from tempPk_1
{
flag += m_const_param;//The number of rows of this satellite in the original data tempPk_1
m_Zp(n+m_const_param,0) = tempZp_1(flag,0);// save old Zp tp new Zp
for (int i = 0;i < tempPk_1.cols();i++)
{//Take out from tempPk_1 and skip the data with oldPrnFlag -1
if (i < m_const_param)
{
m_Rp(n+m_const_param,i) = tempPk_1(flag,i);
m_Rp(i,n+m_const_param) = tempPk_1(i,flag);
}
else
{
int findCols = i - m_const_param,saveFlag = -1;
//Find if the data exists in the old linked list and where it will be saved
for (int m = 0;m < oldPrnFlag.length();m++)
{
if (findCols == oldPrnFlag.at(m))
{
saveFlag = m;
break;
}
}
if (saveFlag!=-1)
{
m_Rp(n+m_const_param,saveFlag+m_const_param) = tempPk_1(flag,i);
//Pk_1(saveFlag+5,n+5) = tempPk_1(i,flag);
}
}//if (i < 5)
}//for (int i = 0;i < tempPk_1.cols();i++)
}
else
{
//New satellite ambiguity calculation
SatlitData oneStalit = epochSatlitData.at(n);
double oneStalit_lamda = M_GetLamta3(oneStalit.Frq[0],oneStalit.Frq[1]);
m_Rp(n+m_const_param,n+m_const_param) = oneStalit_lamda;
m_Zp(n+m_const_param,0) = m_Xk(n+m_const_param,0) * oneStalit_lamda;
m_Rwk(n+m_const_param, n+m_const_param) = sqrt(m_amb_Qw); // set new ambiguity noise matrix m_Rwk (this's important)
for (int i = 0;i < m_const_param;i++)
{
m_Rp(n+m_const_param,i) = 0;
m_Rp(i,n+m_const_param) = 0;
}
}
}//Pk_1 saves the data
MatrixXd error = m_Rp*m_Xk - m_Zp;
// m_matrix.writeCSV("m_Rp.csv", m_Rp);
// m_matrix.writeCSV("tempPk_1.csv", tempPk_1);
m_VarChang = true;
}
//Change the size of the SRIF parameter (only PPP can change paramater)
void SRIFAlgorithm::changeSRIFPara_NoCombination( QVector< SatlitData > &epochSatlitData,QVector< int >oldPrnFlag, int preEpochLen)
{
int epochLenLB = epochSatlitData.length();
m_Phi.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Phi.setZero();
m_Phi.setIdentity();
m_Phi_Inv = m_Phi.inverse();
//Xk_1 change
VectorXd tempXk_1 = m_Xk;
m_Xk.resize(3*epochLenLB+m_const_param);
m_Xk.setZero();
//Xk.resize(epochLenLB+5);
for (int i = 0;i < m_const_param;i++)
m_Xk(i) = tempXk_1(i);
for (int i = 0;i<epochLenLB;i++)
{
if (oldPrnFlag.at(i)!=-1)//Save the old satellite ION and L1 and L2 ambiguity
{
m_Xk(m_const_param+i) = tempXk_1(oldPrnFlag.at(i)+m_const_param);// for ION
m_Xk(m_const_param+epochLenLB+i) = tempXk_1(oldPrnFlag.at(i)+ preEpochLen + m_const_param);// for L1 ambiguity
m_Xk(m_const_param+2*epochLenLB+i) = tempXk_1(oldPrnFlag.at(i)+ 2*preEpochLen + m_const_param);// for L2 ambiguity
}
else
{//New satellite ambiguity calculation
SatlitData oneStalit = epochSatlitData.at(i);
double F1 = oneStalit.Frq[0], F2 = oneStalit.Frq[1];
m_Xk(m_const_param+i) = (oneStalit.C1 - oneStalit.C2)/(1 - (F1*F1)/(F2*F2));
m_Xk(m_const_param+epochLenLB+i) = (oneStalit.C1 - oneStalit.L1)/oneStalit.Frq[0];// new L1 ambiguity
m_Xk(m_const_param+2*epochLenLB+i) = (oneStalit.C2 - oneStalit.L2)/oneStalit.Frq[1];// new L2 ambiguity
}
}
//m_Rwk system noise initialization
m_Rwk.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Rwk.setZero();
m_Rwk(0,0) = 1e10; m_Rwk(1,1) = 1e10; m_Rwk(2,2) = 1e10;
m_Rwk(3,3) = sqrt(1/m_zwd_Qw);//Zenith tropospheric residual variance
for(int i = 4; i < m_const_param;i++) m_Rwk(i,i) = sqrt(1/m_clk_Qw); // for clock
for(int i = m_const_param;i < m_const_param+epochLenLB;i++) m_Rwk(i,i) = sqrt(1/m_ion_Qw);// for ION
for(int i = m_const_param+epochLenLB;i < m_const_param+3*epochLenLB;i++) m_Rwk(i,i) = sqrt(1/m_amb_Qw);// for AMB
// juge is kinematic
if(m_SRIF_MODEL == SRIF_MODEL::PPP_KINEMATIC)
{
m_Rwk(0,0) = 1/m_xyz_dynamic_Qw;
m_Rwk(1,1) = 1/m_xyz_dynamic_Qw;
m_Rwk(2,2) = 1/m_xyz_dynamic_Qw;
}
// init m_G of m_Rwk
m_G.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_G.setIdentity();
//Reset Rk_1 observation noise matrix (reset on the outside, no need to repeat reset here)
//The saved state covariance matrix Pk_1 is increased or decreased (here is more complicated, the main idea is to take out old satellite data, and initialize the new satellite data)
MatrixXd tempPk_1 = m_Rp, tempZp_1 = m_Zp;
m_Rp.resize(m_const_param+3*epochLenLB,m_const_param+3*epochLenLB);
m_Rp.setZero();
m_Zp.resize(m_const_param+3*epochLenLB,1);
m_Zp.setZero();
//If the number of satellites changes
//if satlite number lost, should change tempZp_1 first!
QVector< int > lost_satNum;//store lost satlite number
for (int i = 0;i < preEpochLen;i++)
{
bool is_find = false;
for(int j = 0;j < epochLenLB;j++)
{
int flag = oldPrnFlag.at(j);
if(i == flag)
{
is_find = true;
break;
}
}
if(!is_find) lost_satNum.append(i);
}
// if have lost number change tempZp_1(previous epoch m_Xk sored in tempXk_1)
for(int i = 0; i < lost_satNum.length();i++)
{
int lostNumber = lost_satNum.at(i) + m_const_param;// 5 is The first five parameters
if(lostNumber + 1 > tempPk_1.cols()) break;
for(int k = 0; k < tempZp_1.rows();k++)
{
//
tempZp_1(k, 0) = tempZp_1(k, 0) - tempPk_1(k, lostNumber)*tempXk_1(lostNumber,0)
- tempPk_1(k, lostNumber+preEpochLen)*tempXk_1(lostNumber+preEpochLen,0)
- tempPk_1(k, lostNumber+2*preEpochLen)*tempXk_1(lostNumber+2*preEpochLen,0);
}
}
for (int i = 0;i < m_const_param;i++)
{
for (int j = 0;j < m_const_param;j++)
m_Rp(i,j) = tempPk_1(i,j);
m_Zp(i,0) = tempZp_1(i,0);
}
for (int n = 0; n < epochLenLB;n++)
{
int flag = oldPrnFlag.at(n);
if ( flag != -1)//Description: The previous epoch contains this satellite data and needs to be taken from tempPk_1
{
flag += m_const_param;//The number of rows of this satellite in the original data tempPk_1
m_Zp(n+m_const_param,0) = tempZp_1(flag,0);// save old Zp tp new Zp for ION
m_Zp(n+m_const_param+epochLenLB,0) = tempZp_1(flag+preEpochLen,0);// save old Zp tp new Zp for L1 amb
m_Zp(n+m_const_param+2*epochLenLB,0) = tempZp_1(flag+2*preEpochLen,0);// save old Zp tp new Zp for L2 amb
for (int i = 0;i < tempPk_1.cols();i++)
{//Take out from tempPk_1 and skip the data with oldPrnFlag -1
if (i < m_const_param)
{
// for ION
m_Rp(n+m_const_param,i) = tempPk_1(flag,i);
m_Rp(i,n+m_const_param) = tempPk_1(i,flag);
// for L1 AMB
m_Rp(n+m_const_param+epochLenLB,i) = tempPk_1(flag+preEpochLen,i);
m_Rp(i,n+m_const_param+epochLenLB) = tempPk_1(i,flag+preEpochLen);
// for L2 AMB
m_Rp(n+m_const_param+2*epochLenLB,i) = tempPk_1(flag+2*preEpochLen,i);
m_Rp(i,n+m_const_param+2*epochLenLB) = tempPk_1(i,flag+2*preEpochLen);
}
else
{
int findCols = i - m_const_param,saveFlag = -1;
//Find if the data exists in the old linked list and where it will be saved
for (int m = 0;m < oldPrnFlag.length();m++)
{
if (findCols == oldPrnFlag.at(m))
{
saveFlag = m;
break;
}
}
if (saveFlag!=-1)
{
// qDebug() <<"(" << flag << "," << i << ") -> " <<" (" << n+m_const_param << "," << saveFlag+m_const_param << ")";
m_Rp(n+m_const_param,saveFlag+m_const_param) = tempPk_1(flag,i);// for ION
m_Rp(n+m_const_param,saveFlag+m_const_param+epochLenLB) = tempPk_1(flag,i+preEpochLen);
m_Rp(n+m_const_param,saveFlag+m_const_param+2*epochLenLB) = tempPk_1(flag,i+2*preEpochLen);
m_Rp(n+m_const_param+epochLenLB,saveFlag+m_const_param) = tempPk_1(flag+preEpochLen,i);// for L1 AMB
m_Rp(n+m_const_param+epochLenLB,saveFlag+m_const_param+epochLenLB) = tempPk_1(flag+preEpochLen,i+preEpochLen);// for L1 AMB
m_Rp(n+m_const_param+epochLenLB,saveFlag+m_const_param+2*epochLenLB) = tempPk_1(flag+preEpochLen,i+2*preEpochLen);// for L1 AMB
m_Rp(n+m_const_param+2*epochLenLB,saveFlag+m_const_param) = tempPk_1(flag+2*preEpochLen,i);// for L2 AMB
m_Rp(n+m_const_param+2*epochLenLB,saveFlag+m_const_param+epochLenLB) = tempPk_1(flag+2*preEpochLen,i+preEpochLen);// for L2 AMB
m_Rp(n+m_const_param+2*epochLenLB,saveFlag+m_const_param+2*epochLenLB) = tempPk_1(flag+2*preEpochLen,i+2*preEpochLen);// for L2 AMB
}
}//if (i < 5)
}//for (int i = 0;i < tempPk_1.cols();i++)
}
else
{
//New satellite ambiguity calculation
SatlitData oneStalit = epochSatlitData.at(n);
double oneStalit_lamda1 = M_C/oneStalit.Frq[0],oneStalit_lamda2 = M_C/oneStalit.Frq[1];
// for ION
m_Rp(n+m_const_param,n+m_const_param) = 1;
m_Zp(n+m_const_param,0) = m_Xk(n+m_const_param,0) * 1;
// for L1 amb
m_Rp(n+m_const_param+epochLenLB,n+m_const_param+epochLenLB) = oneStalit_lamda1;
m_Zp(n+m_const_param+epochLenLB,0) = m_Xk(n+m_const_param+epochLenLB,0) * oneStalit_lamda1;
// for L2 amb
m_Rp(n+m_const_param+2*epochLenLB,n+m_const_param+2*epochLenLB) = oneStalit_lamda2;
m_Zp(n+m_const_param+2*epochLenLB,0) = m_Xk(n+m_const_param+2*epochLenLB,0) * oneStalit_lamda2;
// set Rwk
m_Rwk(n+m_const_param, n+m_const_param) = sqrt(m_ion_Qw); // set new ION noise matrix m_Rwk (this's important)
m_Rwk(n+m_const_param+epochLenLB, n+m_const_param+epochLenLB) = sqrt(m_amb_Qw); // set new L1 ambiguity noise matrix m_Rwk (this's important)
m_Rwk(n+m_const_param+2*epochLenLB, n+m_const_param+2*epochLenLB) = sqrt(m_amb_Qw); // set new L1 ambiguity noise matrix m_Rwk (this's important)
for (int i = 0;i < m_const_param;i++)
{
m_Rp(n+m_const_param+epochLenLB,i) = 0;
m_Rp(i,n+m_const_param+epochLenLB) = 0;
m_Rp(n+m_const_param+2*epochLenLB,i) = 0;
m_Rp(i,n+m_const_param+2*epochLenLB) = 0;
}
}
}//Pk_1 saves the data
MatrixXd error = m_Rp*m_Xk - m_Zp;
// m_matrix.writeCSV("m_Rp.csv", m_Rp);
// m_matrix.writeCSV("tempPk_1.csv", tempPk_1);
m_VarChang = true;
}
// use least square method solver B*X = L
void SRIFAlgorithm::ls_solver(QVector< SatlitData > &currEpoch, double *m_ApproxRecPos)
{// this function will change m_ApproxRecPos data
MatrixXd mat_B, mat_P, B1;
Vector3d temp_Xk_1, diff_Xk;
VectorXd ls_Xk, Vct_L, L1;// this ls_Xk contains [dX,dY,dZ,dTrop,dClock,N1,N2,..Nn]
int loop_max = 20, epochLenLB = 0;// max loop iter time
double ApproxRecPos[3] = {0};
temp_Xk_1.setZero();
epochLenLB = currEpoch.length();
while(loop_max > 0)
{
Obtaining_equation(currEpoch, ApproxRecPos, mat_B, Vct_L, mat_P);
B1 = mat_B.block(epochLenLB, 0, epochLenLB, m_const_param);
L1 = Vct_L.tail(epochLenLB);
ls_Xk = (B1.transpose()*B1).inverse()*B1.transpose()*L1;
// ls_Xk = (mat_B.transpose()*mat_B).inverse()*mat_B.transpose()*Vct_L;
// only compute [dX,dY,dZ]
diff_Xk(0) = ls_Xk(0) - temp_Xk_1(0);
diff_Xk(1) = ls_Xk(1) - temp_Xk_1(1);
diff_Xk(2) = ls_Xk(2) - temp_Xk_1(2);
// update m_ApproxRecPos and temp_Xk_1
ApproxRecPos[0] = ApproxRecPos[0] + ls_Xk(0);
ApproxRecPos[1] = ApproxRecPos[1] + ls_Xk(1);
ApproxRecPos[2] = ApproxRecPos[2] + ls_Xk(2);
temp_Xk_1(0) = ls_Xk(0);
temp_Xk_1(1) = ls_Xk(1);
temp_Xk_1(2) = ls_Xk(2);
if(diff_Xk.cwiseAbs().maxCoeff() < 1)
break;
loop_max--;
}
// qDebug() << loop_max;
m_ApproxRecPos[0] = ApproxRecPos[0];
m_ApproxRecPos[1] = ApproxRecPos[1];
m_ApproxRecPos[2] = ApproxRecPos[2];
}
// get matrix B and observer L
void SRIFAlgorithm::Obtaining_equation(QVector< SatlitData > &currEpoch, double *m_ApproxRecPos, MatrixXd &mat_B, VectorXd &Vct_L,
MatrixXd &mat_P)
{
int epochLenLB = currEpoch.length(), const_num = 3;
MatrixXd B, P;
VectorXd L, sys_len;
sys_len.resize(m_sys_str.length());
sys_len.setZero();
switch(m_SRIF_MODEL)
{
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
B.resize(epochLenLB,m_const_param);
P.resize(epochLenLB,epochLenLB);
L.resize(epochLenLB);
const_num = 3;// 3 is conntain [dx,dy,dz]
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
B.resize(2*epochLenLB,epochLenLB+m_const_param);
P.resize(2*epochLenLB,2*epochLenLB);
L.resize(2*epochLenLB);
const_num = 4;// 4 is conntain [dx,dy,dz,mf]
break;
default:
ErroTrace("QKalmanFilter::Obtaining_equation you should use setModel().");
break;
}
// init matrix
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 - m_ApproxRecPos[0];
dltaY = oneSatlit.Y - m_ApproxRecPos[1];
dltaZ = oneSatlit.Z - m_ApproxRecPos[2];
p0 = qSqrt(dltaX*dltaX+dltaY*dltaY+dltaZ*dltaZ);
// compute li mi ni
li = dltaX/p0;mi = dltaY/p0;ni = dltaZ/p0;
//Correction of each
double dlta = 0;
dlta = - oneSatlit.StaClock + oneSatlit.SatTrop - oneSatlit.Relativty -
oneSatlit.Sagnac - oneSatlit.TideEffect - oneSatlit.AntHeight;
// set B L P
double LP_whight = m_LP_whight;
switch(m_SRIF_MODEL)
{
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
//Computational B matrix
//L3 carrier matrix
B(i,0) = li;B(i,1) = mi;B(i,2) = ni;B(i,3) = -1;
// 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.09 for ISB)
}
}
// debug by xiaogongwei 2019.04.10 is exist base system satlite clk
if(m_sys_str[0] == oneSatlit.SatType)
is_find_base_sat = true;
//Pseudorange code L
if(SRIF_SMOOTH_RANGE::SMOOTH == m_SRIF_SMOOTH_RANGE)
{
L(i) = p0 - oneSatlit.PP3_Smooth + dlta;
// Pseudorange code L calculation weight matrix PP3
P(i, i) = 1 / oneSatlit.PP3_Smooth_Q;// Pseudo-range right
}
else
{
L(i) = p0 - oneSatlit.PP3 + dlta;
// Computing weight matrix P
P(i, i) = oneSatlit.SatWight;// Pseudo-range right
}
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
//Computational B matrix
//L3 carrier matrix
B(i,0) = li;B(i,1) = mi;B(i,2) = ni;B(i,3) = -oneSatlit.StaTropMap;B(i,4) = -1;
for (int n = 0;n < epochLenLB;n++)//The diagonal part of the rear part initializes the wavelength of Lamta3, and the rest is 0.
if (i == n)
B(i,m_const_param+n) = M_GetLamta3(oneSatlit.Frq[0],oneSatlit.Frq[1]);//LL3 wavelength
// else
// B(i,m_const_param+n) = 0;
//P3 pseudorange code matrix
B(i+epochLenLB,0) = li;B(i+epochLenLB,1) = mi;B(i+epochLenLB,2) = ni;B(i+epochLenLB,3) = -oneSatlit.StaTropMap;B(i+epochLenLB,4) = -1;
// for (int n = 0;n < epochLenLB;n++)//The latter part is all 0
// B(i+epochLenLB,m_const_param+n) = 0;
// 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,4+k) = -1;
B(i+epochLenLB,4+k) = -1;
sys_len[k] = 1;//good no zeros cloumn in B,sys_lenmybe 0 1 1 0(debug by xiaogongwei 2019.04.09 for ISB)
}
}
// debug by xiaogongwei 2019.04.10 is exist base system satlite clk
if(m_sys_str[0] == oneSatlit.SatType)
is_find_base_sat = true;
//Carrier L Pseudorange code L
L(i) = p0 - oneSatlit.LL3 + dlta;
L(i+epochLenLB) = p0 - oneSatlit.PP3 + dlta;
// Computing weight matrix P
// if(oneSatlit.UTCTime.epochNum <= 100) LP_whight = 1e6;// for convergence
P(i, i) = oneSatlit.SatWight * LP_whight;// Carrier weight
P(i + epochLenLB, i + epochLenLB) = oneSatlit.SatWight;// Pseudo-range right
break;
default:
ErroTrace("SRIFAlgorithm::Obtaining_equation you should use setModel().");
break;
}//switch(m_SRIF_MODEL)
}//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, const_num) = 0;
mat_B(mat_B.rows() - 1, const_num) = 1;
}
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(B.rows()+flag, const_num+i) = 1;
flag++;
}
}
}//if(no_zero > 0)
}
// get matrix B and observer L for No Combination
void SRIFAlgorithm::Obtaining_equation_NoCombination(QVector< SatlitData > &currEpoch, double *m_ApproxRecPos, MatrixXd &mat_B, VectorXd &Vct_L,
MatrixXd &mat_P)
{
int epochLenLB = currEpoch.length(), const_num = 3;
MatrixXd B, P;
VectorXd L, sys_len;
sys_len.resize(m_sys_str.length());
sys_len.setZero();
switch(m_SRIF_MODEL)
{
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
B.resize(2*epochLenLB,m_const_param+epochLenLB);
P.resize(2*epochLenLB,2*epochLenLB);
L.resize(2*epochLenLB);
const_num = 3;// 3 is conntain [dx,dy,dz]
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
B.resize(4*epochLenLB,3*epochLenLB+m_const_param);
P.resize(4*epochLenLB,4*epochLenLB);
L.resize(4*epochLenLB);
const_num = 4;// 4 is conntain [dx,dy,dz,mf]
break;
default:
ErroTrace("QKalmanFilter::Obtaining_equation you should use setModel().");
break;
}
// init matrix
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 - m_ApproxRecPos[0];
dltaY = oneSatlit.Y - m_ApproxRecPos[1];
dltaZ = oneSatlit.Z - m_ApproxRecPos[2];
p0 = qSqrt(dltaX*dltaX+dltaY*dltaY+dltaZ*dltaZ);
// compute li mi ni
li = dltaX/p0;mi = dltaY/p0;ni = dltaZ/p0;
//Correction of each
double dlta = 0;
dlta = - oneSatlit.StaClock + oneSatlit.SatTrop - oneSatlit.Relativty -
oneSatlit.Sagnac - oneSatlit.TideEffect - oneSatlit.AntHeight;
// set B L P
double LP_whight = m_LP_whight;
double F1 = oneSatlit.Frq[0], F2 = oneSatlit.Frq[1];
double lamda1 = M_C/F1, lamda2 = M_C/F2;
switch(m_SRIF_MODEL)
{
case SRIF_MODEL::SPP_STATIC:
case SRIF_MODEL::SPP_KINEMATIC:
//Computational B matrix
//L3 carrier matrix
B(2*i,0) = li;B(2*i,1) = mi;B(2*i,2) = ni;B(2*i,3) = -1;
B(2*i+1,0) = li;B(2*i+1,1) = mi;B(2*i+1,2) = ni;B(2*i+1,3) = -1;
B(2*i,i+m_const_param) = -1;// ION for P1
B(2*i+1,i+m_const_param) = -(F1*F1)/(F2*F2);// ION for P2
// 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(2*i,3+k) = -1;
B(2*i+1,3+k) = -1;
sys_len[k] = 1;//good no zeros cloumn in B,sys_lenmybe 0 1 1 0(debug by xiaogongwei 2019.04.09 for ISB)
}
}
// debug by xiaogongwei 2019.04.10 is exist base system satlite clk
if(m_sys_str[0] == oneSatlit.SatType)
is_find_base_sat = true;
//Pseudorange code not use KALMAN_SMOOTH_RANGE::SMOOTH
//Pseudorange code L
if(SRIF_SMOOTH_RANGE::SMOOTH == m_SRIF_SMOOTH_RANGE)
{
L(2*i) = p0 - oneSatlit.CC1_Smooth + dlta;
L(2*i+1) = p0 - oneSatlit.CC2_Smooth + dlta;
P(2*i, 2*i) = 1 / oneSatlit.CC1_Smooth_Q;// Pseudo-range Wight
P(2*i+1, 2*i+1) = 1 / oneSatlit.CC2_Smooth_Q;// Pseudo-range Wight
}
else
{
L(2*i) = p0 - oneSatlit.C1 + dlta;
L(2*i+1) = p0 - oneSatlit.C2 + dlta;
P(2*i, 2*i) = oneSatlit.SatWight;
P(2*i+1, 2*i+1) = oneSatlit.SatWight;
}
break;
case SRIF_MODEL::PPP_KINEMATIC:
case SRIF_MODEL::PPP_STATIC:
//Computational B matrix
//L carrier matrix
B(2*i,0) = li;B(2*i,1) = mi;B(2*i,2) = ni;B(2*i,3) = -oneSatlit.StaTropMap;B(2*i,4) = -1; // L1
B(2*i+1,0) = li;B(2*i+1,1) = mi;B(2*i+1,2) = ni;B(2*i+1,3) = -oneSatlit.StaTropMap;B(2*i+1,4) = -1; // L2
B(2*i,i+m_const_param) = +1;// ION for L1
B(2*i+1,i+m_const_param) = +(F1*F1)/(F2*F2);// ION for L2
B(2*i,i+m_const_param+epochLenLB) = lamda1;// N1 for L1
B(2*i+1,i+m_const_param+2*epochLenLB) = lamda2;// N2 for L2
//P pseudorange code matrix
B(2*i+2*epochLenLB,0) = li;B(2*i+2*epochLenLB,1) = mi;B(2*i+2*epochLenLB,2) = ni;B(2*i+2*epochLenLB,3) = -oneSatlit.StaTropMap;B(2*i+2*epochLenLB,4) = -1;
B(2*i+2*epochLenLB+1,0) = li;B(2*i+2*epochLenLB+1,1) = mi;B(2*i+2*epochLenLB+1,2) = ni;B(2*i+2*epochLenLB+1,3) = -oneSatlit.StaTropMap;B(2*i+2*epochLenLB+1,4) = -1;
B(2*i+2*epochLenLB,i+m_const_param) = -1;// ION for P1
B(2*i+2*epochLenLB+1,i+m_const_param) = -(F1*F1)/(F2*F2);// ION for P2
// debug by xiaogongwei 2019.04.03 for ISB
for(int k = 1; k < m_sys_str.length();k++)