1 |
|
---|
2 | // Part of BNC, a utility for retrieving decoding and
|
---|
3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
4 | //
|
---|
5 | // Copyright (C) 2007
|
---|
6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
7 | // http://www.bkg.bund.de
|
---|
8 | // Czech Technical University Prague, Department of Geodesy
|
---|
9 | // http://www.fsv.cvut.cz
|
---|
10 | //
|
---|
11 | // Email: euref-ip@bkg.bund.de
|
---|
12 | //
|
---|
13 | // This program is free software; you can redistribute it and/or
|
---|
14 | // modify it under the terms of the GNU General Public License
|
---|
15 | // as published by the Free Software Foundation, version 2.
|
---|
16 | //
|
---|
17 | // This program is distributed in the hope that it will be useful,
|
---|
18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | // GNU General Public License for more details.
|
---|
21 | //
|
---|
22 | // You should have received a copy of the GNU General Public License
|
---|
23 | // along with this program; if not, write to the Free Software
|
---|
24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
25 |
|
---|
26 | /* -------------------------------------------------------------------------
|
---|
27 | * BKG NTRIP Client
|
---|
28 | * -------------------------------------------------------------------------
|
---|
29 | *
|
---|
30 | * Class: t_pppParlist
|
---|
31 | *
|
---|
32 | * Purpose: List of estimated parameters
|
---|
33 | *
|
---|
34 | * Author: L. Mervart
|
---|
35 | *
|
---|
36 | * Created: 29-Jul-2014
|
---|
37 | *
|
---|
38 | * Changes:
|
---|
39 | *
|
---|
40 | * -----------------------------------------------------------------------*/
|
---|
41 |
|
---|
42 | #include <cmath>
|
---|
43 | #include <iostream>
|
---|
44 | #include <sstream>
|
---|
45 | #include <iomanip>
|
---|
46 | #include <algorithm>
|
---|
47 | #include <newmatio.h>
|
---|
48 |
|
---|
49 | #include "pppParlist.h"
|
---|
50 | #include "pppSatObs.h"
|
---|
51 | #include "pppStation.h"
|
---|
52 | #include "bncutils.h"
|
---|
53 | #include "bncconst.h"
|
---|
54 | #include "pppClient.h"
|
---|
55 |
|
---|
56 | using namespace BNC_PPP;
|
---|
57 | using namespace std;
|
---|
58 |
|
---|
59 | // Constructor
|
---|
60 | ////////////////////////////////////////////////////////////////////////////
|
---|
61 | t_pppParam::t_pppParam(e_type type, const t_prn& prn, t_lc::type tLC,
|
---|
62 | const vector<t_pppSatObs*>* obsVector) {
|
---|
63 |
|
---|
64 | _type = type;
|
---|
65 | _prn = prn;
|
---|
66 | _tLC = tLC;
|
---|
67 | _x0 = 0.0;
|
---|
68 | _indexOld = -1;
|
---|
69 | _indexNew = -1;
|
---|
70 | _noise = 0.0;
|
---|
71 | _ambInfo = 0;
|
---|
72 |
|
---|
73 | switch (_type) {
|
---|
74 | case crdX:
|
---|
75 | _epoSpec = false;
|
---|
76 | _sigma0 = OPT->_aprSigCrd[0];
|
---|
77 | _noise = OPT->_noiseCrd[0];
|
---|
78 | break;
|
---|
79 | case crdY:
|
---|
80 | _epoSpec = false;
|
---|
81 | _sigma0 = OPT->_aprSigCrd[1];
|
---|
82 | _noise = OPT->_noiseCrd[1];
|
---|
83 | break;
|
---|
84 | case crdZ:
|
---|
85 | _epoSpec = false;
|
---|
86 | _sigma0 = OPT->_aprSigCrd[2];
|
---|
87 | _noise = OPT->_noiseCrd[2];
|
---|
88 | break;
|
---|
89 | case clkR:
|
---|
90 | _epoSpec = true;
|
---|
91 | _sigma0 = OPT->_noiseClk;
|
---|
92 | break;
|
---|
93 | case amb:
|
---|
94 | _epoSpec = false;
|
---|
95 | _sigma0 = OPT->_aprSigAmb;
|
---|
96 | _ambInfo = new t_ambInfo();
|
---|
97 | if (obsVector) {
|
---|
98 | for (unsigned ii = 0; ii < obsVector->size(); ii++) {
|
---|
99 | const t_pppSatObs* obs = obsVector->at(ii);
|
---|
100 | if (obs->prn() == _prn) {
|
---|
101 | double offGG = 0;
|
---|
102 | if (_prn.system() == 'R' && tLC != t_lc::MW) {
|
---|
103 | offGG = PPP_CLIENT->offGG();
|
---|
104 | }
|
---|
105 | _x0 = floor((obs->obsValue(tLC) - offGG - obs->cmpValue(tLC)) / obs->lambda(tLC) + 0.5);
|
---|
106 | break;
|
---|
107 | }
|
---|
108 | }
|
---|
109 | }
|
---|
110 | break;
|
---|
111 | case offGG:
|
---|
112 | _epoSpec = true;
|
---|
113 | _sigma0 = 1000.0;
|
---|
114 | _x0 = PPP_CLIENT->offGG();
|
---|
115 | break;
|
---|
116 | case trp:
|
---|
117 | _epoSpec = false;
|
---|
118 | _sigma0 = OPT->_aprSigTrp;
|
---|
119 | _noise = OPT->_noiseTrp;
|
---|
120 | break;
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | // Destructor
|
---|
125 | ////////////////////////////////////////////////////////////////////////////
|
---|
126 | t_pppParam::~t_pppParam() {
|
---|
127 | delete _ambInfo;
|
---|
128 | }
|
---|
129 |
|
---|
130 | //
|
---|
131 | ////////////////////////////////////////////////////////////////////////////
|
---|
132 | double t_pppParam::partial(const bncTime& /* epoTime */, const t_pppSatObs* obs,
|
---|
133 | const t_lc::type& tLC) const {
|
---|
134 |
|
---|
135 | // Special Case - Melbourne-Wuebbena
|
---|
136 | // ---------------------------------
|
---|
137 | if (tLC == t_lc::MW && _type != amb) {
|
---|
138 | return 0.0;
|
---|
139 | }
|
---|
140 |
|
---|
141 | const t_pppStation* sta = PPP_CLIENT->staRover();
|
---|
142 | ColumnVector rhoV = sta->xyzApr() - obs->xc().Rows(1,3);
|
---|
143 |
|
---|
144 | switch (_type) {
|
---|
145 | case crdX:
|
---|
146 | return (sta->xyzApr()[0] - obs->xc()[0]) / rhoV.norm_Frobenius();
|
---|
147 | case crdY:
|
---|
148 | return (sta->xyzApr()[1] - obs->xc()[1]) / rhoV.norm_Frobenius();
|
---|
149 | case crdZ:
|
---|
150 | return (sta->xyzApr()[2] - obs->xc()[2]) / rhoV.norm_Frobenius();
|
---|
151 | case clkR:
|
---|
152 | return 1.0;
|
---|
153 | case offGG:
|
---|
154 | return (obs->prn().system() == 'R') ? 1.0 : 0.0;
|
---|
155 | case amb:
|
---|
156 | if (obs->prn() == _prn) {
|
---|
157 | if (tLC == _tLC) {
|
---|
158 | return (obs->lambda(tLC));
|
---|
159 | }
|
---|
160 | else if (tLC == t_lc::lIF && _tLC == t_lc::MW) {
|
---|
161 | return obs->lambda(t_lc::lIF) * obs->lambda(t_lc::MW) / obs->lambda(t_lc::l2);
|
---|
162 | }
|
---|
163 | else {
|
---|
164 | ColumnVector coeff(4);
|
---|
165 | obs->lc(tLC, 0.0, 0.0, 0.0, 0.0, &coeff);
|
---|
166 | if (_tLC == t_lc::l1) {
|
---|
167 | return obs->lambda(t_lc::l1) * coeff(1);
|
---|
168 | }
|
---|
169 | else if (_tLC == t_lc::l2) {
|
---|
170 | return obs->lambda(t_lc::l2) * coeff(2);
|
---|
171 | }
|
---|
172 | }
|
---|
173 | }
|
---|
174 | return 0.0;
|
---|
175 | case trp:
|
---|
176 | return 1.0 / sin(obs->eleSat());
|
---|
177 | }
|
---|
178 |
|
---|
179 | return 0.0;
|
---|
180 | }
|
---|
181 |
|
---|
182 | //
|
---|
183 | ////////////////////////////////////////////////////////////////////////////
|
---|
184 | string t_pppParam::toString() const {
|
---|
185 | stringstream ss;
|
---|
186 | switch (_type) {
|
---|
187 | case crdX:
|
---|
188 | ss << "CRD_X";
|
---|
189 | break;
|
---|
190 | case crdY:
|
---|
191 | ss << "CRD_Y";
|
---|
192 | break;
|
---|
193 | case crdZ:
|
---|
194 | ss << "CRD_Z";
|
---|
195 | break;
|
---|
196 | case clkR:
|
---|
197 | ss << "CLK ";
|
---|
198 | break;
|
---|
199 | case amb:
|
---|
200 | ss << "AMB " << left << setw(3) << t_lc::toString(_tLC) << right << ' ' << _prn.toString();
|
---|
201 | break;
|
---|
202 | case offGG:
|
---|
203 | ss << "OGG ";
|
---|
204 | break;
|
---|
205 | case trp:
|
---|
206 | ss << "TRP ";
|
---|
207 | break;
|
---|
208 | }
|
---|
209 | return ss.str();
|
---|
210 | }
|
---|
211 |
|
---|
212 | // Constructor
|
---|
213 | ////////////////////////////////////////////////////////////////////////////
|
---|
214 | t_pppParlist::t_pppParlist() {
|
---|
215 | }
|
---|
216 |
|
---|
217 | // Destructor
|
---|
218 | ////////////////////////////////////////////////////////////////////////////
|
---|
219 | t_pppParlist::~t_pppParlist() {
|
---|
220 | for (unsigned ii = 0; ii < _params.size(); ii++) {
|
---|
221 | delete _params[ii];
|
---|
222 | }
|
---|
223 | }
|
---|
224 |
|
---|
225 | //
|
---|
226 | ////////////////////////////////////////////////////////////////////////////
|
---|
227 | t_irc t_pppParlist::set(const bncTime& epoTime, const std::vector<t_pppSatObs*>& obsVector) {
|
---|
228 |
|
---|
229 | // Remove some Parameters
|
---|
230 | // ----------------------
|
---|
231 | vector<t_pppParam*>::iterator it = _params.begin();
|
---|
232 | while (it != _params.end()) {
|
---|
233 | t_pppParam* par = *it;
|
---|
234 |
|
---|
235 | bool remove = false;
|
---|
236 |
|
---|
237 | if (par->epoSpec()) {
|
---|
238 | remove = true;
|
---|
239 | }
|
---|
240 |
|
---|
241 | else if (par->type() == t_pppParam::amb) {
|
---|
242 | if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 120.0)) {
|
---|
243 | remove = true;
|
---|
244 | }
|
---|
245 | }
|
---|
246 |
|
---|
247 | else if (par->type() == t_pppParam::amb) {
|
---|
248 | if (par->lastObsTime().valid() && (epoTime - par->lastObsTime() > 3600.0)) {
|
---|
249 | remove = true;
|
---|
250 | }
|
---|
251 | }
|
---|
252 |
|
---|
253 | if (remove) {
|
---|
254 | delete par;
|
---|
255 | it = _params.erase(it);
|
---|
256 | }
|
---|
257 | else {
|
---|
258 | ++it;
|
---|
259 | }
|
---|
260 | }
|
---|
261 |
|
---|
262 | // Check whether parameters have observations
|
---|
263 | // ------------------------------------------
|
---|
264 | for (unsigned ii = 0; ii < _params.size(); ii++) {
|
---|
265 | t_pppParam* par = _params[ii];
|
---|
266 | if (par->prn() == 0) {
|
---|
267 | par->setLastObsTime(epoTime);
|
---|
268 | if (par->firstObsTime().undef()) {
|
---|
269 | par->setFirstObsTime(epoTime);
|
---|
270 | }
|
---|
271 | }
|
---|
272 | else {
|
---|
273 | for (unsigned jj = 0; jj < obsVector.size(); jj++) {
|
---|
274 | const t_pppSatObs* satObs = obsVector[jj];
|
---|
275 | if (satObs->prn() == par->prn()) {
|
---|
276 | par->setLastObsTime(epoTime);
|
---|
277 | if (par->firstObsTime().undef()) {
|
---|
278 | par->setFirstObsTime(epoTime);
|
---|
279 | }
|
---|
280 | break;
|
---|
281 | }
|
---|
282 | }
|
---|
283 | }
|
---|
284 | }
|
---|
285 |
|
---|
286 | // Required Set of Parameters
|
---|
287 | // --------------------------
|
---|
288 | vector<t_pppParam*> required;
|
---|
289 |
|
---|
290 | // Coordinates
|
---|
291 | // -----------
|
---|
292 | required.push_back(new t_pppParam(t_pppParam::crdX, t_prn(), t_lc::dummy));
|
---|
293 | required.push_back(new t_pppParam(t_pppParam::crdY, t_prn(), t_lc::dummy));
|
---|
294 | required.push_back(new t_pppParam(t_pppParam::crdZ, t_prn(), t_lc::dummy));
|
---|
295 |
|
---|
296 | // Receiver Clock
|
---|
297 | // --------------
|
---|
298 | required.push_back(new t_pppParam(t_pppParam::clkR, t_prn(), t_lc::dummy));
|
---|
299 |
|
---|
300 | // GPS-Glonass Clock Offset
|
---|
301 | // ------------------------
|
---|
302 | if (OPT->useGlonass()) {
|
---|
303 | required.push_back(new t_pppParam(t_pppParam::offGG, t_prn(), t_lc::dummy));
|
---|
304 | }
|
---|
305 |
|
---|
306 | // Troposphere
|
---|
307 | // -----------
|
---|
308 | if (OPT->estTrp()) {
|
---|
309 | required.push_back(new t_pppParam(t_pppParam::trp, t_prn(), t_lc::dummy));
|
---|
310 | }
|
---|
311 |
|
---|
312 | // Ambiguities
|
---|
313 | // -----------
|
---|
314 | for (unsigned jj = 0; jj < obsVector.size(); jj++) {
|
---|
315 | const t_pppSatObs* satObs = obsVector[jj];
|
---|
316 | const vector<t_lc::type>& ambLCs = OPT->ambLCs(satObs->prn().system());
|
---|
317 | for (unsigned ii = 0; ii < ambLCs.size(); ii++) {
|
---|
318 | required.push_back(new t_pppParam(t_pppParam::amb, satObs->prn(), ambLCs[ii], &obsVector));
|
---|
319 | }
|
---|
320 | }
|
---|
321 |
|
---|
322 | // Check if all required parameters are present
|
---|
323 | // --------------------------------------------
|
---|
324 | for (unsigned ii = 0; ii < required.size(); ii++) {
|
---|
325 | t_pppParam* parReq = required[ii];
|
---|
326 |
|
---|
327 | bool found = false;
|
---|
328 | for (unsigned jj = 0; jj < _params.size(); jj++) {
|
---|
329 | t_pppParam* parOld = _params[jj];
|
---|
330 | if (parOld->isEqual(parReq)) {
|
---|
331 | found = true;
|
---|
332 | break;
|
---|
333 | }
|
---|
334 | }
|
---|
335 | if (found) {
|
---|
336 | delete parReq;
|
---|
337 | }
|
---|
338 | else {
|
---|
339 | _params.push_back(parReq);
|
---|
340 | }
|
---|
341 | }
|
---|
342 |
|
---|
343 | // Set Parameter Indices
|
---|
344 | // ---------------------
|
---|
345 | sort(_params.begin(), _params.end(), t_pppParam::sortFunction);
|
---|
346 |
|
---|
347 | for (unsigned ii = 0; ii < _params.size(); ii++) {
|
---|
348 | t_pppParam* par = _params[ii];
|
---|
349 | par->setIndex(ii);
|
---|
350 | for (unsigned jj = 0; jj < obsVector.size(); jj++) {
|
---|
351 | const t_pppSatObs* satObs = obsVector[jj];
|
---|
352 | if (satObs->prn() == par->prn()) {
|
---|
353 | par->setAmbEleSat(satObs->eleSat());
|
---|
354 | par->stepAmbNumEpo();
|
---|
355 | }
|
---|
356 | }
|
---|
357 | }
|
---|
358 |
|
---|
359 | return success;
|
---|
360 | }
|
---|
361 |
|
---|
362 | //
|
---|
363 | ////////////////////////////////////////////////////////////////////////////
|
---|
364 | void t_pppParlist::printResult(const bncTime& epoTime, const SymmetricMatrix& QQ,
|
---|
365 | const ColumnVector& xx) const {
|
---|
366 |
|
---|
367 | string epoTimeStr = string(epoTime);
|
---|
368 |
|
---|
369 | LOG << endl;
|
---|
370 |
|
---|
371 | t_pppParam* parX = 0;
|
---|
372 | t_pppParam* parY = 0;
|
---|
373 | t_pppParam* parZ = 0;
|
---|
374 | for (unsigned ii = 0; ii < _params.size(); ii++) {
|
---|
375 | t_pppParam* par = _params[ii];
|
---|
376 | if (par->type() == t_pppParam::crdX) {
|
---|
377 | parX = par;
|
---|
378 | }
|
---|
379 | else if (par->type() == t_pppParam::crdY) {
|
---|
380 | parY = par;
|
---|
381 | }
|
---|
382 | else if (par->type() == t_pppParam::crdZ) {
|
---|
383 | parZ = par;
|
---|
384 | }
|
---|
385 | else {
|
---|
386 | int ind = par->indexNew();
|
---|
387 | LOG << epoTimeStr << ' ' << par->toString() << ' '
|
---|
388 | << setw(10) << setprecision(4) << par->x0() << ' '
|
---|
389 | << showpos << setw(10) << setprecision(4) << xx[ind] << noshowpos << " +- "
|
---|
390 | << setw(8) << setprecision(4) << sqrt(QQ[ind][ind]);
|
---|
391 | if (par->type() == t_pppParam::amb) {
|
---|
392 | LOG << " el = " << setw(6) << setprecision(2) << par->ambEleSat() * 180.0 / M_PI
|
---|
393 | << " epo = " << setw(4) << par->ambNumEpo();
|
---|
394 | }
|
---|
395 | LOG << endl;
|
---|
396 | }
|
---|
397 | }
|
---|
398 |
|
---|
399 | if (parX && parY && parZ) {
|
---|
400 | const t_pppStation* sta = PPP_CLIENT->staRover();
|
---|
401 |
|
---|
402 | ColumnVector xyz(3);
|
---|
403 | xyz[0] = xx[parX->indexNew()];
|
---|
404 | xyz[1] = xx[parY->indexNew()];
|
---|
405 | xyz[2] = xx[parZ->indexNew()];
|
---|
406 |
|
---|
407 | ColumnVector neu(3);
|
---|
408 | xyz2neu(sta->ellApr().data(), xyz.data(), neu.data());
|
---|
409 |
|
---|
410 | SymmetricMatrix QQxyz = QQ.SymSubMatrix(1,3);
|
---|
411 |
|
---|
412 | SymmetricMatrix QQneu(3);
|
---|
413 | covariXYZ_NEU(QQxyz, sta->ellApr().data(), QQneu);
|
---|
414 |
|
---|
415 | LOG << epoTimeStr
|
---|
416 | << " X = " << setprecision(4) << sta->xyzApr()[0] + xyz[0] << " +- "
|
---|
417 | << setprecision(4) << sqrt(QQxyz[0][0])
|
---|
418 |
|
---|
419 | << " Y = " << setprecision(4) << sta->xyzApr()[1] + xyz[1] << " +- "
|
---|
420 | << setprecision(4) << sqrt(QQxyz[1][1])
|
---|
421 |
|
---|
422 | << " Z = " << setprecision(4) << sta->xyzApr()[2] + xyz[2] << " +- "
|
---|
423 | << setprecision(4) << sqrt(QQxyz[2][2])
|
---|
424 |
|
---|
425 | << " dN = " << setprecision(4) << neu[0] << " +- "
|
---|
426 | << setprecision(4) << sqrt(QQneu[0][0])
|
---|
427 |
|
---|
428 | << " dE = " << setprecision(4) << neu[1] << " +- "
|
---|
429 | << setprecision(4) << sqrt(QQneu[1][1])
|
---|
430 |
|
---|
431 | << " dU = " << setprecision(4) << neu[2] << " +- "
|
---|
432 | << setprecision(4) << sqrt(QQneu[2][2]);
|
---|
433 | LOG << endl;
|
---|
434 | }
|
---|
435 | }
|
---|
436 |
|
---|