source: ntrip/trunk/BNC/bncmodel.cpp@ 2061

Last change on this file since 2061 was 2061, checked in by mervart, 14 years ago

* empty log message *

File size: 5.5 KB
Line 
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
48using namespace std;
49
50// Constructor
51////////////////////////////////////////////////////////////////////////////
52bncParam::bncParam(bncParam::parType typeIn) {
53 type = typeIn;
54}
55
56// Destructor
57////////////////////////////////////////////////////////////////////////////
58bncParam::~bncParam() {
59}
60
61// Partial
62////////////////////////////////////////////////////////////////////////////
63double 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////////////////////////////////////////////////////////////////////////////
81bncModel::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////////////////////////////////////////////////////////////////////////////
91bncModel::~bncModel() {
92}
93
94// Bancroft Solution
95////////////////////////////////////////////////////////////////////////////
96t_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////////////////////////////////////////////////////////////////////////////
145double 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) - satData->clk + tropDelay;
160}
161
162// Update Step of the Filter (currently just a single-epoch solution)
163////////////////////////////////////////////////////////////////////////////
164t_irc bncModel::update(t_epoData* epoData) {
165
166 unsigned nPar = _params.size();
167 unsigned nObs = epoData->size();
168
169 _AA.ReSize(nObs, nPar); // variance-covariance matrix
170 _ll.ReSize(nObs); // tems observed-computed
171
172 unsigned iObs = 0;
173 QMapIterator<QString, t_satData*> itObs(epoData->satData);
174 while (itObs.hasNext()) {
175 ++iObs;
176 itObs.next();
177 QString prn = itObs.key();
178 t_satData* satData = itObs.value();
179 _ll(iObs) = satData->P3 - cmpValueP3(satData);
180
181 unsigned iPar = 0;
182 QListIterator<bncParam*> itPar(_params);
183 while (itPar.hasNext()) {
184 ++iPar;
185 bncParam* par = itPar.next();
186 _AA(iObs, iPar) = par->partialP3(satData);
187 }
188 }
189
190 _QQ.ReSize(nPar);
191 _QQ << _AA.t() * _AA;
192 _QQ = _QQ.i();
193 _dx = _QQ * _AA.t() * _ll;
194
195 _xx.ReSize(nPar);
196
197 unsigned iPar = 0;
198 QListIterator<bncParam*> itPar(_params);
199 while (itPar.hasNext()) {
200 ++iPar;
201 bncParam* par = itPar.next();
202 _xx(iPar) = par->x0 + _dx(iPar);
203 }
204
205 return success;
206}
Note: See TracBrowser for help on using the repository browser.