MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_opt.c
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_opt.c : processing and solution option defaults
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_opt.c
18 * @brief MRTKLIB Options Module — Default processing and solution options.
19 */
20#include "mrtklib/mrtk_opt.h"
21
22#include <stdio.h>
23
24/*--- local constants (duplicated to avoid rtklib.h dependency) -------------*/
25static const double D2R = 3.1415926535897932 / 180.0;
26
27#define SYS_GPS 0x01
28
29/*--- default option instances -----------------------------------------------*/
30
32 /* defaults processing options */
34 0,
35 2,
36 SYS_GPS, /* mode,soltype,nf,navsys */
37 15.0 * D2R,
38 {{0, 0}}, /* elmin,snrmask */
39 0,
40 1,
41 0,
42 0, /* sateph,modear,glomodear,bdsmodear */
43 SYS_GPS, /* arsys */
44 5,
45 0,
46 10,
47 1, /* maxout,minlock,minfix,armaxiter */
48 0,
49 0,
50 0,
51 0, /* estion,esttrop,dynamics,tidecorr */
52 1,
53 0,
54 0,
55 0,
56 0, /* niter,codesmooth,intpref,sbascorr,sbassatsel */
57 0,
58 0, /* rovpos,refpos */
59 {100.0, 100.0}, /* eratio[] */
60 {100.0, 0.003, 0.003, 0.0, 1.0}, /* err[] */
61 {30.0, 0.03, 0.3}, /* std[] */
62 {1E-4, 1E-3, 1E-4, 1E-1, 1E-2, 0.0}, /* prn[] */
63 5E-12, /* sclkstab */
64 {3.0, 0.9999, 0.25, 0.1, 0.05}, /* thresar */
65 0.0,
66 0.0,
67 0.05,
68 0.0, /* elmaskar,almaskhold,thresslip,thresdop */
69 30.0,
70 30.0,
71 30.0, /* maxtdif,maxinno,maxgdop */
72 {0},
73 {0},
74 {0}, /* baseline,ru,rb */
75 {"", ""}, /* anttype */
76 {{0}},
77 {{0}},
78 {0} /* antdel,pcv,exsats */
79 ,
80 0,
81 0 /* ign_chierr,bds2bias */
82 ,
83 0,
84 0,
85 0,
86 0, /* pppsatcb,pppsatpb,unbias,maxbiasdt */
87 .correction = CORR_AUTO,
88 .enhanced_spp_seed = SEEDENH_BASE, /* default on: C/N0 + TDCP a-priori seed (PPP-RTK/VRS) */
89 .rejethres = 0.0, /* standalone SPP off; CLAS seed applies upstream auto-default */
90 .rejeminsat = 7,
91};
93 /* defaults solution output options */
94 SOLF_LLH, TIMES_GPST, 1, 3, /* posf,times,timef,timeu */
95 0, 1, 0, 0, 0, 0, 0, /* degf,outhead,outopt,outvel,datum,height,geoid */
96 0, 0, 0, /* solstatic,sstat,trace */
97 {0.0, 0.0}, /* nmeaintv */
98 " ", "" /* separator/program name */
99};
100
101/* resolve and validate correction source ------------------------------------
102 * Resolve CORR_AUTO from mode + sateph (backward compatibility for configs that
103 * omit `correction`), reject reserved-but-unimplemented sources, and enforce the
104 * (mode, correction) validity matrix. See docs/design/configuration.md.
105 * args : prcopt_t *opt IO processing options (opt->correction resolved in place)
106 * char *msg O error text on failure (caller buffer)
107 * size_t msgsz I size of msg buffer
108 * return : status (1:ok, 0:invalid combination -> caller should abort)
109 *--------------------------------------------------------------------------*/
110/* human-readable names for resolve_correction() error messages -------------*/
111static const char* corr_name(int corr) {
112 switch (corr) {
113 case CORR_AUTO:
114 return "auto";
115 case CORR_NONE:
116 return "none";
117 case CORR_IGS:
118 return "igs";
119 case CORR_IGS_RTS:
120 return "igs-rts";
121 case CORR_QZS_MADOCA:
122 return "qzs-madoca";
123 case CORR_GAL_HAS:
124 return "gal-has";
125 case CORR_BDS_B2B:
126 return "bds-b2b";
127 case CORR_QZS_CLAS:
128 return "qzs-clas";
129 default:
130 return "?";
131 }
132}
133static const char* mode_name(int mode) {
134 switch (mode) {
135 case PMODE_SINGLE:
136 return "single";
137 case PMODE_DGPS:
138 return "dgps";
139 case PMODE_KINEMA:
140 return "kinematic";
141 case PMODE_STATIC:
142 return "static";
143 case PMODE_MOVEB:
144 return "movingbase";
145 case PMODE_FIXED:
146 return "fixed";
147 case PMODE_PPP_KINEMA:
148 return "ppp-kine";
149 case PMODE_PPP_STATIC:
150 return "ppp-static";
151 case PMODE_PPP_FIXED:
152 return "ppp-fixed";
153 case PMODE_PPP_RTK:
154 return "ppp-rtk";
155 case PMODE_SSR2OSR:
156 return "ssr2osr";
158 return "ssr2osr-fixed";
159 case PMODE_VRS_RTK:
160 return "vrs-rtk";
161 default:
162 return "?";
163 }
164}
165extern int resolve_correction(prcopt_t* opt, char* msg, size_t msgsz) {
166 int m = opt->mode;
167
168 /* infer when not explicitly configured (correction omitted -> CORR_AUTO) */
169 if (opt->correction == CORR_AUTO) {
170 if (m == PMODE_PPP_RTK || m == PMODE_VRS_RTK) {
172 } else if (m == PMODE_PPP_KINEMA || m == PMODE_PPP_STATIC || m == PMODE_PPP_FIXED) {
173 /* igs-rts is never inferred: it shares sateph=brdc+ssrapc with
174 * qzs-madoca, so the two are indistinguishable here. Require an
175 * explicit `correction = "igs-rts"` to take the RTCM-SSR path. */
177 } else {
178 opt->correction = CORR_NONE;
179 }
180 }
181
182 /* reserved sources: present in the schema but not implemented yet.
183 * igs-rts is NOT reserved any more (#138): the RTCM-SSR / IGS-SSR(MT4076)
184 * decode-and-apply pipeline is inherited from the MADOCA-via-RTCM path and
185 * runs through the same SSR branch of corr_meas. gal-has is NOT reserved any
186 * more: HAS MT1 corrections decode into nav->ssr_ch[0] and run through the
187 * same SSR branch of corr_meas (float PPP). */
188 if (opt->correction == CORR_BDS_B2B) {
189 if (msg) {
190 snprintf(msg, msgsz, "correction source not implemented yet (correction=%s)", corr_name(opt->correction));
191 }
192 return 0;
193 }
194
195 /* validity matrix (see docs/design/configuration.md) */
196 switch (m) {
197 case PMODE_PPP_KINEMA:
198 case PMODE_PPP_STATIC:
199 case PMODE_PPP_FIXED:
200 if (opt->correction != CORR_IGS && opt->correction != CORR_QZS_MADOCA && opt->correction != CORR_IGS_RTS &&
201 opt->correction != CORR_GAL_HAS) {
202 if (msg) {
203 snprintf(msg, msgsz, "invalid correction=%s for mode=%s (use igs, igs-rts, qzs-madoca or gal-has)",
204 corr_name(opt->correction), mode_name(m));
205 }
206 return 0;
207 }
208 /* igs-rts and gal-has apply broadcast ephemeris + SSR corrections; they
209 * need an SSR-aware satellite-ephemeris option (brdc+ssrapc or
210 * brdc+ssrcom). */
211 if ((opt->correction == CORR_IGS_RTS || opt->correction == CORR_GAL_HAS) && opt->sateph != EPHOPT_SSRAPC &&
212 opt->sateph != EPHOPT_SSRCOM) {
213 if (msg) {
214 snprintf(msg, msgsz,
215 "correction=%s requires satellite_ephemeris=brdc+ssrapc or brdc+ssrcom (got %d)",
216 corr_name(opt->correction), opt->sateph);
217 }
218 return 0;
219 }
220 /* #142: integer PPP-AR for IGS precise products needs the uncombined
221 * measurement model. ppp_amb_ILS resolves per-frequency ambiguity
222 * states, which only exist when ionosphere=est-stec; with the
223 * iono-free combination there is one ambiguity per satellite and
224 * ppp_ar() is a no-op. Flag the misconfiguration rather than silently
225 * returning a float-only solution. */
226 if (opt->correction == CORR_IGS && opt->modear >= ARMODE_CONT && opt->ionoopt != IONOOPT_EST) {
227 if (msg) {
228 snprintf(msg, msgsz,
229 "correction=igs with ambiguity_resolution requires ionosphere=est-stec (uncombined)");
230 }
231 return 0;
232 }
233 break;
234 case PMODE_PPP_RTK:
235 case PMODE_VRS_RTK:
236 if (opt->correction != CORR_QZS_CLAS) {
237 if (msg) {
238 snprintf(msg, msgsz, "invalid correction=%s for mode=%s (use qzs-clas)", corr_name(opt->correction),
239 mode_name(m));
240 }
241 return 0;
242 }
243 break;
244 default:
245 /* single / dgps / rtk-relative / ssr2osr: no augmentation source allowed */
246 if (opt->correction != CORR_NONE) {
247 if (msg) {
248 snprintf(msg, msgsz, "invalid correction=%s for mode=%s (use none)", corr_name(opt->correction),
249 mode_name(m));
250 }
251 return 0;
252 }
253 break;
254 }
255 return 1;
256}
#define D2R
Definition mrtk_coords.c:36
#define EPHOPT_PREC
Definition mrtk_eph.c:84
#define SYS_GPS
Definition mrtk_eph.c:65
#define EPHOPT_SSRAPC
Definition mrtk_eph.c:86
#define EPHOPT_SSRCOM
Definition mrtk_eph.c:87
static const char * mode_name(int mode)
Definition mrtk_opt.c:133
static const char * corr_name(int corr)
Definition mrtk_opt.c:111
const prcopt_t prcopt_default
Definition mrtk_opt.c:31
int resolve_correction(prcopt_t *opt, char *msg, size_t msgsz)
Definition mrtk_opt.c:165
const solopt_t solopt_default
Definition mrtk_opt.c:92
MRTKLIB Options Module — Processing and solution option types.
#define PMODE_PPP_RTK
Definition mrtk_opt.h:54
#define PMODE_MOVEB
Definition mrtk_opt.h:49
#define TIMES_GPST
Definition mrtk_opt.h:84
#define CORR_QZS_MADOCA
Definition mrtk_opt.h:119
#define CORR_BDS_B2B
Definition mrtk_opt.h:121
#define IONOOPT_EST
Definition mrtk_opt.h:96
#define SEEDENH_BASE
Definition mrtk_opt.h:344
#define CORR_IGS_RTS
Definition mrtk_opt.h:118
#define PMODE_PPP_KINEMA
Definition mrtk_opt.h:51
#define PMODE_DGPS
Definition mrtk_opt.h:46
#define CORR_GAL_HAS
Definition mrtk_opt.h:120
#define PMODE_PPP_STATIC
Definition mrtk_opt.h:52
#define PMODE_KINEMA
Definition mrtk_opt.h:47
#define PMODE_PPP_FIXED
Definition mrtk_opt.h:53
#define CORR_NONE
Definition mrtk_opt.h:116
#define ARMODE_CONT
Definition mrtk_opt.h:129
#define PMODE_SSR2OSR_FIXED
Definition mrtk_opt.h:56
#define PMODE_FIXED
Definition mrtk_opt.h:50
#define PMODE_STATIC
Definition mrtk_opt.h:48
#define PMODE_VRS_RTK
Definition mrtk_opt.h:57
#define SOLF_LLH
Definition mrtk_opt.h:63
#define PMODE_SSR2OSR
Definition mrtk_opt.h:55
#define CORR_IGS
Definition mrtk_opt.h:117
#define CORR_AUTO
Definition mrtk_opt.h:115
#define CORR_QZS_CLAS
Definition mrtk_opt.h:122
#define PMODE_SINGLE
Definition mrtk_opt.h:45
int ionoopt
Definition mrtk_opt.h:187
int modear
Definition mrtk_opt.h:179
int mode
Definition mrtk_opt.h:172
int correction
Definition mrtk_opt.h:300
int sateph
Definition mrtk_opt.h:178