#include #include #include #include #include "fmt/format.h" #include "fmt/printf.h" #include #include #include #include #include #include #include #include "ubx.hh" #include "bits.hh" #include "minivec.hh" #include "navmon.pb.h" #include "ephemeris.hh" #include "gps.hh" #include "glonass.hh" #include "beidou.hh" #include "galileo.hh" #include "navmon.hh" #include "tle.hh" #include using namespace std; Point g_ourpos; string beidouHealth(int in) { string ret; if(in == 256) { return "NO CLOCK"; } if(in==511) { return "NO SAT"; } if(in & (1<<7)) ret += "B1I abnormal "; if(in & (1<<6)) ret += "B2I abnormal "; if(in & (1<<5)) ret += "B3I abnormal "; if(in & (1<<1)) ret += "navigation abnormal "; if(ret.empty()) return "OK"; return ret; } double utcFromGPS(int wn, double tow) { return (315964800 + wn * 7*86400 + tow - 18); } static double utcFromGST(int wn, double tow) { return (935280000.0 + wn * 7*86400 + tow - 18); } // GALILEO ONLY!! template void doOrbitDump(int gnss, int sv, int wn, const T& oldEph, const T& newEph, int time_start, int time_end) { ofstream orbitcsv("orbit."+to_string(gnss)+"."+to_string(sv)+"."+to_string(oldEph.iodnav)+"-"+to_string(newEph.iodnav)+".csv"); orbitcsv << "timestamp x y z oldx oldy oldz\n"; orbitcsv << fixed; for(int t = time_start; t < time_end; t += 30) { Point p, oldp; getCoordinates(t, newEph, &p); getCoordinates(t, oldEph, &oldp); time_t posix = utcFromGST(wn, t); orbitcsv << posix <<" " < inav((uint8_t*)nmm.gi().contents().c_str(), nmm.gi().contents().size()); static map gms; static map, GalileoMessage> gmwtypes; static map oldgm4s; int sv = nmm.gi().gnsssv(); GalileoMessage& gm = gms[sv]; int wtype = gm.parse(inav); gm.tow = nmm.gi().gnsstow(); gmwtypes[{nmm.gi().gnsssv(), wtype}] = gm; static map oldEph; cout << "gal inav for "< "<=7 && wtype<=10) cout<<" ioda "<((uint8_t*)nmm.gpsi().contents().c_str(), nmm.gpsi().contents().size())); struct GPSState gs; static map eph; static map almas; uint8_t page; static int gpswn; int frame=parseGPSMessage(cond, gs, &page); cout<<"GPS "< oldgs1s; gpswn = gs.wn; cout << "gpshealth = "<<(int)gs.gpshealth<<", wn "<second.t0c != gs.t0c) { auto oldOffset = getGPSAtomicOffset(gs.tow, iter->second); auto newOffset = getGPSAtomicOffset(gs.tow, gs); cout<<" Timejump: "<second) )<<" seconds, old t0c "<second.t0c; } oldgs1s[sv] = gs; } else if(frame == 2) { parseGPSMessage(cond, eph[sv], &page); cout << "t0e = "<second.t0e << " " <second.t0e) << " iod "<= 25 && gs.gpsalma.sv <= 32) || gs.gpsalma.sv==57 ) { // see table 20-V of the GPS ICD cout << " data-id "<((uint8_t*)nmm.bid1().contents().c_str(), nmm.bid1().contents().size())); uint8_t pageno; static map bms; auto& bm = bms[sv]; int fraid = bm.parse(cond, &pageno); cout<<"BeiDou "< msgs; if(msgs[sv].wn>= 0 && msgs[sv].t0c != bm.t0c) { auto oldOffset = msgs[sv].getAtomicOffset(bm.sow); auto newOffset = bm.getAtomicOffset(bm.sow); cout<<" Timejump: "<((uint8_t*)nmm.bid2().contents().c_str(), nmm.bid2().contents().size())); BeidouMessage bm; uint8_t pageno; int fraid = bm.parse(cond, &pageno); cout<<"BeiDou "< gms; auto& gm = gms[nmm.gloi().gnsssv()]; int strno = gm.parse(std::basic_string((uint8_t*)nmm.gloi().contents().c_str(), nmm.gloi().contents().size())); cout<<"Glonass R"< "; cout << "("<