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;
196 const int NSYSQZS = 1;
200 const int NSYSQZS = 0;
208 const int NSYSBDS = 1;
213 const int NSYSBDS = 0;
220 const int NSYSIRN = 1;
222 const int NSATIRN = 0;
223 const int NSYSIRN = 0;
230 const int NSYSLEO = 1;
232 const int NSATLEO = 0;
233 const int NSYSLEO = 0;
236 const int NSYS = (NSYSGPS + NSYSGLO + NSYSGAL + NSYSQZS + NSYSBDS + NSYSIRN + NSYSLEO);
244 const int MAXSTA = 255;
313 const int ARMODE_WLNL = 6;
314 const int ARMODE_TCAR = 7;
324 #define STR_MODE_R 0x1 325 #define STR_MODE_W 0x2 326 #define STR_MODE_RW 0x3 334 #define STR_NTRIPSVR 6 335 #define STR_NTRIPCLI 7 339 #define NP_PPP(opt) ((opt)->dynamics ? 9 : 3) 340 #define IC_PPP(s, opt) (NP_PPP(opt) + (s)) 341 #define IT_PPP(opt) (IC_PPP(0, opt) + NSYS) 342 #define NR_PPP(opt) (IT_PPP(opt) + ((opt)->tropopt < TROPOPT_EST ? 0 : ((opt)->tropopt == TROPOPT_EST ? 1 : 3))) 343 #define IB_PPP(s, opt) (NR_PPP(opt) + (s)-1) 344 #define NX_PPP(opt) (IB_PPP(MAXSAT, opt) + 1) 347 #define NF_RTK(opt) ((opt)->ionoopt == IONOOPT_IFLC ? 1 : (opt)->nf) 348 #define NP_RTK(opt) ((opt)->dynamics == 0 ? 3 : 9) 349 #define NI_RTK(opt) ((opt)->ionoopt != IONOOPT_EST ? 0 : MAXSAT) 350 #define NT_RTK(opt) ((opt)->tropopt < TROPOPT_EST ? 0 : ((opt)->tropopt < TROPOPT_ESTG ? 2 : 6)) 351 #define NL_RTK(opt) ((opt)->glomodear != 2 ? 0 : NFREQGLO) 352 #define NB_RTK(opt) ((opt)->mode <= PMODE_DGPS ? 0 : MAXSAT * NF_RTK(opt)) 353 #define NR_RTK(opt) (NP_RTK(opt) + NI_RTK(opt) + NT_RTK(opt) + NL_RTK(opt)) 354 #define NX_RTK(opt) (NR_RTK(opt) + NB_RTK(opt)) 366 unsigned char sat, rcv;
406 double off[
NFREQ][3];
407 double var[
NFREQ][19];
427 double A, e, i0, OMG0, omg, M0, OMGd;
444 double A, e, i0, OMG0, omg, M0, deln, OMGd, idot;
445 double crc, crs, cuc, cus, cic, cis;
455 float has_clock_correction_m;
456 float has_orbit_radial_correction_m;
457 float has_orbit_in_track_correction_m;
458 float has_orbit_cross_track_correction_m;
459 bool apply_has_corrections;
483 double pos[MAXSAT][4];
484 float std[MAXSAT][4];
485 double vel[MAXSAT][4];
486 float vst[MAXSAT][4];
487 float cov[MAXSAT][3];
488 float vco[MAXSAT][3];
496 double clk[MAXSAT][1];
497 float std[MAXSAT][1];
561 double bias[MAXSAT][3];
562 double std[MAXSAT][3];
570 unsigned char msg[29];
672 double yaw_ang, yaw_rate;
673 unsigned char update;
685 unsigned char msg[212];
701 unsigned char health;
744 char stas[MAXSTA][8];
745 double rr[MAXSTA][3];
746 int ns[MAXSTA], nsmax[MAXSTA];
747 int nt[MAXSTA], ntmax[MAXSTA];
785 double lam[MAXSAT][
NFREQ];
786 double cbias[MAXSAT][3];
787 double rbias[
MAXRCV][2][3];
788 double wlbias[MAXSAT];
789 double glo_cpbias[4];
863 unsigned short slipc;
890 char msmtype[6][128];
900 unsigned char buff[1200];
902 unsigned int nmsg2[100];
903 unsigned int nmsg3[400];
929 double cerr[4][
NFREQ * 2];
930 double perr[4][
NFREQ * 2];
931 double gpsglob[
NFREQ];
932 double gloicb[
NFREQ];
939 double mask[
NFREQ][9];
972 double eratio[
NFREQ];
993 unsigned char exsats[MAXSAT];
1000 double odisp[2][6 * 11];
1038 unsigned char vsat[
NFREQ];
1039 unsigned char snr[
NFREQ];
1040 unsigned char fix[
NFREQ];
1041 unsigned char slip[
NFREQ];
1042 unsigned char half[
NFREQ];
1044 unsigned int outc[
NFREQ];
1045 unsigned int slipc[
NFREQ];
1046 unsigned int rejc[
NFREQ];
1052 double ph[2][
NFREQ];
1088 unsigned char valid;
1100 unsigned int inb, inr;
1101 unsigned int outb, outr;
1102 unsigned int tick, tact;
1103 unsigned int inbt, outbt;
1121 FILE *fp_tag =
nullptr;
1122 FILE *fp_tmp =
nullptr;
1123 FILE *fp_tag_tmp =
nullptr;
1125 std::string openpath;
1132 unsigned int tick = 0;
1133 unsigned int tick_f = 0;
1134 unsigned int fpos = 0;
1137 double swapintv = 0;
1147 struct sockaddr_in addr;
1179 char str[NTRIP_MAXSTR];
1180 unsigned char buff[NTRIP_MAXRSP];
1213 unsigned char subfrm[MAXSAT][380];
1216 double icpp[MAXSAT], off[MAXSAT], icpc;
1217 double prCA[MAXSAT], dpCA[MAXSAT];
1229 double receive_time;
1235 unsigned char pbuff[255 + 4 + 2];
1256 unsigned char *buff[3];
1257 unsigned char *sbuf[2];
1258 unsigned char *pbuf[3];
1260 unsigned int nmsg[3][10];
1280 unsigned char time_s;
1281 unsigned char clk_str;
1282 unsigned char clk_ext;
1283 unsigned char smooth;
1284 unsigned char tint_s;
1285 unsigned char nsat, nsig;
1286 unsigned char sats[64];
1287 unsigned char sigs[32];
1288 unsigned char cellmask[64];
1292 const double CHISQR[100] = {
1293 10.8, 13.8, 16.3, 18.5, 20.5, 22.5, 24.3, 26.1, 27.9, 29.6,
1294 31.3, 32.9, 34.5, 36.1, 37.7, 39.3, 40.8, 42.3, 43.8, 45.3,
1295 46.8, 48.3, 49.7, 51.2, 52.6, 54.1, 55.5, 56.9, 58.3, 59.7,
1296 61.1, 62.5, 63.9, 65.2, 66.6, 68.0, 69.3, 70.7, 72.1, 73.4,
1297 74.7, 76.0, 77.3, 78.6, 80.0, 81.3, 82.6, 84.0, 85.4, 86.7,
1298 88.0, 89.3, 90.6, 91.9, 93.3, 94.7, 96.0, 97.4, 98.7, 100,
1299 101, 102, 103, 104, 105, 107, 108, 109, 110, 112,
1300 113, 114, 115, 116, 118, 119, 120, 122, 123, 125,
1301 126, 127, 128, 129, 131, 132, 133, 134, 135, 137,
1302 138, 139, 140, 142, 143, 144, 145, 147, 148, 149};
1305 const double LAM_CARR[
MAXFREQ] = {
1309 const int STRFMT_RTCM2 = 0;
1310 const int STRFMT_RTCM3 = 1;
1311 const int STRFMT_SP3 = 16;
1312 const int STRFMT_RNXCLK = 17;
1313 const int STRFMT_SBAS = 18;
1314 const int STRFMT_NMEA = 19;
1317 const int MAXSTRRTK = 8;
1321 #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)
const int MAXPRNQZS_S
max satellite PRN number of QZSS SAIF
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 MINPRNQZS_S
min satellite PRN number of QZSS SAIF
const int MAXERRMSG
max length of error/warning message
const int PMODE_STATIC
positioning mode: static
const int NSATQZS
number of QZSS satellites
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