MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_rtksvr.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_rtksvr.h : real-time RTK server type definitions and functions
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 * Copyright (C) 2023-2025 Cabinet Office, Japan
6 * Copyright (C) 2024-2025 Lighthouse Technology & Consulting Co. Ltd.
7 * Copyright (C) 2023-2025 Japan Aerospace Exploration Agency
8 * Copyright (C) 2023-2025 TOSHIBA ELECTRONIC TECHNOLOGIES CORPORATION
9 * Copyright (C) 2015- Mitsubishi Electric Corp.
10 * Copyright (C) 2014 Geospatial Information Authority of Japan
11 * Copyright (C) 2014 T.SUZUKI
12 * Copyright (C) 2007-2023 T.TAKASU
13 *
14 * SPDX-License-Identifier: BSD-2-Clause
15 *----------------------------------------------------------------------------*/
16/**
17 * @file mrtk_rtksvr.h
18 * @brief MRTKLIB RTK Server Module — real-time positioning server.
19 *
20 * This header provides the rtksvr_t type and functions for managing a
21 * real-time RTK positioning server that reads receiver data streams,
22 * performs positioning computation, and outputs solutions.
23 *
24 * @note Functions declared here are implemented in mrtk_rtksvr.c.
25 */
26#ifndef MRTK_RTKSVR_H
27#define MRTK_RTKSVR_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "mrtklib/mrtk_clas.h"
36#include "mrtklib/mrtk_has.h"
37#include "mrtklib/mrtk_nav.h"
38#include "mrtklib/mrtk_obs.h"
39#include "mrtklib/mrtk_opt.h"
40#include "mrtklib/mrtk_ppp.h"
41#include "mrtklib/mrtk_rcvraw.h"
42#include "mrtklib/mrtk_rtcm.h"
43#include "mrtklib/mrtk_rtkpos.h"
44#include "mrtklib/mrtk_sol.h"
45#include "mrtklib/mrtk_stream.h"
46#include "mrtklib/mrtk_time.h"
47
48/*============================================================================
49 * RTK Server Type
50 *===========================================================================*/
51
52typedef struct { /* RTK server type */
53 int state; /* server state (0:stop,1:running) */
54 int cycle; /* processing cycle (ms) */
55 int nmeacycle; /* NMEA request cycle (ms) (0:no req) */
56 int nmeareq; /* NMEA request (0:no,1:nmeapos,2:single sol) */
57 double nmeapos[3]; /* NMEA request position (ecef) (m) */
58 int buffsize; /* input buffer size (bytes) */
59 int format[3]; /* input format {rov,base,corr} */
60 solopt_t solopt[2]; /* output solution options {sol1,sol2} */
61 int navsel; /* ephemeris select (0:all,1:rover,2:base,3:corr) */
62 int nsbs; /* number of sbas message */
63 int nsol; /* number of solution buffer */
64 rtk_t rtk; /* RTK control/result struct */
65 int nb[3]; /* bytes in input buffers {rov,base} */
66 int nsb[2]; /* bytes in soulution buffers */
67 int npb[3]; /* bytes in input peek buffers */
68 uint8_t* buff[3]; /* input buffers {rov,base,corr} */
69 uint8_t* sbuf[2]; /* output buffers {sol1,sol2} */
70 uint8_t* pbuf[3]; /* peek buffers {rov,base,corr} */
71 sol_t solbuf[MAXSOLBUF]; /* solution buffer */
72 uint32_t nmsg[3][12]; /* input message counts */
73 raw_t raw[3]; /* receiver raw control {rov,base,corr} */
74 rtcm_t rtcm[3]; /* RTCM control {rov,base,corr} */
75 sstat_t sstat; /* single stat control */
76 gtime_t ftime[3]; /* download time {rov,base,corr} */
77 char files[3][MAXSTRPATH]; /* download paths {rov,base,corr} */
78 obs_t obs[3][MAXOBSBUF]; /* observation data {rov,base,corr} */
79 nav_t nav; /* navigation data */
80 sbsmsg_t sbsmsg[MAXSBSMSG]; /* SBAS message buffer */
81 stream_t stream[8]; /* streams {rov,base,corr,sol1,sol2,logr,logb,logc} */
82 stream_t* moni; /* monitor stream */
83 uint32_t tick; /* start tick */
84 rtk_thread_t thread; /* server thread */
85 int cputime; /* CPU time (ms) for a processing cycle */
86 int prcout; /* missing observation data count */
87 int nave; /* number of averaging base pos */
88 double rb_ave[3]; /* averaging base pos */
89 char cmds_periodic[3][MAXRCVCMD]; /* periodic commands */
90 char cmd_reset[MAXRCVCMD]; /* reset command */
91 double bl_reset; /* baseline length to reset (km) */
92 rtk_lock_t lock; /* lock flag */
93 mrtk_ctx_t* ctx; /* runtime context */
94 clas_ctx_t* clas; /* CLAS CSSR decoder context (NULL if unused) */
95 has_t* has; /* Galileo HAS decoder context (NULL if unused) */
96 mdcl6d_t* mdciono; /* MADOCA-PPP L6D iono decoder contexts (MIONO_MAX_PRN, NULL if unused) */
97} rtksvr_t;
98
99/*============================================================================
100 * RTK Server Functions
101 *===========================================================================*/
102
103/**
104 * @brief Initialize RTK server.
105 * @param[in,out] svr RTK server struct
106 * @return status (0:error,1:ok)
107 */
108int rtksvrinit(rtksvr_t* svr);
109
110/**
111 * @brief Free RTK server resources.
112 * @param[in,out] svr RTK server struct
113 */
114void rtksvrfree(rtksvr_t* svr);
115
116/**
117 * @brief Start RTK server.
118 * @param[in,out] svr RTK server struct
119 * @param[in] cycle processing cycle (ms)
120 * @param[in] buffsize input buffer size (bytes)
121 * @param[in] strs stream types (8)
122 * @param[in] paths stream paths (8)
123 * @param[in] formats input formats (3)
124 * @param[in] navsel navigation select (0:all,1:rov,2:base,3:corr)
125 * @param[in] cmds startup commands (3)
126 * @param[in] cmds_periodic periodic commands (3)
127 * @param[in] rcvopts receiver options (3)
128 * @param[in] nmeacycle NMEA request cycle (ms) (0:no)
129 * @param[in] nmeareq NMEA request type (0:no,1:nmeapos,2:single)
130 * @param[in] nmeapos NMEA request position (ecef) (m) (3)
131 * @param[in] prcopt processing options
132 * @param[in] solopt solution options (2)
133 * @param[in] moni monitor stream (NULL: no monitor)
134 * @param[in] rst reset time
135 * @param[out] errmsg error message
136 * @return status (0:error,1:ok)
137 */
138int rtksvrstart(rtksvr_t* svr, int cycle, int buffsize, int* strs, char** paths, int* formats, int navsel, char** cmds,
139 char** cmds_periodic, char** rcvopts, int nmeacycle, int nmeareq, const double* nmeapos,
140 prcopt_t* prcopt, solopt_t* solopt, stream_t* moni, gtime_t rst, char* errmsg);
141
142/**
143 * @brief Stop RTK server.
144 * @param[in,out] svr RTK server struct
145 * @param[in] cmds shutdown commands (3)
146 */
147void rtksvrstop(rtksvr_t* svr, char** cmds);
148
149/**
150 * @brief Open RTK server output/log stream.
151 * @param[in,out] svr RTK server struct
152 * @param[in] index stream index
153 * @param[in] str stream type
154 * @param[in] path stream path
155 * @param[in] solopt solution options
156 * @return status (0:error,1:ok)
157 */
158int rtksvropenstr(rtksvr_t* svr, int index, int str, const char* path, const solopt_t* solopt);
159
160/**
161 * @brief Close RTK server output/log stream.
162 * @param[in,out] svr RTK server struct
163 * @param[in] index stream index
164 */
165void rtksvrclosestr(rtksvr_t* svr, int index);
166
167/**
168 * @brief Lock RTK server mutex.
169 * @param[in,out] svr RTK server struct
170 */
171void rtksvrlock(rtksvr_t* svr);
172
173/**
174 * @brief Unlock RTK server mutex.
175 * @param[in,out] svr RTK server struct
176 */
177void rtksvrunlock(rtksvr_t* svr);
178
179/**
180 * @brief Get observation data status.
181 * @param[in] svr RTK server struct
182 * @param[in] type receiver type (0:rover,1:base,2:corr)
183 * @param[out] time observation time
184 * @param[out] sat satellite numbers
185 * @param[out] az azimuths (rad)
186 * @param[out] el elevations (rad)
187 * @param[out] snr SNR (0.001 dBHz)
188 * @param[out] vsat valid satellite flags
189 * @return number of satellites
190 */
191int rtksvrostat(rtksvr_t* svr, int type, gtime_t* time, int* sat, double* az, double* el, int** snr, int* vsat);
192
193/**
194 * @brief Get stream status.
195 * @param[in,out] svr RTK server struct
196 * @param[out] sstat stream status
197 * @param[out] msg status message
198 */
199void rtksvrsstat(rtksvr_t* svr, int* sstat, char* msg);
200
201/**
202 * @brief Mark current position in solution.
203 * @param[in,out] svr RTK server struct
204 * @param[in] name mark name
205 * @param[in] comment mark comment
206 * @return status (0:error,1:ok)
207 */
208int rtksvrmark(rtksvr_t* svr, const char* name, const char* comment);
209
210/**
211 * @brief Decide whether a decoded SSR result may be applied to nav.ssr_ch[0].
212 *
213 * In CLAS/PPP-RTK mode (svr->clas set) the CLAS decoder owns nav.ssr_ch[0],
214 * so MADOCA-PPP SSR from a raw L6E stream (STRFMT_L6E, code 10) or from a
215 * UBX/SBF L6E frame (code 15) is not applied. Other SSR sources (e.g. RTCM3
216 * SSR, code 10) are applied as before.
217 *
218 * @param[in] svr RTK server struct
219 * @param[in] index input stream index (0..2)
220 * @param[in] ret decoder status (10 or 15)
221 * @return 1 if update_ssr() should apply the result, 0 otherwise
222 */
223int rtksvr_ssr_applicable(const rtksvr_t* svr, int index, int ret);
224
225#ifdef __cplusplus
226}
227#endif
228
229#endif /* MRTK_RTKSVR_H */
CLAS (QZSS L6D) CSSR decoder and grid correction type definitions.
MRTKLIB Context — runtime context for processing, trace, and error handling.
struct nav_s nav_t
Definition mrtk_eph.h:40
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
#define MAXSTRPATH
#define MAXOBSBUF
#define rtk_thread_t
#define MAXRCVCMD
#define rtk_lock_t
#define MAXSOLBUF
#define MAXSBSMSG
MRTKLIB Galileo HAS Module — E6-B C/NAV HAS page collection and Message Type 1 (MT1) decode into ssr_...
MRTKLIB Navigation Module — Navigation data types and satellite/nav utility functions.
MRTKLIB Observation Module — Observation data types and utility functions.
MRTKLIB Options Module — Processing and solution option types.
MRTKLIB Precise Point Positioning (PPP) Module.
MRTKLIB Receiver Raw Data Module — Receiver raw data types and decoder functions for various GNSS rec...
MRTKLIB RTCM Module — RTCM message types and functions.
static void errmsg(rtk_t *rtk, const char *format,...)
MRTKLIB RTK Positioning Module — relative and precise positioning.
void rtksvrunlock(rtksvr_t *svr)
Unlock RTK server mutex.
int rtksvrmark(rtksvr_t *svr, const char *name, const char *comment)
Mark current position in solution.
void rtksvrstop(rtksvr_t *svr, char **cmds)
Stop RTK server.
void rtksvrclosestr(rtksvr_t *svr, int index)
Close RTK server output/log stream.
void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg)
Get stream status.
int rtksvr_ssr_applicable(const rtksvr_t *svr, int index, int ret)
Decide whether a decoded SSR result may be applied to nav.ssr_ch[0].
int rtksvrinit(rtksvr_t *svr)
Initialize RTK server.
int rtksvropenstr(rtksvr_t *svr, int index, int str, const char *path, const solopt_t *solopt)
Open RTK server output/log stream.
int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, char **paths, int *formats, int navsel, char **cmds, char **cmds_periodic, char **rcvopts, int nmeacycle, int nmeareq, const double *nmeapos, prcopt_t *prcopt, solopt_t *solopt, stream_t *moni, gtime_t rst, char *errmsg)
Start RTK server.
int rtksvrostat(rtksvr_t *svr, int type, gtime_t *time, int *sat, double *az, double *el, int **snr, int *vsat)
Get observation data status.
void rtksvrfree(rtksvr_t *svr)
Free RTK server resources.
void rtksvrlock(rtksvr_t *svr)
Lock RTK server mutex.
MRTKLIB Solution Module — Solution data types and I/O functions.
static int buffsize
MRTKLIB Stream Module — stream I/O abstraction layer.
struct stream_tag stream_t
MRTKLIB Time Module — GNSS time types and conversion functions.
GNSS time representation.
Definition mrtk_time.h:49
QZSS L6D message control struct.
Definition mrtk_ppp.h:50
Runtime context for MRTKLIB processing.
Observation data collection.
Definition mrtk_obs.h:59
Receiver raw data control type.
Definition mrtk_rcvraw.h:78
RTCM control struct type.
Definition mrtk_rtcm.h:50
uint8_t * buff[3]
Definition mrtk_rtksvr.h:68
nav_t nav
Definition mrtk_rtksvr.h:79
int nb[3]
Definition mrtk_rtksvr.h:65
clas_ctx_t * clas
Definition mrtk_rtksvr.h:94
rtk_t rtk
Definition mrtk_rtksvr.h:64
int nmeareq
Definition mrtk_rtksvr.h:56
double nmeapos[3]
Definition mrtk_rtksvr.h:57
has_t * has
Definition mrtk_rtksvr.h:95
char files[3][MAXSTRPATH]
Definition mrtk_rtksvr.h:77
uint32_t nmsg[3][12]
Definition mrtk_rtksvr.h:72
rtk_lock_t lock
Definition mrtk_rtksvr.h:92
uint8_t * pbuf[3]
Definition mrtk_rtksvr.h:70
rtk_thread_t thread
Definition mrtk_rtksvr.h:84
solopt_t solopt[2]
Definition mrtk_rtksvr.h:60
int nsb[2]
Definition mrtk_rtksvr.h:66
stream_t * moni
Definition mrtk_rtksvr.h:82
sstat_t sstat
Definition mrtk_rtksvr.h:75
int buffsize
Definition mrtk_rtksvr.h:58
uint8_t * sbuf[2]
Definition mrtk_rtksvr.h:69
mrtk_ctx_t * ctx
Definition mrtk_rtksvr.h:93
char cmds_periodic[3][MAXRCVCMD]
Definition mrtk_rtksvr.h:89
sbsmsg_t sbsmsg[MAXSBSMSG]
Definition mrtk_rtksvr.h:80
char cmd_reset[MAXRCVCMD]
Definition mrtk_rtksvr.h:90
double rb_ave[3]
Definition mrtk_rtksvr.h:88
stream_t stream[8]
Definition mrtk_rtksvr.h:81
double bl_reset
Definition mrtk_rtksvr.h:91
obs_t obs[3][MAXOBSBUF]
Definition mrtk_rtksvr.h:78
int cputime
Definition mrtk_rtksvr.h:85
sol_t solbuf[MAXSOLBUF]
Definition mrtk_rtksvr.h:71
int nmeacycle
Definition mrtk_rtksvr.h:55
rtcm_t rtcm[3]
Definition mrtk_rtksvr.h:74
mdcl6d_t * mdciono
Definition mrtk_rtksvr.h:96
int npb[3]
Definition mrtk_rtksvr.h:67
uint32_t tick
Definition mrtk_rtksvr.h:83
int format[3]
Definition mrtk_rtksvr.h:59
gtime_t ftime[3]
Definition mrtk_rtksvr.h:76
raw_t raw[3]
Definition mrtk_rtksvr.h:73