GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
rtklib_pvt_gs.h
Go to the documentation of this file.
1 /*!
2  * \file rtklib_pvt_gs.h
3  * \brief Interface of a Position Velocity and Time computation block
4  * \author Javier Arribas, 2017. jarribas(at)cttc.es
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
9  *
10  * GNSS-SDR is a software defined Global Navigation
11  * Satellite Systems receiver
12  *
13  * This file is part of GNSS-SDR.
14  *
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 #ifndef GNSS_SDR_RTKLIB_PVT_GS_H
21 #define GNSS_SDR_RTKLIB_PVT_GS_H
22 
23 #include "gnss_synchro.h"
24 #include "rtklib.h"
25 #include <boost/date_time/gregorian/gregorian.hpp>
26 #include <boost/date_time/posix_time/posix_time.hpp>
27 #include <gnuradio/sync_block.h> // for sync_block
28 #include <gnuradio/types.h> // for gr_vector_const_void_star
29 #include <pmt/pmt.h> // for pmt_t
30 #include <chrono> // for system_clock
31 #include <cstddef> // for size_t
32 #include <cstdint> // for int32_t
33 #include <ctime> // for time_t
34 #include <map> // for map
35 #include <memory> // for shared_ptr, unique_ptr
36 #include <string> // for string
37 #include <sys/types.h> // for key_t
38 #include <vector> // for vector
39 #if GNURADIO_USES_STD_POINTERS
40 #else
41 #include <boost/shared_ptr.hpp>
42 #endif
43 
46 class Galileo_Almanac;
47 class Galileo_Ephemeris;
48 class GeoJSON_Printer;
49 class Gps_Almanac;
50 class Gps_Ephemeris;
51 class Gpx_Printer;
52 class Kml_Printer;
54 class Nmea_Printer;
55 class Pvt_Conf;
56 class Rinex_Printer;
57 class Rtcm_Printer;
58 class Rtklib_Solver;
59 class rtklib_pvt_gs;
60 
61 #if GNURADIO_USES_STD_POINTERS
62 using rtklib_pvt_gs_sptr = std::shared_ptr<rtklib_pvt_gs>;
63 #else
64 using rtklib_pvt_gs_sptr = boost::shared_ptr<rtklib_pvt_gs>;
65 #endif
66 
67 rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
68  const Pvt_Conf& conf_,
69  const rtk_t& rtk);
70 
71 /*!
72  * \brief This class implements a block that computes the PVT solution using the RTKLIB integrated library
73  */
74 class rtklib_pvt_gs : public gr::sync_block
75 {
76 public:
77  ~rtklib_pvt_gs(); //!< Default destructor
78 
79  /*!
80  * \brief Get latest set of GPS ephemeris from PVT block
81  */
82  std::map<int, Gps_Ephemeris> get_gps_ephemeris_map() const;
83 
84  /*!
85  * \brief Get latest set of GPS almanac from PVT block
86  */
87  std::map<int, Gps_Almanac> get_gps_almanac_map() const;
88 
89  /*!
90  * \brief Get latest set of Galileo ephemeris from PVT block
91  */
92  std::map<int, Galileo_Ephemeris> get_galileo_ephemeris_map() const;
93 
94  /*!
95  * \brief Get latest set of Galileo almanac from PVT block
96  */
97  std::map<int, Galileo_Almanac> get_galileo_almanac_map() const;
98 
99  /*!
100  * \brief Get latest set of BeiDou DNAV ephemeris from PVT block
101  */
102  std::map<int, Beidou_Dnav_Ephemeris> get_beidou_dnav_ephemeris_map() const;
103 
104  /*!
105  * \brief Get latest set of BeiDou DNAV almanac from PVT block
106  */
107  std::map<int, Beidou_Dnav_Almanac> get_beidou_dnav_almanac_map() const;
108 
109  /*!
110  * \brief Clear all ephemeris information and the almanacs for GPS and Galileo
111  */
112  void clear_ephemeris();
113 
114  /*!
115  * \brief Get the latest Position WGS84 [deg], Ground Velocity, Course over Ground, and UTC Time, if available
116  */
117  bool get_latest_PVT(double* longitude_deg,
118  double* latitude_deg,
119  double* height_m,
120  double* ground_speed_kmh,
121  double* course_over_ground_deg,
122  time_t* UTC_time) const;
123 
124  int work(int noutput_items, gr_vector_const_void_star& input_items,
125  gr_vector_void_star& output_items); //!< PVT Signal Processing
126 
127 private:
128  friend rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
129  const Pvt_Conf& conf_,
130  const rtk_t& rtk);
131 
132  rtklib_pvt_gs(uint32_t nchannels,
133  const Pvt_Conf& conf_,
134  const rtk_t& rtk);
135 
136  void msg_handler_telemetry(const pmt::pmt_t& msg);
137 
138  void initialize_and_apply_carrier_phase_offset();
139 
140  void apply_rx_clock_offset(std::map<int, Gnss_Synchro>& observables_map,
141  double rx_clock_offset_s);
142 
143  std::map<int, Gnss_Synchro> interpolate_observables(const std::map<int, Gnss_Synchro>& observables_map_t0,
144  const std::map<int, Gnss_Synchro>& observables_map_t1,
145  double rx_time_s);
146 
147  inline std::time_t convert_to_time_t(const boost::posix_time::ptime pt) const
148  {
149  return (pt - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds();
150  }
151 
152  std::vector<std::string> split_string(const std::string& s, char delim) const;
153 
154  typedef struct
155  {
156  long mtype; // NOLINT(google-runtime-int) required by SysV queue messaging
157  double ttff;
158  } d_ttff_msgbuf;
159  bool send_sys_v_ttff_msg(d_ttff_msgbuf ttff);
160 
161  bool save_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
162  bool load_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
163 
164  std::shared_ptr<Rtklib_Solver> d_internal_pvt_solver;
165  std::shared_ptr<Rtklib_Solver> d_user_pvt_solver;
166 
167  std::unique_ptr<Rinex_Printer> d_rp;
168  std::unique_ptr<Kml_Printer> d_kml_dump;
169  std::unique_ptr<Gpx_Printer> d_gpx_dump;
170  std::unique_ptr<Nmea_Printer> d_nmea_printer;
171  std::unique_ptr<GeoJSON_Printer> d_geojson_printer;
172  std::unique_ptr<Rtcm_Printer> d_rtcm_printer;
173  std::unique_ptr<Monitor_Pvt_Udp_Sink> d_udp_sink_ptr;
174 
175  std::chrono::time_point<std::chrono::system_clock> d_start;
176  std::chrono::time_point<std::chrono::system_clock> d_end;
177 
178  std::string d_dump_filename;
179  std::string d_xml_base_path;
180  std::string d_local_time_str;
181 
182  std::vector<bool> d_channel_initialized;
183  std::vector<double> d_initial_carrier_phase_offset_estimation_rads;
184 
185  enum StringValue_
186  {
187  evGPS_1C,
188  evGPS_2S,
189  evGPS_L5,
190  evSBAS_1C,
191  evGAL_1B,
192  evGAL_5X,
193  evGLO_1G,
194  evGLO_2G,
195  evBDS_B1,
196  evBDS_B2,
197  evBDS_B3
198  };
199  std::map<std::string, StringValue_> d_mapStringValues;
200  std::map<int, Gnss_Synchro> d_gnss_observables_map;
201  std::map<int, Gnss_Synchro> d_gnss_observables_map_t0;
202  std::map<int, Gnss_Synchro> d_gnss_observables_map_t1;
203 
204  boost::posix_time::time_duration d_utc_diff_time;
205 
206  size_t d_gps_ephemeris_sptr_type_hash_code;
207  size_t d_gps_iono_sptr_type_hash_code;
208  size_t d_gps_utc_model_sptr_type_hash_code;
209  size_t d_gps_cnav_ephemeris_sptr_type_hash_code;
210  size_t d_gps_cnav_iono_sptr_type_hash_code;
211  size_t d_gps_cnav_utc_model_sptr_type_hash_code;
212  size_t d_gps_almanac_sptr_type_hash_code;
213  size_t d_galileo_ephemeris_sptr_type_hash_code;
214  size_t d_galileo_iono_sptr_type_hash_code;
215  size_t d_galileo_utc_model_sptr_type_hash_code;
216  size_t d_galileo_almanac_helper_sptr_type_hash_code;
217  size_t d_galileo_almanac_sptr_type_hash_code;
218  size_t d_glonass_gnav_ephemeris_sptr_type_hash_code;
219  size_t d_glonass_gnav_utc_model_sptr_type_hash_code;
220  size_t d_glonass_gnav_almanac_sptr_type_hash_code;
221  size_t d_beidou_dnav_ephemeris_sptr_type_hash_code;
222  size_t d_beidou_dnav_iono_sptr_type_hash_code;
223  size_t d_beidou_dnav_utc_model_sptr_type_hash_code;
224  size_t d_beidou_dnav_almanac_sptr_type_hash_code;
225 
226  double d_rinex_version;
227  double d_rx_time;
228 
229  key_t d_sysv_msg_key;
230  int d_sysv_msqid;
231 
232  int32_t d_rinexobs_rate_ms;
233  int32_t d_rtcm_MT1045_rate_ms; // Galileo Broadcast Ephemeris
234  int32_t d_rtcm_MT1019_rate_ms; // GPS Broadcast Ephemeris (orbits)
235  int32_t d_rtcm_MT1020_rate_ms; // GLONASS Broadcast Ephemeris (orbits)
236  int32_t d_rtcm_MT1077_rate_ms; // The type 7 Multiple Signal Message format for the USA’s GPS system, popular
237  int32_t d_rtcm_MT1087_rate_ms; // GLONASS MSM7. The type 7 Multiple Signal Message format for the Russian GLONASS system
238  int32_t d_rtcm_MT1097_rate_ms; // Galileo MSM7. The type 7 Multiple Signal Message format for Europe’s Galileo system
239  int32_t d_rtcm_MSM_rate_ms;
240  int32_t d_kml_rate_ms;
241  int32_t d_gpx_rate_ms;
242  int32_t d_geojson_rate_ms;
243  int32_t d_nmea_rate_ms;
244  int32_t d_last_status_print_seg; // for status printer
245  int32_t d_output_rate_ms;
246  int32_t d_display_rate_ms;
247  int32_t d_report_rate_ms;
248  int32_t d_max_obs_block_rx_clock_offset_ms;
249 
250  uint32_t d_nchannels;
251  uint32_t d_type_of_rx;
252 
253  bool d_dump;
254  bool d_dump_mat;
255  bool d_rinex_output_enabled;
256  bool d_rinex_header_written;
257  bool d_rinex_header_updated;
258  bool d_geojson_output_enabled;
259  bool d_gpx_output_enabled;
260  bool d_kml_output_enabled;
261  bool d_nmea_output_file_enabled;
262  bool d_first_fix;
263  bool d_xml_storage;
264  bool d_flag_monitor_pvt_enabled;
265  bool d_show_local_time_zone;
266  bool d_waiting_obs_block_rx_clock_offset_correction_msg;
267  bool d_enable_rx_clock_correction;
268  bool d_rtcm_writing_started;
269  bool d_rtcm_enabled;
270 };
271 
272 #endif // GNSS_SDR_RTKLIB_PVT_GS_H
This class is a storage for the BeiDou D1 almanac.
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
Definition: gps_ephemeris.h:36
bool get_latest_PVT(double *longitude_deg, double *latitude_deg, double *height_m, double *ground_speed_kmh, double *course_over_ground_deg, time_t *UTC_time) const
Get the latest Position WGS84 [deg], Ground Velocity, Course over Ground, and UTC Time...
Class that handles the generation of Receiver INdependent EXchange format (RINEX) files...
Definition: rinex_printer.h:75
This class is a storage for the Galileo SV ALMANAC data.
This class provides a implementation of a subset of the RTCM Standard 10403.2 messages.
Definition: rtcm_printer.h:43
std::map< int, Galileo_Almanac > get_galileo_almanac_map() const
Get latest set of Galileo almanac from PVT block.
This class implements a block that computes the PVT solution using the RTKLIB integrated library...
Definition: rtklib_pvt_gs.h:74
This class implements a PVT solution based on RTKLIB.
Definition: rtklib_solver.h:69
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in Bei...
std::map< int, Beidou_Dnav_Almanac > get_beidou_dnav_almanac_map() const
Get latest set of BeiDou DNAV almanac from PVT block.
main header file for the rtklib library
~rtklib_pvt_gs()
Default destructor.
This class provides a implementation of a subset of the NMEA-0183 standard for interfacing marine ele...
Definition: nmea_printer.h:41
std::map< int, Galileo_Ephemeris > get_galileo_ephemeris_map() const
Get latest set of Galileo ephemeris from PVT block.
Prints PVT solutions in GeoJSON format file.
This class is a storage and orbital model functions for the Galileo SV ephemeris data as described in...
std::map< int, Gps_Ephemeris > get_gps_ephemeris_map() const
Get latest set of GPS ephemeris from PVT block.
void clear_ephemeris()
Clear all ephemeris information and the almanacs for GPS and Galileo.
This class is a storage for the GPS SV ALMANAC data as described in IS-GPS-200K.
Definition: gps_almanac.h:32
Prints PVT information to GPX format file.
Definition: gpx_printer.h:36
Prints PVT information to OGC KML format file (can be viewed with Google Earth)
Definition: kml_printer.h:35
Definition: rtklib.h:1059
std::map< int, Beidou_Dnav_Ephemeris > get_beidou_dnav_ephemeris_map() const
Get latest set of BeiDou DNAV ephemeris from PVT block.
std::map< int, Gps_Almanac > get_gps_almanac_map() const
Get latest set of GPS almanac from PVT block.
Interface of the Gnss_Synchro class.
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
PVT Signal Processing.