33 #ifndef GNSS_SDR_RTKLIB_H 34 #define GNSS_SDR_RTKLIB_H 44 #include <netinet/in.h> 59 #define closesocket close 60 #define lock_t pthread_mutex_t 61 #define initlock(f) pthread_mutex_init(f, NULL) 62 #define rtk_lock(f) pthread_mutex_lock(f) 63 #define rtk_unlock(f) pthread_mutex_unlock(f) 65 #define VER_RTKLIB "2.4.2" 66 #define NTRIP_AGENT "RTKLIB/" VER_RTKLIB 67 #define NTRIP_CLI_PORT 2101 68 #define NTRIP_SVR_PORT 80 69 #define NTRIP_MAXRSP 32768 70 #define NTRIP_MAXSTR 256 71 #define NTRIP_RSP_OK_CLI "ICY 200 OK\r\n" 72 #define NTRIP_RSP_OK_SVR "OK\r\n" 73 #define NTRIP_RSP_SRCTBL "SOURCETABLE 200 OK\r\n" 74 #define NTRIP_RSP_TBLEND "ENDSOURCETABLE" 75 #define NTRIP_RSP_HTTP "HTTP/" 76 #define NTRIP_RSP_ERROR "ERROR" 78 #define FTP_CMD "wget" 92 const int FILEPATHSEP =
'/';
96 const double HION = 350000.0;
156 const int NSYSGPS = 1;
175 const int NSYSGLO = 1;
180 const int NSYSGLO = 0;
187 const int NSYSGAL = 1;
192 const int MINPRNQZS_S = 183;
193 const int MAXPRNQZS_S = 189;
195 const int NSYSQZS = 1;
197 const int MINPRNQZS_S = 0;
198 const int NSATQZS = 0;
199 const int NSYSQZS = 0;
207 const int NSYSBDS = 1;
212 const int NSYSBDS = 0;
219 const int NSYSIRN = 1;
221 const int NSATIRN = 0;
222 const int NSYSIRN = 0;
229 const int NSYSLEO = 1;
231 const int NSATLEO = 0;
232 const int NSYSLEO = 0;
235 const int NSYS = (NSYSGPS + NSYSGLO + NSYSGAL + NSYSQZS + NSYSBDS + NSYSIRN + NSYSLEO);
243 const int MAXSTA = 255;
312 const int ARMODE_WLNL = 6;
313 const int ARMODE_TCAR = 7;
323 #define STR_MODE_R 0x1 324 #define STR_MODE_W 0x2 325 #define STR_MODE_RW 0x3 333 #define STR_NTRIPSVR 6 334 #define STR_NTRIPCLI 7 338 #define NP_PPP(opt) ((opt)->dynamics ? 9 : 3) 339 #define IC_PPP(s, opt) (NP_PPP(opt) + (s)) 340 #define IT_PPP(opt) (IC_PPP(0, opt) + NSYS) 341 #define NR_PPP(opt) (IT_PPP(opt) + ((opt)->tropopt < TROPOPT_EST ? 0 : ((opt)->tropopt == TROPOPT_EST ? 1 : 3))) 342 #define IB_PPP(s, opt) (NR_PPP(opt) + (s)-1) 343 #define NX_PPP(opt) (IB_PPP(MAXSAT, opt) + 1) 346 #define NF_RTK(opt) ((opt)->ionoopt == IONOOPT_IFLC ? 1 : (opt)->nf) 347 #define NP_RTK(opt) ((opt)->dynamics == 0 ? 3 : 9) 348 #define NI_RTK(opt) ((opt)->ionoopt != IONOOPT_EST ? 0 : MAXSAT) 349 #define NT_RTK(opt) ((opt)->tropopt < TROPOPT_EST ? 0 : ((opt)->tropopt < TROPOPT_ESTG ? 2 : 6)) 350 #define NL_RTK(opt) ((opt)->glomodear != 2 ? 0 : NFREQGLO) 351 #define NB_RTK(opt) ((opt)->mode <= PMODE_DGPS ? 0 : MAXSAT * NF_RTK(opt)) 352 #define NR_RTK(opt) (NP_RTK(opt) + NI_RTK(opt) + NT_RTK(opt) + NL_RTK(opt)) 353 #define NX_RTK(opt) (NR_RTK(opt) + NB_RTK(opt)) 365 unsigned char sat, rcv;
405 double off[
NFREQ][3];
406 double var[
NFREQ][19];
426 double A, e, i0, OMG0, omg, M0, OMGd;
443 double A, e, i0, OMG0, omg, M0, deln, OMGd, idot;
444 double crc, crs, cuc, cus, cic, cis;
454 float has_clock_correction_m;
455 float has_orbit_radial_correction_m;
456 float has_orbit_in_track_correction_m;
457 float has_orbit_cross_track_correction_m;
458 bool apply_has_corrections;
482 double pos[MAXSAT][4];
483 float std[MAXSAT][4];
484 double vel[MAXSAT][4];
485 float vst[MAXSAT][4];
486 float cov[MAXSAT][3];
487 float vco[MAXSAT][3];
495 double clk[MAXSAT][1];
496 float std[MAXSAT][1];
560 double bias[MAXSAT][3];
561 double std[MAXSAT][3];
569 unsigned char msg[29];
671 double yaw_ang, yaw_rate;
672 unsigned char update;
684 unsigned char msg[212];
700 unsigned char health;
743 char stas[MAXSTA][8];
744 double rr[MAXSTA][3];
745 int ns[MAXSTA], nsmax[MAXSTA];
746 int nt[MAXSTA], ntmax[MAXSTA];
784 double lam[MAXSAT][
NFREQ];
785 double cbias[MAXSAT][3];
786 double rbias[
MAXRCV][2][3];
787 double wlbias[MAXSAT];
788 double glo_cpbias[4];
862 unsigned short slipc;
889 char msmtype[6][128];
899 unsigned char buff[1200];
901 unsigned int nmsg2[100];
902 unsigned int nmsg3[400];
928 double cerr[4][
NFREQ * 2];
929 double perr[4][
NFREQ * 2];
930 double gpsglob[
NFREQ];
931 double gloicb[
NFREQ];
938 double mask[
NFREQ][9];
971 double eratio[
NFREQ];
992 unsigned char exsats[MAXSAT];
999 double odisp[2][6 * 11];
1037 unsigned char vsat[
NFREQ];
1038 unsigned char snr[
NFREQ];
1039 unsigned char fix[
NFREQ];
1040 unsigned char slip[
NFREQ];
1041 unsigned char half[
NFREQ];
1043 unsigned int outc[
NFREQ];
1044 unsigned int slipc[
NFREQ];
1045 unsigned int rejc[
NFREQ];
1051 double ph[2][
NFREQ];
1087 unsigned char valid;
1099 unsigned int inb, inr;
1100 unsigned int outb, outr;
1101 unsigned int tick, tact;
1102 unsigned int inbt, outbt;
1120 FILE *fp_tag =
nullptr;
1121 FILE *fp_tmp =
nullptr;
1122 FILE *fp_tag_tmp =
nullptr;
1124 std::string openpath;
1131 unsigned int tick = 0;
1132 unsigned int tick_f = 0;
1133 unsigned int fpos = 0;
1136 double swapintv = 0;
1146 struct sockaddr_in addr;
1178 char str[NTRIP_MAXSTR];
1179 unsigned char buff[NTRIP_MAXRSP];
1212 unsigned char subfrm[MAXSAT][380];
1215 double icpp[MAXSAT], off[MAXSAT], icpc;
1216 double prCA[MAXSAT], dpCA[MAXSAT];
1228 double receive_time;
1234 unsigned char pbuff[255 + 4 + 2];
1255 unsigned char *buff[3];
1256 unsigned char *sbuf[2];
1257 unsigned char *pbuf[3];
1259 unsigned int nmsg[3][10];
1279 unsigned char time_s;
1280 unsigned char clk_str;
1281 unsigned char clk_ext;
1282 unsigned char smooth;
1283 unsigned char tint_s;
1284 unsigned char nsat, nsig;
1285 unsigned char sats[64];
1286 unsigned char sigs[32];
1287 unsigned char cellmask[64];
1291 const double CHISQR[100] = {
1292 10.8, 13.8, 16.3, 18.5, 20.5, 22.5, 24.3, 26.1, 27.9, 29.6,
1293 31.3, 32.9, 34.5, 36.1, 37.7, 39.3, 40.8, 42.3, 43.8, 45.3,
1294 46.8, 48.3, 49.7, 51.2, 52.6, 54.1, 55.5, 56.9, 58.3, 59.7,
1295 61.1, 62.5, 63.9, 65.2, 66.6, 68.0, 69.3, 70.7, 72.1, 73.4,
1296 74.7, 76.0, 77.3, 78.6, 80.0, 81.3, 82.6, 84.0, 85.4, 86.7,
1297 88.0, 89.3, 90.6, 91.9, 93.3, 94.7, 96.0, 97.4, 98.7, 100,
1298 101, 102, 103, 104, 105, 107, 108, 109, 110, 112,
1299 113, 114, 115, 116, 118, 119, 120, 122, 123, 125,
1300 126, 127, 128, 129, 131, 132, 133, 134, 135, 137,
1301 138, 139, 140, 142, 143, 144, 145, 147, 148, 149};
1304 const double LAM_CARR[
MAXFREQ] = {
1308 const int STRFMT_RTCM2 = 0;
1309 const int STRFMT_RTCM3 = 1;
1310 const int STRFMT_SP3 = 16;
1311 const int STRFMT_RNXCLK = 17;
1312 const int STRFMT_SBAS = 18;
1313 const int STRFMT_NMEA = 19;
1316 const int MAXSTRRTK = 8;
1320 #endif // GNSS_SDR_RTKLIB_H const double ERR_CBIAS
code bias error std (m)
const double EFACT_GPS
error factor: GPS
constexpr double FREQ1
L1/E1 frequency (Hz)
const int ARMODE_CONT
AR mode: continuous.
const int MINPRNLEO
min satellite sat number of LEO
const double GAP_RESION
default gap to reset ionos parameters (ep)
const int SOLQ_NONE
solution status: no solution
const int NFREQ
number of carrier frequencies
const int PMODE_SINGLE
positioning mode: single
const int MINPRNIRN
min satellite sat number of IRNSS
const double EFACT_SBS
error factor: SBAS
const int SOLQ_FIX
solution status: fix
const int PMODE_PPP_STATIC
positioning mode: PPP-static
const int SOLF_XYZ
solution format: x/y/z-ecef
const int MINPRNQZS
min satellite PRN number of QZSS
const int PMODE_PPP_KINEMA
positioning mode: PPP-kinemaric
const int MAXCLI
max client connection for tcp svr
const int TIMES_JST
time system: jst
const double FE_WGS84
earth flattening (WGS84)
const int NSATGAL
number of Galileo satellites
const double REL_HUMI
relative humidity for saastamoinen model
const int NSATSBS
number of SBAS satellites
const double EFACT_IRN
error factor: IRNSS
const double INT_SWAP_TRAC
swap interval of trace file (s)
const int SOLF_ENU
solution format: e/n/u-baseline
const int TROPOPT_SAAS
troposphere option: Saastamoinen model
const int MAXPRNGAL
max satellite PRN number of Galileo
const double EFACT_QZS
error factor: QZSS
const int PMODE_FIXED
positioning mode: fixed
const int TROPOPT_EST
troposphere option: ZTD estimation
const int SYS_ALL
navigation system: all
const int SYS_BDS
navigation system: BeiDou
const int TROPOPT_ESTG
troposphere option: ZTD+grad estimation
const double PRN_HWBIAS
process noise of h/w bias (m/MHz/sqrt(s))
const int FTP_TIMEOUT
ftp/http timeout (s)
const int SOLF_STAT
solution format: solution status
const int MAXSTATMSG
max length of status message
const int MAXPRNGPS
max satellite PRN number of GPS
const int SOLF_LLH
solution format: lat/lon/height
const int ARMODE_INST
AR mode: instantaneous.
const int IONOOPT_OFF
ionosphere option: correction off
const int PMODE_MOVEB
positioning mode: moving-base
const int MAXPRNLEO
max satellite sat number of LEO */
const int EPHOPT_SBAS
ephemeris option: broadcast + SBAS
const int IONOOPT_TEC
ionosphere option: IONEX TEC model
const int EPHOPT_SSRCOM
ephemeris option: broadcast + SSR_COM
const double INT_SWAP_STAT
swap interval of solution status file (s)
constexpr double FREQ6
E6/LEX frequency (Hz)
const int IONOOPT_SBAS
ionosphere option: SBAS model
const int IONOOPT_LEX
ionosphere option: QZSS LEX ionospehre
const double MAXDTOE
max time difference to GPS Toe (s)
const int SOLQ_DR
solution status: dead reckoning
const int NFREQGLO
number of carrier frequencies of GLONASS
const double MAXSBSAGEL
max age of SBAS long term corr (s)
const int MAXERRMSG
max length of error/warning message
const int PMODE_STATIC
positioning mode: static
const int MINPRNSBS
min satellite PRN number of SBAS
const int MAXSOLQ
max number of solution status
const int MAXSOLBUF
max number of solution buffer
const int MINPRNGPS
min satellite PRN number of GPS
const int EPHOPT_BRDC
ephemeris option: broadcast ephemeris
constexpr double FREQ5
L5/E5a frequency (Hz)
constexpr double FREQ7
E5b frequency (Hz)
const int TINTACT
period for stream active (ms)
const int MAXFREQ
max NFREQ
const int ARMODE_OFF
AR mode: off.
const int SOLF_NMEA
solution format: NMEA-183
const int MINPRNGAL
min satellite PRN number of Galileo
const double MAXDTOE_BDS
max time difference to BeiDou Toe (s)
const int MAXOBS
max number of obs in an epoch
const double MAXDTOE_QZS
max time difference to QZSS Toe (s)
const int MAXSOLMSG
max length of solution message
Defines useful mathematical constants and their scaled versions.
const int TIMES_GPST
time system: gps time
const double ERR_BRDCI
broadcast iono model error factor
const double MAXDTOE_GAL
max time difference to Galileo Toe (s)
const int MAXPRNQZS
max satellite PRN number of QZSS
const int SOLQ_DGPS
solution status: DGPS/DGNSS
const double HION
ionosphere height (m)
const int MAXOBSTYPE
max number of obs type in RINEX
const int TIMETAGH_LEN
time tag file header length
const int MINPRNBDS
min satellite sat number of BeiDou
const int MAXLEAPS
max number of leap seconds table
const int MAXRCV
max receiver number (1 to MAXRCV)
const int SOLF_GSIF
solution format: GSI F1/F2
const int MAXPRNSBS
max satellite PRN number of SBAS
const int MAXBAND
max SBAS band of IGP
const int NSATGPS
number of GPS satellites
const int EPHOPT_SSRAPC
ephemeris option: broadcast + SSR_APC
constexpr int32_t MAXCODE
max number of obs code
constexpr double FREQ2
L2 frequency (Hz)
const int MAXRAWLEN
max length of receiver raw message
const int SYS_IRN
navigation system: IRNS
const int ARMODE_PPPAR_ILS
AR mode: AR mode: PPP-AR ILS.
const int NSATBDS
number of BeiDou satellites
const int MAXSBSMSG
max number of SBAS msg in RTK server
const int IONOOPT_QZS
ionosphere option: QZSS broadcast model
const int SYS_GAL
navigation system: Galileo
const int MAXSBSURA
max URA of SBAS satellite
const int IONOOPT_STEC
ionosphere option: SLANT TEC model
const double MAXGDOP
max GDOP
const int IONOOPT_IFLC
ionosphere option: L1/L2 or L1/L5 iono-free LC
const int SYS_QZS
navigation system: QZSS
const unsigned int POLYCRC32
CRC32 polynomial.
const int SERIBUFFSIZE
serial buffer size (bytes)
constexpr double FREQ8
E5a+b frequency (Hz)
const int MAXPRNGLO
max satellite slot number of GLONASS
const double MAXDTOE_GLO
max time difference to GLONASS Toe (s)
const int SOLQ_SINGLE
solution status: single
const int TROPOPT_COR
troposphere option: ZTD correction
const int MAXNGEO
max number of GEO satellites
const int NSATGLO
number of GLONASS satellites
const int SYS_SBS
navigation system: SBAS
const int ARMODE_PPPAR
AR mode: PPP-AR.
const int MAXPRNBDS
max satellite sat number of BeiDou
const int EPHOPT_PREC
ephemeris option: precise ephemeris
void(const char *) fatalfunc_t
fatal callback function type
const double EFACT_GLO
error factor: GLONASS
const int MINPRNGLO
min satellite slot number of GLONASS
const int SYS_LEO
navigation system: LEO
const double RE_WGS84
earth semimajor axis (WGS84) (m)
const int PMODE_DGPS
positioning mode: DGPS/DGNSS
const int EPHOPT_LEX
ephemeris option: QZSS LEX ephemeris
const int MAXNIGP
max number of IGP in SBAS band
const int IONOOPT_BRDC
ionosphere option: broadcast model
const int MAXPRNIRN
max satellite sat number of IRNSS
const double MAXSBSAGEF
max age of SBAS fast correction (s)
const int SOLQ_PPP
solution status: PPP
const int SYS_GLO
navigation system: GLONASS
const int SOLQ_FLOAT
solution status: float
const double EFACT_BDS
error factor: BeiDou
const int TROPOPT_OFF
troposphere option: correction off
const int PMODE_PPP_FIXED
positioning mode: PPP-fixed
const int MAXOBSBUF
max number of observation data buffer
const int SYS_GPS
navigation system: GPS
const double EFACT_GAL
error factor: Galileo
const double MAXDTOE_SBS
max time difference to SBAS Toe (s)
const double MAXDTOE_S
max time difference to ephem toe (s) for other
const int ARMODE_FIXHOLD
AR mode: fix and hold.
const int SOLQ_SBAS
solution status: SBAS
const int MAXANT
max length of station name/antenna type
const int PMODE_KINEMA
positioning mode: kinematic
const int MAXSTRPATH
max length of stream path
const int MAXSTRMSG
max length of stream message
constexpr double SPEED_OF_LIGHT_M_S
Speed of light in vacuum [m/s].
const double ERR_SAAS
saastamoinen model error std (m)
const int NEXOBS
number of extended obs codes
const int MAXEXFILE
max number of expanded files
const int TROPOPT_CORG
troposphere option: ZTD+grad correction
const double DTTOL
tolerance of time difference (s)
const int TROPOPT_SBAS
troposphere option: SBAS model
const int IONOOPT_EST
ionosphere option: estimation
const unsigned int POLYCRC24Q
CRC24Q polynomial.
const int SYS_NONE
navigation system: none
const int NSYS
number of systems
constexpr double FREQ9
S frequency (Hz)
const int TIMES_UTC
time system: utc
const int POSOPT_RINEX
pos option: rinex header pos