1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncParam, bncModel
|
---|
30 | *
|
---|
31 | * Purpose: Model for PPP
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 01-Dec-2009
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iomanip>
|
---|
42 | #include <newmatio.h>
|
---|
43 |
|
---|
44 | #include "bncmodel.h"
|
---|
45 | #include "bncpppclient.h"
|
---|
46 | #include "bancroft.h"
|
---|
47 |
|
---|
48 | using namespace std;
|
---|
49 |
|
---|
50 | // Constructor
|
---|
51 | ////////////////////////////////////////////////////////////////////////////
|
---|
52 | bncParam::bncParam(bncParam::parType typeIn) {
|
---|
53 | type = typeIn;
|
---|
54 | }
|
---|
55 |
|
---|
56 | // Destructor
|
---|
57 | ////////////////////////////////////////////////////////////////////////////
|
---|
58 | bncParam::~bncParam() {
|
---|
59 | }
|
---|
60 |
|
---|
61 | // Partial
|
---|
62 | ////////////////////////////////////////////////////////////////////////////
|
---|
63 | double bncParam::partialP3(t_satData* satData) {
|
---|
64 | if (type == CRD_X) {
|
---|
65 | return (x0 - satData->xx(1)) / satData->rho;
|
---|
66 | }
|
---|
67 | else if (type == CRD_Y) {
|
---|
68 | return (x0 - satData->xx(2)) / satData->rho;
|
---|
69 | }
|
---|
70 | else if (type == CRD_Z) {
|
---|
71 | return (x0 - satData->xx(3)) / satData->rho;
|
---|
72 | }
|
---|
73 | else if (type == RECCLK) {
|
---|
74 | return 1.0;
|
---|
75 | }
|
---|
76 | return 0.0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | // Constructor
|
---|
80 | ////////////////////////////////////////////////////////////////////////////
|
---|
81 | bncModel::bncModel() {
|
---|
82 | _xcBanc.ReSize(4); _xcBanc = 0.0;
|
---|
83 | _params.push_back(new bncParam(bncParam::CRD_X));
|
---|
84 | _params.push_back(new bncParam(bncParam::CRD_Y));
|
---|
85 | _params.push_back(new bncParam(bncParam::CRD_Z));
|
---|
86 | _params.push_back(new bncParam(bncParam::RECCLK));
|
---|
87 | }
|
---|
88 |
|
---|
89 | // Destructor
|
---|
90 | ////////////////////////////////////////////////////////////////////////////
|
---|
91 | bncModel::~bncModel() {
|
---|
92 | }
|
---|
93 |
|
---|
94 | // Bancroft Solution
|
---|
95 | ////////////////////////////////////////////////////////////////////////////
|
---|
96 | t_irc bncModel::cmpBancroft(t_epoData* epoData) {
|
---|
97 |
|
---|
98 | const unsigned MINOBS = 4;
|
---|
99 |
|
---|
100 | if (epoData->size() < MINOBS) {
|
---|
101 | return failure;
|
---|
102 | }
|
---|
103 |
|
---|
104 | Matrix BB(epoData->size(), 4);
|
---|
105 |
|
---|
106 | QMapIterator<QString, t_satData*> it(epoData->satData);
|
---|
107 | int iObs = 0;
|
---|
108 | while (it.hasNext()) {
|
---|
109 | ++iObs;
|
---|
110 | it.next();
|
---|
111 | QString prn = it.key();
|
---|
112 | t_satData* satData = it.value();
|
---|
113 | BB(iObs, 1) = satData->xx(1);
|
---|
114 | BB(iObs, 2) = satData->xx(2);
|
---|
115 | BB(iObs, 3) = satData->xx(3);
|
---|
116 | BB(iObs, 4) = satData->P3 + satData->clk;
|
---|
117 | }
|
---|
118 |
|
---|
119 | bancroft(BB, _xcBanc);
|
---|
120 |
|
---|
121 | // Set Parameter A Priori Values
|
---|
122 | // -----------------------------
|
---|
123 | QListIterator<bncParam*> itPar(_params);
|
---|
124 | while (itPar.hasNext()) {
|
---|
125 | bncParam* par = itPar.next();
|
---|
126 | if (par->type == bncParam::CRD_X) {
|
---|
127 | par->x0 = _xcBanc(1);
|
---|
128 | }
|
---|
129 | else if (par->type == bncParam::CRD_Y) {
|
---|
130 | par->x0 = _xcBanc(2);
|
---|
131 | }
|
---|
132 | else if (par->type == bncParam::CRD_Z) {
|
---|
133 | par->x0 = _xcBanc(3);
|
---|
134 | }
|
---|
135 | else if (par->type == bncParam::RECCLK) {
|
---|
136 | par->x0 = _xcBanc(4);
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | return success;
|
---|
141 | }
|
---|
142 |
|
---|
143 | // Computed Value
|
---|
144 | ////////////////////////////////////////////////////////////////////////////
|
---|
145 | double bncModel::cmpValueP3(t_satData* satData) {
|
---|
146 |
|
---|
147 | double rho0 = (satData->xx - _xcBanc.Rows(1,3)).norm_Frobenius();
|
---|
148 |
|
---|
149 | ColumnVector xRec(3);
|
---|
150 | double dPhi = t_CST::omega * rho0 / t_CST::c;
|
---|
151 | xRec(1) = _xcBanc(1) * cos(dPhi) - _xcBanc(2) * sin(dPhi);
|
---|
152 | xRec(2) = _xcBanc(2) * cos(dPhi) + _xcBanc(1) * sin(dPhi);
|
---|
153 | xRec(3) = _xcBanc(3);
|
---|
154 |
|
---|
155 | satData->rho = (satData->xx - xRec).norm_Frobenius();
|
---|
156 |
|
---|
157 | double tropDelay = 0.0;
|
---|
158 |
|
---|
159 | return satData->rho + _xcBanc(4) + tropDelay;
|
---|
160 | }
|
---|
161 |
|
---|
162 | // Update Step of the Filter (currently just a single-epoch solution)
|
---|
163 | ////////////////////////////////////////////////////////////////////////////
|
---|
164 | t_irc bncModel::update(t_epoData* epoData) {
|
---|
165 |
|
---|
166 | unsigned nPar = _params.size();
|
---|
167 | unsigned nObs = epoData->size();
|
---|
168 |
|
---|
169 | cout << "update " << nPar << " " << nObs << endl;
|
---|
170 |
|
---|
171 | _AA.ReSize(nObs, nPar); // variance-covariance matrix
|
---|
172 | _ll.ReSize(nObs); // tems observed-computed
|
---|
173 |
|
---|
174 | unsigned iObs = 0;
|
---|
175 | QMapIterator<QString, t_satData*> itObs(epoData->satData);
|
---|
176 | while (itObs.hasNext()) {
|
---|
177 | ++iObs;
|
---|
178 | itObs.next();
|
---|
179 | QString prn = itObs.key();
|
---|
180 | t_satData* satData = itObs.value();
|
---|
181 | _ll(iObs) = cmpValueP3(satData);
|
---|
182 |
|
---|
183 | unsigned iPar = 0;
|
---|
184 | QListIterator<bncParam*> itPar(_params);
|
---|
185 | while (itPar.hasNext()) {
|
---|
186 | ++iPar;
|
---|
187 | bncParam* par = itPar.next();
|
---|
188 | _AA(iObs, iPar) = par->partialP3(satData);
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | cout << _AA << endl;
|
---|
193 | cout.flush();
|
---|
194 |
|
---|
195 | _QQ.ReSize(nPar);
|
---|
196 | _QQ << _AA.t() * _AA;
|
---|
197 | _QQ = _QQ.i();
|
---|
198 | _dx = _QQ * _AA.t() * _ll;
|
---|
199 |
|
---|
200 | _xx.ReSize(nPar);
|
---|
201 |
|
---|
202 | unsigned iPar = 0;
|
---|
203 | QListIterator<bncParam*> itPar(_params);
|
---|
204 | while (itPar.hasNext()) {
|
---|
205 | ++iPar;
|
---|
206 | bncParam* par = itPar.next();
|
---|
207 | _xx(iPar) = par->x0 + _dx(iPar);
|
---|
208 | }
|
---|
209 |
|
---|
210 | return success;
|
---|
211 | }
|
---|