GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
rtklib_rtkcmn.h
Go to the documentation of this file.
1/*!
2 * \file rtklib_rtkcmn.h
3 * \brief rtklib common functions
4 * \authors <ul>
5 * <li> 2007-2013, T. Takasu
6 * <li> 2017, Javier Arribas
7 * <li> 2017, Carles Fernandez
8 * </ul>
9 *
10 * This is a derived work from RTKLIB http://www.rtklib.com/
11 * The original source code at https://github.com/tomojitakasu/RTKLIB is
12 * released under the BSD 2-clause license with an additional exclusive clause
13 * that does not apply here. This additional clause is reproduced below:
14 *
15 * " The software package includes some companion executive binaries or shared
16 * libraries necessary to execute APs on Windows. These licenses succeed to the
17 * original ones of these software. "
18 *
19 * Neither the executive binaries nor the shared libraries are required by, used
20 * or included in GNSS-SDR.
21 *
22 * -----------------------------------------------------------------------------
23 * Copyright (C) 2007-2013, T. Takasu
24 * Copyright (C) 2017, Javier Arribas
25 * Copyright (C) 2017, Carles Fernandez
26 * All rights reserved.
27 *
28 * SPDX-License-Identifier: BSD-2-Clause
29 *
30 *
31 * References :
32 * [1] IS-GPS-200M, Navstar GPS Space Segment/Navigation User Interfaces,
33 * May, 2021
34 * [2] RTCA/DO-229C, Minimum operational performance standards for global
35 * positioning system/wide area augmentation system airborne equipment,
36 * RTCA inc, November 28, 2001
37 * [3] M.Rothacher, R.Schmid, ANTEX: The Antenna Exchange Format Version 1.4,
38 * 15 September, 2010
39 * [4] A.Gelb ed., Applied Optimal Estimation, The M.I.T Press, 1974
40 * [5] A.E.Niell, Global mapping functions for the atmosphere delay at radio
41 * wavelengths, Journal of geophysical research, 1996
42 * [6] W.Gurtner and L.Estey, RINEX The Receiver Independent Exchange Format
43 * Version 3.00, November 28, 2007
44 * [7] J.Kouba, A Guide to using International GNSS Service (IGS) products,
45 * May 2009
46 * [8] China Satellite Navigation Office, BeiDou navigation satellite system
47 * signal in space interface control document, open service signal B1I
48 * (version 1.0), Dec 2012
49 * [9] J.Boehm, A.Niell, P.Tregoning and H.Shuh, Global Mapping Function
50 * (GMF): A new empirical mapping function base on numerical weather
51 * model data, Geophysical Research Letters, 33, L07304, 2006
52 * [10] GLONASS/GPS/Galileo/Compass/SBAS NV08C receiver series BINR interface
53 * protocol specification ver.1.3, August, 2012
54 *
55 * -----------------------------------------------------------------------------
56 */
57
58#ifndef GNSS_SDR_RTKLIB_RTKCMN_H
59#define GNSS_SDR_RTKLIB_RTKCMN_H
60
61#include "rtklib.h"
62#include <cstddef>
63#include <string>
64
65#if HAS_STD_FILESYSTEM
66#include <system_error>
67namespace errorlib = std;
68#if HAS_STD_FILESYSTEM_EXPERIMENTAL
69#include <experimental/filesystem>
70namespace fs = std::experimental::filesystem;
71#else
72#include <filesystem>
73namespace fs = std::filesystem;
74#endif
75#else
76#include <boost/filesystem/operations.hpp> // for create_directories, exists
77#include <boost/filesystem/path.hpp> // for path, operator<<
78#include <boost/filesystem/path_traits.hpp> // for filesystem
79#include <boost/system/error_code.hpp> // for error_code
80namespace fs = boost::filesystem;
81namespace errorlib = boost::system;
82#endif
83
84/* coordinate rotation matrix ------------------------------------------------*/
85#define Rx(t, X) \
86 do \
87 { \
88 (X)[0] = 1.0; \
89 (X)[1] = (X)[2] = (X)[3] = (X)[6] = 0.0; \
90 (X)[4] = (X)[8] = cos(t); \
91 (X)[7] = sin(t); \
92 (X)[5] = -(X)[7]; \
93 } \
94 while (0)
95
96#define Ry(t, X) \
97 do \
98 { \
99 (X)[4] = 1.0; \
100 (X)[1] = (X)[3] = (X)[5] = (X)[7] = 0.0; \
101 (X)[0] = (X)[8] = cos(t); \
102 (X)[2] = sin(t); \
103 (X)[6] = -(X)[2]; \
104 } \
105 while (0)
106
107#define Rz(t, X) \
108 do \
109 { \
110 (X)[8] = 1.0; \
111 (X)[2] = (X)[5] = (X)[6] = (X)[7] = 0.0; \
112 (X)[0] = (X)[4] = cos(t); \
113 (X)[3] = sin(t); \
114 (X)[1] = -(X)[3]; \
115 } \
116 while (0)
117
118char *strncpy_no_trunc(char *out, size_t outsz, const char *in, size_t insz);
119void fatalerr(const char *format, ...);
120int satno(int sys, int prn);
121int satsys(int sat, int *prn);
122int satid2no(const char *id);
123std::string satno2id(int sat);
124int satexclude(int sat, int svh, const prcopt_t *opt);
125int testsnr(int base, int freq, double el, double snr, const snrmask_t *mask);
126unsigned char obs2code(const char *obs, int *freq);
127char *code2obs(unsigned char code, int *freq);
128void setcodepri(int sys, int freq, const char *pri);
129int getcodepri(int sys, unsigned char code, const char *opt);
130unsigned int getbitu(const unsigned char *buff, int pos, int len);
131int getbits(const unsigned char *buff, int pos, int len);
132void setbitu(unsigned char *buff, int pos, int len, unsigned int data);
133void setbits(unsigned char *buff, int pos, int len, int data);
134unsigned int rtk_crc32(const unsigned char *buff, int len);
135unsigned int rtk_crc24q(const unsigned char *buff, int len);
136unsigned short rtk_crc16(const unsigned char *buff, int len);
137int decode_word(unsigned int word, unsigned char *data);
138double *mat(int n, int m);
139int *imat(int n, int m);
140double *zeros(int n, int m);
141double *eye(int n);
142double dot(const double *a, const double *b, int n);
143double norm_rtk(const double *a, int n);
144void cross3(const double *a, const double *b, double *c);
145int normv3(const double *a, double *b);
146void matcpy(double *A, const double *B, int n, int m);
147void matmul(const char *tr, int n, int k, int m, double alpha,
148 const double *A, const double *B, double beta, double *C);
149int matinv(double *A, int n);
150int solve(const char *tr, const double *A, const double *Y, int n,
151 int m, double *X);
152int lsq(const double *A, const double *y, int n, int m, double *x,
153 double *Q);
154int filter_(const double *x, const double *P, const double *H,
155 const double *v, const double *R, int n, int m,
156 double *xp, double *Pp);
157int filter(double *x, double *P, const double *H, const double *v,
158 const double *R, int n, int m);
159int smoother(const double *xf, const double *Qf, const double *xb,
160 const double *Qb, int n, double *xs, double *Qs);
161void matfprint(const double A[], int n, int m, int p, int q, FILE *fp);
162void matsprint(const double A[], int n, int m, int p, int q, std::string &buffer);
163void matprint(const double A[], int n, int m, int p, int q);
164double str2num(const char *s, int i, int n);
165int str2time(const char *s, int i, int n, gtime_t *t);
166gtime_t epoch2time(const double *ep);
167void time2epoch(gtime_t t, double *ep);
168gtime_t gpst2time(int week, double sec);
169double time2gpst(gtime_t t, int *week);
170gtime_t gst2time(int week, double sec);
171double time2gst(gtime_t t, int *week);
172gtime_t bdt2time(int week, double sec);
173double time2bdt(gtime_t t, int *week);
174gtime_t timeadd(gtime_t t, double sec);
175double timediff(gtime_t t1, gtime_t t2);
176double timediffweekcrossover(gtime_t t1, gtime_t t2);
177gtime_t timeget();
178void timeset(gtime_t t);
179int read_leaps_text(FILE *fp);
180int read_leaps_usno(FILE *fp);
181int read_leaps(const char *file);
182gtime_t gpst2utc(gtime_t t);
183gtime_t utc2gpst(gtime_t t);
184gtime_t gpst2bdt(gtime_t t);
185gtime_t bdt2gpst(gtime_t t);
186double time2sec(gtime_t time, gtime_t *day);
187double utc2gmst(gtime_t t, double ut1_utc);
188void time2str(gtime_t t, char *s, int n);
189char *time_str(gtime_t t, int n);
190double time2doy(gtime_t t);
191int adjgpsweek(int week, bool pre_2009_file = false);
192unsigned int tickget();
193void sleepms(int ms);
194void deg2dms(double deg, double *dms, int ndec);
195void deg2dms(double deg, double *dms);
196double dms2deg(const double *dms);
197void ecef2pos(const double *r, double *pos);
198void pos2ecef(const double *pos, double *r);
199void xyz2enu(const double *pos, double *E);
200void ecef2enu(const double *pos, const double *r, double *e);
201void enu2ecef(const double *pos, const double *e, double *r);
202void covenu(const double *pos, const double *P, double *Q);
203void covecef(const double *pos, const double *Q, double *P);
204void ast_args(double t, double *f);
205void nut_iau1980(double t, const double *f, double *dpsi, double *deps);
206void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst);
207int decodef(char *p, int n, double *v);
208void addpcv(const pcv_t *pcv, pcvs_t *pcvs);
209int readngspcv(const char *file, pcvs_t *pcvs);
210int readantex(const char *file, pcvs_t *pcvs);
211int readpcv(const char *file, pcvs_t *pcvs);
212pcv_t *searchpcv(int sat, const char *type, gtime_t time,
213 const pcvs_t *pcvs);
214void readpos(const char *file, const char *rcv, double *pos);
215int readblqrecord(FILE *fp, double *odisp);
216int readblq(const char *file, const char *sta, double *odisp);
217int readerp(const char *file, erp_t *erp);
218int geterp(const erp_t *erp, gtime_t time, double *erpv);
219int cmpeph(const void *p1, const void *p2);
220void uniqeph(nav_t *nav);
221int cmpgeph(const void *p1, const void *p2);
222void uniqgeph(nav_t *nav);
223int cmpseph(const void *p1, const void *p2);
224void uniqseph(nav_t *nav);
225void uniqnav(nav_t *nav);
226int cmpobs(const void *p1, const void *p2);
227int sortobs(obs_t *obs);
228int screent(gtime_t time, gtime_t ts, gtime_t te, double tint);
229int readnav(const char *file, nav_t *nav);
230int savenav(const char *file, const nav_t *nav);
231void freeobs(obs_t *obs);
232void freenav(nav_t *nav, int opt);
233
234void traceopen(const char *file);
235void traceclose();
236void tracelevel(int level);
237void traceswap();
238void trace(int level, const char *format, ...);
239void tracet(int level, const char *format, ...);
240void tracemat(int level, const double *A, int n, int m, int p, int q);
241void traceobs(int level, const obsd_t *obs, int n);
242// void tracenav(int level, const nav_t *nav);
243// void tracegnav(int level, const nav_t *nav);
244// void tracehnav(int level, const nav_t *nav);
245// void tracepeph(int level, const nav_t *nav);
246// void tracepclk(int level, const nav_t *nav);
247// void traceb (int level, const unsigned char *p, int n);
248
249int execcmd(const char *cmd);
250void createdir(fs::path const &path);
251int reppath(std::string const &path, std::string &rpath, gtime_t time, const char *rov,
252 const char *base);
253double satwavelen(int sat, int frq, const nav_t *nav);
254double geodist(const double *rs, const double *rr, double *e);
255double satazel(const double *pos, const double *e, double *azel);
256
257void dops(int ns, const double *azel, double elmin, double *dop);
258double ionmodel(gtime_t t, const double *ion, const double *pos,
259 const double *azel);
260double ionmapf(const double *pos, const double *azel);
261double ionppp(const double *pos, const double *azel, double re,
262 double hion, double *posp);
263double tropmodel(gtime_t time, const double *pos, const double *azel,
264 double humi);
265double interpc(const double coef[], double lat);
266double mapf(double el, double a, double b, double c);
267double nmf(gtime_t time, const double pos[], const double azel[],
268 double *mapfw);
269double tropmapf(gtime_t time, const double pos[], const double azel[],
270 double *mapfw);
271double interpvar(double ang, const double *var);
272
273void antmodel(const pcv_t *pcv, const double *del, const double *azel,
274 int opt, double *dant);
275
276void antmodel_s(const pcv_t *pcv, double nadir, double *dant);
277void sunmoonpos_eci(gtime_t tut, double *rsun, double *rmoon);
278void sunmoonpos(gtime_t tutc, const double *erpv, double *rsun,
279 double *rmoon, double *gmst);
280void csmooth(obs_t *obs, int ns);
281int rtk_uncompress(const char *file, char *uncfile);
282int expath(const char *path, char *paths[], int nmax);
283void windupcorr(gtime_t time, const double *rs, const double *rr, double *phw);
284
285#endif // GNSS_SDR_RTKLIB_RTKCMN_H
STL namespace.
main header file for the rtklib library