Backup
[gps] / gpstk-prsolution.cpp
1 #include <iostream>
2 #include "PRSolution.hpp"
3 #include "SP3EphemerisStore.hpp"
4 #include "Position.hpp"
5
6 using namespace std;
7 using namespace gpstk;
8
9 int main() {
10
11         DayTime dayTime(1667, 66448.850000);
12         PRSolution raimSolver;
13
14         raimSolver.RMSLimit = 10.0;
15         //raimSolver.Debug = true;
16
17         vector<SatID> satelliteVector;
18         vector<double> pseudoRangeVector;
19
20         // push PRN 
21         satelliteVector.push_back(SatID( 2, SatID::systemGPS));
22         satelliteVector.push_back(SatID(10, SatID::systemGPS));
23         satelliteVector.push_back(SatID( 4, SatID::systemGPS));
24         satelliteVector.push_back(SatID( 5, SatID::systemGPS));
25         satelliteVector.push_back(SatID(13, SatID::systemGPS));
26         satelliteVector.push_back(SatID( 7, SatID::systemGPS));
27         satelliteVector.push_back(SatID(29, SatID::systemGPS));
28
29         // push pseudo range
30         pseudoRangeVector.push_back(21375681.860758);
31         pseudoRangeVector.push_back(20192220.627359);
32         pseudoRangeVector.push_back(21808239.424646);
33         pseudoRangeVector.push_back(23834064.766712);
34         pseudoRangeVector.push_back(20794005.449315);
35         pseudoRangeVector.push_back(21213754.205750);
36         pseudoRangeVector.push_back(25306963.567147);
37
38         SP3EphemerisStore ephemerisStore;
39         // from
40         // ftp://rgpdata.ign.fr/pub/products/ephemerides/1667/esr16670.sp3.Z
41         ephemerisStore.loadFile("esr16670.sp3");
42
43         // no tropo model
44         ZeroTropModel noTropModel;
45
46         raimSolver.RAIMCompute(dayTime, 
47                                satelliteVector,
48                                pseudoRangeVector,
49                                ephemerisStore,
50                                &noTropModel);
51
52         if (raimSolver.isValid()) {
53                 cout << fixed << setprecision(3);
54                 cout << "x = " << raimSolver.Solution[0] << endl;
55                 cout << "y = " << raimSolver.Solution[1] << endl;
56                 cout << "z = " << raimSolver.Solution[2] << endl;
57
58                 /* we got (the results depends on RMSLimit)
59                    Default RMSLimit :
60                         x = 4205773.319
61                         y =  166187.065
62                         z = 4776312.107
63
64                    RMSLimit = 1.0
65                         x = 4205780.801
66                         y = 166176.178
67                         z = 4776323.217
68
69                    RMSLimit = 10.0
70                         x = 4205771.276
71                         y = 166200.837
72                         z = 4776326.902
73
74                    SiRF Star III was computing (sat 2, 10 & 4) :
75                      X-position : 4205766 m
76                      Y-position :  166220 m
77                      Z-position : 4776300 m
78                 */
79
80                 Position pos(raimSolver.Solution[0],
81                              raimSolver.Solution[1],
82                              raimSolver.Solution[2],
83                              Position::Cartesian);
84
85                 cout << fixed << setprecision(6);
86                 cout << "longitude = " << pos.asGeodetic().getLongitude()
87                      << endl;
88                 cout << "latitude  = " << pos.asGeodetic().geodeticLatitude()
89                      << endl;
90                 cout << "altitude  = " << pos.asGeodetic().getAltitude()
91                      << endl;
92
93                 /* current position is (as reported by gpsd) : 
94                    longitude =   2.262773
95                    latitude  =  48.803081
96                    altitude  = 156.445000
97                 */
98         }
99
100         return 0;
101 }