MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_eph.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_eph.h : satellite ephemeris 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_eph.h
18 * @brief MRTKLIB Broadcast Ephemeris Module — Satellite orbit/clock types and
19 * Kepler/GLONASS/SBAS orbit computation functions.
20 *
21 * This header provides the fundamental broadcast ephemeris struct types
22 * (eph_t, geph_t, seph_t, alm_t, galm_t) and the pure orbit/clock
23 * computation functions extracted from ephemeris.c.
24 *
25 * @note All functions in this module are pure cut-and-paste extractions
26 * from ephemeris.c with zero algorithmic changes.
27 */
28#ifndef MRTK_EPH_H
29#define MRTK_EPH_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36#include "mrtklib/mrtk_time.h"
37
38/* forward declaration for nav_t (defined in mrtk_nav.h) */
39struct nav_s;
40typedef struct nav_s nav_t;
41
42/*============================================================================
43 * Broadcast Ephemeris Types
44 *===========================================================================*/
45
46/**
47 * @brief GPS/GAL/QZS/BDS/IRN almanac type.
48 */
49typedef struct {
50 int sat; /* satellite number */
51 int svh; /* SV health (0:ok) */
52 int svconf; /* AS and SV config */
53 int week; /* GPS/QZS: GPS week, GAL: Galileo week */
54 gtime_t toa; /* Toa */
55 double A, e, i0, OMG0, omg, M0, OMGd; /* SV orbit parameters */
56 double toas; /* Toa (s) in week */
57 double f0, f1; /* SV clock parameters (af0,af1) */
58} alm_t;
59
60/**
61 * @brief GLONASS almanac type.
62 */
63typedef struct {
64 int sat; /* satellite number */
65 int Cn; /* unhealthy flag (1:unhealthy) */
66 int Mn; /* satellite type (0:GLONASS,1:GLONASS-M) */
67 int Hn; /* carrier-frequency number */
68 gtime_t toa; /* Toa */
69 double tn; /* time of first acsending node passage (s) */
70 double lamn, din, eccn, omgn, dTn, ddTn; /* SV orbit parameters */
71 double taun; /* SV clock parameters */
72} galm_t;
73
74/**
75 * @brief GPS/GAL/QZS/BDS/IRN broadcast ephemeris type.
76 */
77typedef struct {
78 int sat; /* satellite number */
79 int iode, iodc; /* IODE,IODC */
80 int sva; /* SV accuracy (URA index) */
81 int svh; /* SV health (0:ok) */
82 int week; /* GPS/QZS: gps week, GAL: galileo week */
83 int code; /* GPS/QZS: code on L2 */
84 /* GAL: data source defined as rinex 3.03 */
85 /* BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q) */
86 int flag; /* GPS/QZS: L2 P data flag */
87 /* BDS: nav type (0:unknown,1:IGSO/MEO,2:GEO) */
88 gtime_t toe, toc, ttr; /* Toe,Toc,T_trans */
89 /* SV orbit parameters */
90 double A, e, i0, OMG0, omg, M0, deln, OMGd, idot;
91 double crc, crs, cuc, cus, cic, cis;
92 double toes; /* Toe (s) in week */
93 double fit; /* fit interval (h) */
94 double f0, f1, f2; /* SV clock parameters (af0,af1,af2) */
95 double tgd[6]; /* group delay parameters */
96 /* GPS/QZS:tgd[0]=TGD */
97 /* GAL:tgd[0]=BGD_E1E5a,tgd[1]=BGD_E1E5b */
98 /* BDS:tgd[0]=TGD_B1I ,tgd[1]=TGD_B2I/B2b,tgd[2]=TGD_B1Cp */
99 /* tgd[3]=TGD_B2ap,tgd[4]=ISC_B1Cd ,tgd[5]=ISC_B2ad */
100 int type; /* ephemeris type */
101 /* GPS/QZS: 0=LNAV,1=CNAV,2=CNAV-2 */
102 /* GAL : 0=INAV,1=FNAV */
103 /* BDS : 0=D1,1=D2,2=CNAV-1,3=CNAV-2,4=CNAV-3 */
104 /* IRN : 0=LNAV */
105 double Adot, ndot; /* Adot,ndot for CNAV */
106} eph_t;
107
108/**
109 * @brief GLONASS broadcast ephemeris type.
110 */
111typedef struct {
112 int sat; /* satellite number */
113 int iode; /* IODE (0-6 bit of tb field) */
114 int frq; /* FCN (frequency channel number) */
115 int svh; /* extended SVH (b3:ln,b2:Cn_a,b1:Cn,b0:Bn) */
116 int flags; /* status flags (b78:M,b6:P4,b5:P3,b4:P2,b23:P1,b01:P) */
117 int sva, age; /* URA index (FT), age of operation (En) */
118 gtime_t toe; /* epoch of ephemerides (gpst) */
119 gtime_t tof; /* message frame time (gpst) */
120 double pos[3]; /* satellite position (ecef) (m) */
121 double vel[3]; /* satellite velocity (ecef) (m/s) */
122 double acc[3]; /* satellite acceleration (ecef) (m/s^2) */
123 double taun, gamn; /* SV clock bias (s)/relative freq bias */
124 double dtaun; /* delay between L1 and L2 (s) */
125} geph_t;
126
127/**
128 * @brief SBAS ephemeris type.
129 */
130typedef struct {
131 int sat; /* satellite number */
132 gtime_t t0; /* reference epoch time (GPST) */
133 gtime_t tof; /* time of message frame (GPST) */
134 int sva; /* SV accuracy (URA index) */
135 int svh; /* SV health (0:ok) */
136 double pos[3]; /* satellite position (m) (ecef) */
137 double vel[3]; /* satellite velocity (m/s) (ecef) */
138 double acc[3]; /* satellite acceleration (m/s^2) (ecef) */
139 double af0, af1; /* satellite clock-offset/drift (s,s/s) */
140} seph_t;
141
142/*============================================================================
143 * Broadcast Ephemeris Functions
144 *===========================================================================*/
145
146/**
147 * @brief Compute satellite clock bias with broadcast ephemeris (GPS/GAL/QZS).
148 * @param[in] time Time by satellite clock (GPST)
149 * @param[in] eph Broadcast ephemeris
150 * @return Satellite clock bias (s) without relativity correction
151 */
152double eph2clk(gtime_t time, const eph_t* eph);
153
154/**
155 * @brief Compute satellite position and clock with broadcast ephemeris
156 * (GPS/GAL/QZS/BDS/IRN).
157 * @param[in] time Time (GPST)
158 * @param[in] eph Broadcast ephemeris
159 * @param[out] rs Satellite position (ecef) {x,y,z} (m)
160 * @param[out] dts Satellite clock bias (s)
161 * @param[out] var Satellite position and clock variance (m^2)
162 */
163void eph2pos(gtime_t time, const eph_t* eph, double* rs, double* dts, double* var);
164
165/**
166 * @brief Compute satellite clock bias with GLONASS ephemeris.
167 * @param[in] time Time by satellite clock (GPST)
168 * @param[in] geph GLONASS ephemeris
169 * @return Satellite clock bias (s)
170 */
171double geph2clk(gtime_t time, const geph_t* geph);
172
173/**
174 * @brief Compute satellite position and clock with GLONASS ephemeris.
175 * @param[in] time Time (GPST)
176 * @param[in] geph GLONASS ephemeris
177 * @param[out] rs Satellite position {x,y,z} (ecef) (m)
178 * @param[out] dts Satellite clock bias (s)
179 * @param[out] var Satellite position and clock variance (m^2)
180 */
181void geph2pos(gtime_t time, const geph_t* geph, double* rs, double* dts, double* var);
182
183/**
184 * @brief Compute satellite clock bias with SBAS ephemeris.
185 * @param[in] time Time by satellite clock (GPST)
186 * @param[in] seph SBAS ephemeris
187 * @return Satellite clock bias (s)
188 */
189double seph2clk(gtime_t time, const seph_t* seph);
190
191/**
192 * @brief Compute satellite position and clock with SBAS ephemeris.
193 * @param[in] time Time (GPST)
194 * @param[in] seph SBAS ephemeris
195 * @param[out] rs Satellite position {x,y,z} (ecef) (m)
196 * @param[out] dts Satellite clock bias (s)
197 * @param[out] var Satellite position and clock variance (m^2)
198 */
199void seph2pos(gtime_t time, const seph_t* seph, double* rs, double* dts, double* var);
200
201/**
202 * @brief Compute satellite position and clock bias with almanac.
203 * @param[in] time Time (GPST)
204 * @param[in] alm Almanac
205 * @param[out] rs Satellite position (ecef) {x,y,z} (m)
206 * @param[out] dts Satellite clock bias (s)
207 */
208void alm2pos(gtime_t time, const alm_t* alm, double* rs, double* dts);
209
210/*============================================================================
211 * Ephemeris Selection Functions
212 *===========================================================================*/
213
214/**
215 * @brief Set selected satellite ephemeris for multiple ones.
216 * @param[in] sys Satellite system (SYS_???)
217 * @param[in] sel Selection of ephemeris
218 * GPS,QZS : 0:LNAV ,1:CNAV (default: LNAV)
219 * GAL : 0:I/NAV,1:F/NAV (default: I/NAV)
220 * others : undefined
221 */
222void setseleph(int sys, int sel);
223
224/**
225 * @brief Get selected satellite ephemeris.
226 * @param[in] sys Satellite system (SYS_???)
227 * @return Selected ephemeris (refer setseleph())
228 */
229int getseleph(int sys);
230
231/**
232 * @brief Set SSR channel index for satpos_ssr() (multi-L6E).
233 * @param[in] ch Channel index (0 or 1)
234 */
235void set_ssr_ch_idx(int ch);
236
237/**
238 * @brief Get current SSR channel index.
239 * @return Current channel index
240 */
241int get_ssr_ch_idx(void);
242
243/**
244 * @brief Select broadcast ephemeris by satellite and IODE.
245 * @param[in] time Time for ephemeris selection
246 * @param[in] sat Satellite number
247 * @param[in] iode IODE (-1: any)
248 * @param[in] nav Navigation data
249 * @return Pointer to selected ephemeris, NULL if not found
250 */
251eph_t* seleph(gtime_t time, int sat, int iode, const nav_t* nav);
252
253/**
254 * @brief Satellite position and clock by broadcast ephemeris.
255 * @param[in] time Transmission time
256 * @param[in] teph Time for ephemeris selection
257 * @param[in] sat Satellite number
258 * @param[in] nav Navigation data
259 * @param[in] iode IODE (-1: any)
260 * @param[out] rs Satellite position/velocity {x,y,z,vx,vy,vz} (m,m/s)
261 * @param[out] dts Satellite clock {bias,drift} (s,s/s)
262 * @param[out] var Satellite position variance (m^2)
263 * @param[out] svh Satellite health flag
264 * @return 1:ok, 0:error
265 */
266int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t* nav, int iode, double* rs, double* dts, double* var,
267 int* svh);
268
269#ifdef __cplusplus
270}
271#endif
272
273#endif /* MRTK_EPH_H */
void geph2pos(gtime_t time, const geph_t *geph, double *rs, double *dts, double *var)
Compute satellite position and clock with GLONASS ephemeris.
Definition mrtk_eph.c:372
int getseleph(int sys)
Get selected satellite ephemeris.
Definition mrtk_eph.c:1040
void set_ssr_ch_idx(int ch)
Set SSR channel index for satpos_ssr() (multi-L6E).
Definition mrtk_eph.c:761
double geph2clk(gtime_t time, const geph_t *geph)
Compute satellite clock bias with GLONASS ephemeris.
Definition mrtk_eph.c:349
void eph2pos(gtime_t time, const eph_t *eph, double *rs, double *dts, double *var)
Compute satellite position and clock with broadcast ephemeris (GPS/GAL/QZS/BDS/IRN).
Definition mrtk_eph.c:258
int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, int iode, double *rs, double *dts, double *var, int *svh)
Satellite position and clock by broadcast ephemeris.
Definition mrtk_eph.c:673
struct nav_s nav_t
Definition mrtk_eph.h:40
double seph2clk(gtime_t time, const seph_t *seph)
Compute satellite clock bias with SBAS ephemeris.
Definition mrtk_eph.c:405
void setseleph(int sys, int sel)
Set selected satellite ephemeris for multiple ones.
Definition mrtk_eph.c:1009
void alm2pos(gtime_t time, const alm_t *alm, double *rs, double *dts)
Compute satellite position and clock bias with almanac.
Definition mrtk_eph.c:185
int get_ssr_ch_idx(void)
Get current SSR channel index.
Definition mrtk_eph.c:766
void seph2pos(gtime_t time, const seph_t *seph, double *rs, double *dts, double *var)
Compute satellite position and clock with SBAS ephemeris.
Definition mrtk_eph.c:428
double eph2clk(gtime_t time, const eph_t *eph)
Compute satellite clock bias with broadcast ephemeris (GPS/GAL/QZS).
Definition mrtk_eph.c:232
eph_t * seleph(gtime_t time, int sat, int iode, const nav_t *nav)
Select broadcast ephemeris by satellite and IODE.
Definition mrtk_eph.c:465
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
MRTKLIB Time Module — GNSS time types and conversion functions.
GPS/GAL/QZS/BDS/IRN almanac type.
Definition mrtk_eph.h:49
gtime_t toa
Definition mrtk_eph.h:54
double e
Definition mrtk_eph.h:55
int svh
Definition mrtk_eph.h:51
double i0
Definition mrtk_eph.h:55
double M0
Definition mrtk_eph.h:55
int week
Definition mrtk_eph.h:53
double toas
Definition mrtk_eph.h:56
double A
Definition mrtk_eph.h:55
int sat
Definition mrtk_eph.h:50
int svconf
Definition mrtk_eph.h:52
double OMGd
Definition mrtk_eph.h:55
double f0
Definition mrtk_eph.h:57
double OMG0
Definition mrtk_eph.h:55
double f1
Definition mrtk_eph.h:57
double omg
Definition mrtk_eph.h:55
GPS/GAL/QZS/BDS/IRN broadcast ephemeris type.
Definition mrtk_eph.h:77
double OMG0
Definition mrtk_eph.h:90
double omg
Definition mrtk_eph.h:90
int sat
Definition mrtk_eph.h:78
gtime_t ttr
Definition mrtk_eph.h:88
double OMGd
Definition mrtk_eph.h:90
double f1
Definition mrtk_eph.h:94
double f0
Definition mrtk_eph.h:94
int svh
Definition mrtk_eph.h:81
double e
Definition mrtk_eph.h:90
double idot
Definition mrtk_eph.h:90
double M0
Definition mrtk_eph.h:90
double A
Definition mrtk_eph.h:90
double cis
Definition mrtk_eph.h:91
int flag
Definition mrtk_eph.h:86
gtime_t toe
Definition mrtk_eph.h:88
double fit
Definition mrtk_eph.h:93
int week
Definition mrtk_eph.h:82
gtime_t toc
Definition mrtk_eph.h:88
double cic
Definition mrtk_eph.h:91
double tgd[6]
Definition mrtk_eph.h:95
double cus
Definition mrtk_eph.h:91
double cuc
Definition mrtk_eph.h:91
double toes
Definition mrtk_eph.h:92
int code
Definition mrtk_eph.h:83
int type
Definition mrtk_eph.h:100
double Adot
Definition mrtk_eph.h:105
double crs
Definition mrtk_eph.h:91
double i0
Definition mrtk_eph.h:90
int iode
Definition mrtk_eph.h:79
int sva
Definition mrtk_eph.h:80
double ndot
Definition mrtk_eph.h:105
double deln
Definition mrtk_eph.h:90
double crc
Definition mrtk_eph.h:91
double f2
Definition mrtk_eph.h:94
int iodc
Definition mrtk_eph.h:79
GLONASS almanac type.
Definition mrtk_eph.h:63
int Mn
Definition mrtk_eph.h:66
double omgn
Definition mrtk_eph.h:70
int Hn
Definition mrtk_eph.h:67
double eccn
Definition mrtk_eph.h:70
double tn
Definition mrtk_eph.h:69
double din
Definition mrtk_eph.h:70
int sat
Definition mrtk_eph.h:64
gtime_t toa
Definition mrtk_eph.h:68
double dTn
Definition mrtk_eph.h:70
int Cn
Definition mrtk_eph.h:65
double lamn
Definition mrtk_eph.h:70
double taun
Definition mrtk_eph.h:71
double ddTn
Definition mrtk_eph.h:70
GLONASS broadcast ephemeris type.
Definition mrtk_eph.h:111
double vel[3]
Definition mrtk_eph.h:121
double dtaun
Definition mrtk_eph.h:124
gtime_t toe
Definition mrtk_eph.h:118
double pos[3]
Definition mrtk_eph.h:120
int sva
Definition mrtk_eph.h:117
int flags
Definition mrtk_eph.h:116
int iode
Definition mrtk_eph.h:113
double gamn
Definition mrtk_eph.h:123
double acc[3]
Definition mrtk_eph.h:122
int age
Definition mrtk_eph.h:117
int svh
Definition mrtk_eph.h:115
double taun
Definition mrtk_eph.h:123
gtime_t tof
Definition mrtk_eph.h:119
int sat
Definition mrtk_eph.h:112
int frq
Definition mrtk_eph.h:114
GNSS time representation.
Definition mrtk_time.h:49
SBAS ephemeris type.
Definition mrtk_eph.h:130
int sva
Definition mrtk_eph.h:134
double pos[3]
Definition mrtk_eph.h:136
double vel[3]
Definition mrtk_eph.h:137
double acc[3]
Definition mrtk_eph.h:138
gtime_t tof
Definition mrtk_eph.h:133
double af0
Definition mrtk_eph.h:139
double af1
Definition mrtk_eph.h:139
int sat
Definition mrtk_eph.h:131
gtime_t t0
Definition mrtk_eph.h:132
int svh
Definition mrtk_eph.h:135