2017-04-20 14:10:12 +00:00
|
|
|
/*!
|
|
|
|
* \file rtklib_conversions.cc
|
|
|
|
* \brief GNSS-SDR to RTKLIB data structures conversion functions
|
2017-04-24 22:48:13 +00:00
|
|
|
* \author 2017, Javier Arribas
|
2017-04-20 14:10:12 +00:00
|
|
|
*
|
2017-04-24 22:48:13 +00:00
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2018-05-13 20:49:11 +00:00
|
|
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
2017-04-24 22:48:13 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
2017-04-20 14:10:12 +00:00
|
|
|
*
|
2017-04-24 22:48:13 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
2017-04-20 14:10:12 +00:00
|
|
|
*
|
2017-04-24 22:48:13 +00:00
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2017-04-20 14:10:12 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
2017-04-24 22:48:13 +00:00
|
|
|
*/
|
2017-04-22 22:36:57 +00:00
|
|
|
|
2017-04-20 14:10:12 +00:00
|
|
|
#include "rtklib_conversions.h"
|
2017-04-24 22:48:13 +00:00
|
|
|
#include "rtklib_rtkcmn.h"
|
2017-04-20 14:10:12 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro, int week, int band)
|
2017-04-20 14:10:12 +00:00
|
|
|
{
|
2017-04-23 19:10:32 +00:00
|
|
|
rtklib_obs.D[band] = gnss_synchro.Carrier_Doppler_hz;
|
|
|
|
rtklib_obs.P[band] = gnss_synchro.Pseudorange_m;
|
2017-12-11 11:17:01 +00:00
|
|
|
rtklib_obs.L[band] = gnss_synchro.Carrier_phase_rads / PI_2;
|
2018-03-03 01:03:39 +00:00
|
|
|
switch (band)
|
|
|
|
{
|
2017-11-20 11:31:49 +00:00
|
|
|
case 0:
|
|
|
|
rtklib_obs.code[band] = static_cast<unsigned char>(CODE_L1C);
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_obs.code[band] = static_cast<unsigned char>(CODE_L2S);
|
|
|
|
break;
|
2017-11-20 11:31:49 +00:00
|
|
|
case 2:
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_obs.code[band] = static_cast<unsigned char>(CODE_L5X);
|
|
|
|
break;
|
|
|
|
}
|
2017-04-30 10:32:04 +00:00
|
|
|
double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz;
|
|
|
|
if (CN0_dB_Hz_est > 63.75) CN0_dB_Hz_est = 63.75;
|
|
|
|
if (CN0_dB_Hz_est < 0.0) CN0_dB_Hz_est = 0.0;
|
2018-12-03 15:25:11 +00:00
|
|
|
auto CN0_dB_Hz = static_cast<unsigned char>(std::round(CN0_dB_Hz_est / 0.25));
|
2017-04-30 10:32:04 +00:00
|
|
|
rtklib_obs.SNR[band] = CN0_dB_Hz;
|
2017-05-04 16:18:11 +00:00
|
|
|
//Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris
|
2018-03-03 01:03:39 +00:00
|
|
|
switch (gnss_synchro.System)
|
|
|
|
{
|
2017-05-04 16:18:11 +00:00
|
|
|
case 'G':
|
|
|
|
rtklib_obs.sat = gnss_synchro.PRN;
|
|
|
|
break;
|
|
|
|
case 'E':
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_obs.sat = gnss_synchro.PRN + NSATGPS + NSATGLO;
|
2017-05-04 16:18:11 +00:00
|
|
|
break;
|
2017-07-19 14:45:54 +00:00
|
|
|
case 'R':
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_obs.sat = gnss_synchro.PRN + NSATGPS;
|
2017-07-19 14:45:54 +00:00
|
|
|
break;
|
|
|
|
|
2017-05-04 16:18:11 +00:00
|
|
|
default:
|
|
|
|
rtklib_obs.sat = gnss_synchro.PRN;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-04-23 19:10:32 +00:00
|
|
|
rtklib_obs.time = gpst2time(adjgpsweek(week), gnss_synchro.RX_time);
|
2017-05-02 17:31:38 +00:00
|
|
|
rtklib_obs.rcv = 1;
|
2017-04-20 14:10:12 +00:00
|
|
|
return rtklib_obs;
|
|
|
|
}
|
2017-04-21 09:34:23 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
geph_t eph_to_rtklib(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, const Glonass_Gnav_Utc_Model& gnav_clock_model)
|
2017-07-19 14:45:54 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
double week, sec;
|
|
|
|
int adj_week;
|
|
|
|
geph_t rtklib_sat = {0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, 0.0, 0.0, 0.0};
|
2017-07-19 14:45:54 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.sat = glonass_gnav_eph.i_satellite_slot_number + NSATGPS; /* satellite number */
|
|
|
|
rtklib_sat.iode = static_cast<int>(glonass_gnav_eph.d_t_b); /* IODE (0-6 bit of tb field) */
|
|
|
|
rtklib_sat.frq = glonass_gnav_eph.i_satellite_freq_channel; /* satellite frequency number */
|
|
|
|
rtklib_sat.svh = glonass_gnav_eph.d_l3rd_n; /* satellite health*/
|
|
|
|
rtklib_sat.sva = static_cast<int>(glonass_gnav_eph.d_F_T); /* satellite accuracy*/
|
|
|
|
rtklib_sat.age = static_cast<int>(glonass_gnav_eph.d_E_n); /* satellite age*/
|
|
|
|
rtklib_sat.pos[0] = glonass_gnav_eph.d_Xn * 1000; /* satellite position (ecef) (m) */
|
|
|
|
rtklib_sat.pos[1] = glonass_gnav_eph.d_Yn * 1000; /* satellite position (ecef) (m) */
|
|
|
|
rtklib_sat.pos[2] = glonass_gnav_eph.d_Zn * 1000; /* satellite position (ecef) (m) */
|
|
|
|
rtklib_sat.vel[0] = glonass_gnav_eph.d_VXn * 1000; /* satellite velocity (ecef) (m/s) */
|
|
|
|
rtklib_sat.vel[1] = glonass_gnav_eph.d_VYn * 1000; /* satellite velocity (ecef) (m/s) */
|
|
|
|
rtklib_sat.vel[2] = glonass_gnav_eph.d_VZn * 1000; /* satellite velocity (ecef) (m/s) */
|
|
|
|
rtklib_sat.acc[0] = glonass_gnav_eph.d_AXn * 1000; /* satellite acceleration (ecef) (m/s^2) */
|
|
|
|
rtklib_sat.acc[1] = glonass_gnav_eph.d_AYn * 1000; /* satellite acceleration (ecef) (m/s^2) */
|
|
|
|
rtklib_sat.acc[2] = glonass_gnav_eph.d_AZn * 1000; /* satellite acceleration (ecef) (m/s^2) */
|
|
|
|
rtklib_sat.taun = glonass_gnav_eph.d_tau_n; /* SV clock bias (s) */
|
|
|
|
rtklib_sat.gamn = glonass_gnav_eph.d_gamma_n; /* SV relative freq bias */
|
|
|
|
rtklib_sat.age = static_cast<int>(glonass_gnav_eph.d_Delta_tau_n); /* delay between L1 and L2 (s) */
|
2017-07-19 14:45:54 +00:00
|
|
|
|
2017-10-19 19:22:55 +00:00
|
|
|
// Time expressed in GPS Time but using RTKLib format
|
2017-11-02 03:05:40 +00:00
|
|
|
glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_t_b, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
|
2017-10-19 19:22:55 +00:00
|
|
|
adj_week = adjgpsweek(static_cast<int>(week));
|
|
|
|
rtklib_sat.toe = gpst2time(adj_week, sec);
|
2017-07-19 14:45:54 +00:00
|
|
|
|
2017-10-19 19:22:55 +00:00
|
|
|
// Time expressed in GPS Time but using RTKLib format
|
|
|
|
glonass_gnav_eph.glot_to_gpst(glonass_gnav_eph.d_t_k, gnav_clock_model.d_tau_c, gnav_clock_model.d_tau_gps, &week, &sec);
|
|
|
|
adj_week = adjgpsweek(static_cast<int>(week));
|
|
|
|
rtklib_sat.tof = gpst2time(adj_week, sec);
|
2017-07-19 14:45:54 +00:00
|
|
|
|
|
|
|
return rtklib_sat;
|
|
|
|
}
|
|
|
|
|
2017-10-11 16:22:56 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
eph_t eph_to_rtklib(const Galileo_Ephemeris& gal_eph)
|
2017-04-20 14:10:12 +00:00
|
|
|
{
|
2017-04-25 16:27:23 +00:00
|
|
|
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
2018-11-05 16:53:53 +00:00
|
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0};
|
2017-05-04 16:18:11 +00:00
|
|
|
//Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.sat = gal_eph.i_satellite_PRN + NSATGPS + NSATGLO;
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.A = gal_eph.A_1 * gal_eph.A_1;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.M0 = gal_eph.M0_1;
|
|
|
|
rtklib_sat.deln = gal_eph.delta_n_3;
|
|
|
|
rtklib_sat.OMG0 = gal_eph.OMEGA_0_2;
|
|
|
|
rtklib_sat.OMGd = gal_eph.OMEGA_dot_3;
|
|
|
|
rtklib_sat.omg = gal_eph.omega_2;
|
|
|
|
rtklib_sat.i0 = gal_eph.i_0_2;
|
|
|
|
rtklib_sat.idot = gal_eph.iDot_2;
|
|
|
|
rtklib_sat.e = gal_eph.e_1;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.Adot = 0; //only in CNAV;
|
|
|
|
rtklib_sat.ndot = 0; //only in CNAV;
|
2017-04-21 09:34:23 +00:00
|
|
|
|
|
|
|
rtklib_sat.week = adjgpsweek(gal_eph.WN_5); /* week of tow */
|
|
|
|
rtklib_sat.cic = gal_eph.C_ic_4;
|
|
|
|
rtklib_sat.cis = gal_eph.C_is_4;
|
|
|
|
rtklib_sat.cuc = gal_eph.C_uc_3;
|
|
|
|
rtklib_sat.cus = gal_eph.C_us_3;
|
|
|
|
rtklib_sat.crc = gal_eph.C_rc_3;
|
|
|
|
rtklib_sat.crs = gal_eph.C_rs_3;
|
|
|
|
rtklib_sat.f0 = gal_eph.af0_4;
|
|
|
|
rtklib_sat.f1 = gal_eph.af1_4;
|
|
|
|
rtklib_sat.f2 = gal_eph.af2_4;
|
2017-11-20 11:31:49 +00:00
|
|
|
rtklib_sat.tgd[0] = gal_eph.BGD_E1E5a_5;
|
|
|
|
rtklib_sat.tgd[1] = gal_eph.BGD_E1E5b_5;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.tgd[2] = 0;
|
|
|
|
rtklib_sat.tgd[3] = 0;
|
|
|
|
rtklib_sat.toes = gal_eph.t0e_1;
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, gal_eph.t0c_4);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, gal_eph.TOW_5);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
/* adjustment for week handover */
|
|
|
|
double tow, toc;
|
2017-04-22 22:36:57 +00:00
|
|
|
tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week);
|
2018-12-03 09:05:47 +00:00
|
|
|
toc = time2gpst(rtklib_sat.toc, nullptr);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (rtklib_sat.toes < tow - 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week++;
|
|
|
|
tow -= 604800.0;
|
|
|
|
}
|
|
|
|
else if (rtklib_sat.toes > tow + 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week--;
|
|
|
|
tow += 604800.0;
|
|
|
|
}
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.toe = gpst2time(rtklib_sat.week, rtklib_sat.toes);
|
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, toc);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, tow);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
return rtklib_sat;
|
|
|
|
}
|
|
|
|
|
2017-04-21 09:34:23 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
eph_t eph_to_rtklib(const Gps_Ephemeris& gps_eph)
|
2017-04-20 14:10:12 +00:00
|
|
|
{
|
2017-04-25 16:27:23 +00:00
|
|
|
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
2018-11-05 16:53:53 +00:00
|
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0};
|
2017-04-20 14:10:12 +00:00
|
|
|
rtklib_sat.sat = gps_eph.i_satellite_PRN;
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.A = gps_eph.d_sqrt_A * gps_eph.d_sqrt_A;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.M0 = gps_eph.d_M_0;
|
|
|
|
rtklib_sat.deln = gps_eph.d_Delta_n;
|
|
|
|
rtklib_sat.OMG0 = gps_eph.d_OMEGA0;
|
|
|
|
rtklib_sat.OMGd = gps_eph.d_OMEGA_DOT;
|
|
|
|
rtklib_sat.omg = gps_eph.d_OMEGA;
|
|
|
|
rtklib_sat.i0 = gps_eph.d_i_0;
|
|
|
|
rtklib_sat.idot = gps_eph.d_IDOT;
|
|
|
|
rtklib_sat.e = gps_eph.d_e_eccentricity;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.Adot = 0; //only in CNAV;
|
|
|
|
rtklib_sat.ndot = 0; //only in CNAV;
|
2017-04-21 09:34:23 +00:00
|
|
|
|
|
|
|
rtklib_sat.week = adjgpsweek(gps_eph.i_GPS_week); /* week of tow */
|
|
|
|
rtklib_sat.cic = gps_eph.d_Cic;
|
|
|
|
rtklib_sat.cis = gps_eph.d_Cis;
|
|
|
|
rtklib_sat.cuc = gps_eph.d_Cuc;
|
|
|
|
rtklib_sat.cus = gps_eph.d_Cus;
|
|
|
|
rtklib_sat.crc = gps_eph.d_Crc;
|
|
|
|
rtklib_sat.crs = gps_eph.d_Crs;
|
|
|
|
rtklib_sat.f0 = gps_eph.d_A_f0;
|
|
|
|
rtklib_sat.f1 = gps_eph.d_A_f1;
|
|
|
|
rtklib_sat.f2 = gps_eph.d_A_f2;
|
|
|
|
rtklib_sat.tgd[0] = gps_eph.d_TGD;
|
2018-03-06 14:58:48 +00:00
|
|
|
rtklib_sat.tgd[1] = 0.0;
|
|
|
|
rtklib_sat.tgd[2] = 0.0;
|
|
|
|
rtklib_sat.tgd[3] = 0.0;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.toes = gps_eph.d_Toe;
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, gps_eph.d_Toc);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, gps_eph.d_TOW);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
/* adjustment for week handover */
|
|
|
|
double tow, toc;
|
2017-04-22 22:36:57 +00:00
|
|
|
tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week);
|
2018-12-03 09:05:47 +00:00
|
|
|
toc = time2gpst(rtklib_sat.toc, nullptr);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (rtklib_sat.toes < tow - 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week++;
|
|
|
|
tow -= 604800.0;
|
|
|
|
}
|
|
|
|
else if (rtklib_sat.toes > tow + 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week--;
|
|
|
|
tow += 604800.0;
|
|
|
|
}
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.toe = gpst2time(rtklib_sat.week, rtklib_sat.toes);
|
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, toc);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, tow);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
return rtklib_sat;
|
|
|
|
}
|
2017-04-21 09:34:23 +00:00
|
|
|
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
eph_t eph_to_rtklib(const Gps_CNAV_Ephemeris& gps_cnav_eph)
|
2017-04-20 14:10:12 +00:00
|
|
|
{
|
2017-04-25 16:27:23 +00:00
|
|
|
eph_t rtklib_sat = {0, 0, 0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {0, 0}, 0.0, 0.0, 0.0, 0.0, 0.0,
|
2018-11-05 16:53:53 +00:00
|
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0};
|
2017-04-20 14:10:12 +00:00
|
|
|
rtklib_sat.sat = gps_cnav_eph.i_satellite_PRN;
|
2018-03-03 01:03:39 +00:00
|
|
|
const double A_REF = 26559710.0; // See IS-GPS-200H, pp. 170
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.A = A_REF + gps_cnav_eph.d_DELTA_A;
|
|
|
|
rtklib_sat.M0 = gps_cnav_eph.d_M_0;
|
|
|
|
rtklib_sat.deln = gps_cnav_eph.d_Delta_n;
|
|
|
|
rtklib_sat.OMG0 = gps_cnav_eph.d_OMEGA0;
|
2017-04-20 14:10:12 +00:00
|
|
|
// Compute the angle between the ascending node and the Greenwich meridian
|
2018-03-03 01:03:39 +00:00
|
|
|
const double OMEGA_DOT_REF = -2.6e-9; // semicircles / s, see IS-GPS-200H pp. 164
|
2017-12-11 11:17:01 +00:00
|
|
|
double d_OMEGA_DOT = OMEGA_DOT_REF * PI + gps_cnav_eph.d_DELTA_OMEGA_DOT;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.OMGd = d_OMEGA_DOT;
|
|
|
|
rtklib_sat.omg = gps_cnav_eph.d_OMEGA;
|
|
|
|
rtklib_sat.i0 = gps_cnav_eph.d_i_0;
|
|
|
|
rtklib_sat.idot = gps_cnav_eph.d_IDOT;
|
|
|
|
rtklib_sat.e = gps_cnav_eph.d_e_eccentricity;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.Adot = gps_cnav_eph.d_A_DOT; //only in CNAV;
|
|
|
|
rtklib_sat.ndot = gps_cnav_eph.d_DELTA_DOT_N; //only in CNAV;
|
2017-04-21 09:34:23 +00:00
|
|
|
|
|
|
|
rtklib_sat.week = adjgpsweek(gps_cnav_eph.i_GPS_week); /* week of tow */
|
|
|
|
rtklib_sat.cic = gps_cnav_eph.d_Cic;
|
|
|
|
rtklib_sat.cis = gps_cnav_eph.d_Cis;
|
|
|
|
rtklib_sat.cuc = gps_cnav_eph.d_Cuc;
|
|
|
|
rtklib_sat.cus = gps_cnav_eph.d_Cus;
|
|
|
|
rtklib_sat.crc = gps_cnav_eph.d_Crc;
|
|
|
|
rtklib_sat.crs = gps_cnav_eph.d_Crs;
|
|
|
|
rtklib_sat.f0 = gps_cnav_eph.d_A_f0;
|
|
|
|
rtklib_sat.f1 = gps_cnav_eph.d_A_f1;
|
|
|
|
rtklib_sat.f2 = gps_cnav_eph.d_A_f2;
|
|
|
|
rtklib_sat.tgd[0] = gps_cnav_eph.d_TGD;
|
2018-03-05 12:07:41 +00:00
|
|
|
rtklib_sat.tgd[1] = 0.0;
|
|
|
|
rtklib_sat.tgd[2] = 0.0;
|
|
|
|
rtklib_sat.tgd[3] = 0.0;
|
|
|
|
rtklib_sat.isc[0] = gps_cnav_eph.d_ISCL1;
|
|
|
|
rtklib_sat.isc[1] = gps_cnav_eph.d_ISCL2;
|
|
|
|
rtklib_sat.isc[2] = gps_cnav_eph.d_ISCL5I;
|
|
|
|
rtklib_sat.isc[3] = gps_cnav_eph.d_ISCL5Q;
|
2017-04-21 09:34:23 +00:00
|
|
|
rtklib_sat.toes = gps_cnav_eph.d_Toe1;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, gps_cnav_eph.d_Toc);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, gps_cnav_eph.d_TOW);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
/* adjustment for week handover */
|
|
|
|
double tow, toc;
|
2017-04-22 22:36:57 +00:00
|
|
|
tow = time2gpst(rtklib_sat.ttr, &rtklib_sat.week);
|
2018-12-03 09:05:47 +00:00
|
|
|
toc = time2gpst(rtklib_sat.toc, nullptr);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (rtklib_sat.toes < tow - 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week++;
|
|
|
|
tow -= 604800.0;
|
|
|
|
}
|
|
|
|
else if (rtklib_sat.toes > tow + 302400.0)
|
|
|
|
{
|
|
|
|
rtklib_sat.week--;
|
|
|
|
tow += 604800.0;
|
|
|
|
}
|
2017-04-22 22:36:57 +00:00
|
|
|
rtklib_sat.toe = gpst2time(rtklib_sat.week, rtklib_sat.toes);
|
|
|
|
rtklib_sat.toc = gpst2time(rtklib_sat.week, toc);
|
|
|
|
rtklib_sat.ttr = gpst2time(rtklib_sat.week, tow);
|
2017-04-20 14:10:12 +00:00
|
|
|
|
|
|
|
return rtklib_sat;
|
|
|
|
}
|
2018-11-05 16:53:53 +00:00
|
|
|
|
|
|
|
alm_t alm_to_rtklib(const Gps_Almanac& gps_alm)
|
|
|
|
{
|
|
|
|
alm_t rtklib_alm;
|
|
|
|
|
|
|
|
rtklib_alm = {0, 0, 0, 0, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
|
|
|
rtklib_alm.sat = gps_alm.i_satellite_PRN;
|
|
|
|
rtklib_alm.svh = gps_alm.i_SV_health;
|
|
|
|
rtklib_alm.svconf = gps_alm.i_AS_status;
|
|
|
|
rtklib_alm.week = gps_alm.i_WNa;
|
2018-11-22 14:19:36 +00:00
|
|
|
gtime_t toa;
|
|
|
|
toa.time = gps_alm.i_Toa;
|
|
|
|
rtklib_alm.toa = toa;
|
2018-11-05 16:53:53 +00:00
|
|
|
rtklib_alm.A = gps_alm.d_sqrt_A * gps_alm.d_sqrt_A;
|
|
|
|
rtklib_alm.e = gps_alm.d_e_eccentricity;
|
2018-11-22 14:19:36 +00:00
|
|
|
rtklib_alm.i0 = (gps_alm.d_Delta_i + 0.3) * PI;
|
|
|
|
rtklib_alm.OMG0 = gps_alm.d_OMEGA0 * PI;
|
|
|
|
rtklib_alm.OMGd = gps_alm.d_OMEGA_DOT * PI;
|
|
|
|
rtklib_alm.omg = gps_alm.d_OMEGA * PI;
|
|
|
|
rtklib_alm.M0 = gps_alm.d_M_0 * PI;
|
2018-11-05 16:53:53 +00:00
|
|
|
rtklib_alm.f0 = gps_alm.d_A_f0;
|
|
|
|
rtklib_alm.f1 = gps_alm.d_A_f1;
|
2018-11-07 21:25:09 +00:00
|
|
|
rtklib_alm.toas = gps_alm.i_Toa;
|
2018-11-05 16:53:53 +00:00
|
|
|
|
|
|
|
return rtklib_alm;
|
|
|
|
}
|
2018-11-22 10:59:49 +00:00
|
|
|
|
|
|
|
|
2018-11-05 16:53:53 +00:00
|
|
|
alm_t alm_to_rtklib(const Galileo_Almanac& gal_alm)
|
|
|
|
{
|
|
|
|
alm_t rtklib_alm;
|
|
|
|
|
|
|
|
rtklib_alm = {0, 0, 0, 0, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
2018-11-22 10:59:49 +00:00
|
|
|
rtklib_alm.sat = gal_alm.i_satellite_PRN + NSATGPS + NSATGLO;
|
2018-11-05 16:53:53 +00:00
|
|
|
rtklib_alm.svh = gal_alm.E1B_HS;
|
|
|
|
rtklib_alm.svconf = gal_alm.E1B_HS;
|
2018-11-07 21:25:09 +00:00
|
|
|
rtklib_alm.week = gal_alm.i_WNa;
|
2018-11-22 10:59:49 +00:00
|
|
|
gtime_t toa;
|
|
|
|
toa.time = gal_alm.i_Toa;
|
|
|
|
rtklib_alm.toa = toa;
|
2018-11-05 16:53:53 +00:00
|
|
|
rtklib_alm.A = 5440.588203494 + gal_alm.d_Delta_sqrt_A;
|
|
|
|
rtklib_alm.A = rtklib_alm.A * rtklib_alm.A;
|
|
|
|
rtklib_alm.e = gal_alm.d_e_eccentricity;
|
2018-11-22 10:59:49 +00:00
|
|
|
rtklib_alm.i0 = (gal_alm.d_Delta_i + 56.0 / 180.0) * PI;
|
|
|
|
rtklib_alm.OMG0 = gal_alm.d_OMEGA0 * PI;
|
|
|
|
rtklib_alm.OMGd = gal_alm.d_OMEGA_DOT * PI;
|
|
|
|
rtklib_alm.omg = gal_alm.d_OMEGA * PI;
|
|
|
|
rtklib_alm.M0 = gal_alm.d_M_0 * PI;
|
2018-11-05 16:53:53 +00:00
|
|
|
rtklib_alm.f0 = gal_alm.d_A_f0;
|
|
|
|
rtklib_alm.f1 = gal_alm.d_A_f1;
|
2018-11-07 21:25:09 +00:00
|
|
|
rtklib_alm.toas = gal_alm.i_Toa;
|
2018-11-05 16:53:53 +00:00
|
|
|
|
|
|
|
return rtklib_alm;
|
|
|
|
}
|