GNSS-SDR  0.0.20
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  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
9  * This file is part of GNSS-SDR.
10  *
11  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
12  * SPDX-License-Identifier: GPL-3.0-or-later
13  *
14  * -----------------------------------------------------------------------------
15  */
16 
17 #ifndef GNSS_SDR_RTKLIB_PVT_GS_H
18 #define GNSS_SDR_RTKLIB_PVT_GS_H
19 
20 #include "gnss_block_interface.h"
21 #include "gnss_sdr_make_unique.h"
22 #include "gnss_synchro.h"
23 #include "gnss_time.h"
24 #include "osnma_data.h"
25 #include "rtklib.h"
26 #include <boost/date_time/gregorian/gregorian.hpp>
27 #include <boost/date_time/posix_time/posix_time.hpp>
28 #include <boost/interprocess/ipc/message_queue.hpp>
29 #include <gnuradio/sync_block.h> // for sync_block
30 #include <gnuradio/types.h> // for gr_vector_const_void_star
31 #include <pmt/pmt.h> // for pmt_t
32 #include <chrono> // for system_clock
33 #include <cstddef> // for size_t
34 #include <cstdint> // for int32_t
35 #include <ctime> // for time_t
36 #include <fstream> // for std::fstream
37 #include <map> // for map
38 #include <memory> // for shared_ptr, unique_ptr
39 #include <queue> // for std::queue
40 #include <set> // for std::set
41 #include <string> // for string
42 #include <vector> // for vector
43 
44 /** \addtogroup PVT
45  * \{ */
46 /** \addtogroup PVT_gnuradio_blocks pvt_gr_blocks
47  * GNU Radio blocks for the computation of PVT solutions.
48  * \{ */
49 
50 
53 class Galileo_Almanac;
54 class Galileo_Ephemeris;
55 class Galileo_HAS_data;
56 class Geohash;
57 class GeoJSON_Printer;
58 class Gps_Almanac;
59 class Gps_Ephemeris;
60 class Gpx_Printer;
61 class Kml_Printer;
64 class Nmea_Printer;
65 class Pvt_Conf;
66 class Rinex_Printer;
67 class Rtcm_Printer;
68 class An_Packet_Printer;
69 class Has_Simple_Printer;
70 class Rtklib_Solver;
71 class rtklib_pvt_gs;
72 
73 using rtklib_pvt_gs_sptr = gnss_shared_ptr<rtklib_pvt_gs>;
74 
75 rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
76  const Pvt_Conf& conf_,
77  const rtk_t& rtk);
78 
79 /*!
80  * \brief This class implements a block that computes the PVT solution using the RTKLIB integrated library
81  */
82 class rtklib_pvt_gs : public gr::sync_block
83 {
84 public:
85  ~rtklib_pvt_gs(); //!< Default destructor
86 
87  /*!
88  * \brief Get latest set of GPS ephemeris from PVT block
89  */
90  std::map<int, Gps_Ephemeris> get_gps_ephemeris_map() const;
91 
92  /*!
93  * \brief Get latest set of GPS almanac from PVT block
94  */
95  std::map<int, Gps_Almanac> get_gps_almanac_map() const;
96 
97  /*!
98  * \brief Get latest set of Galileo ephemeris from PVT block
99  */
100  std::map<int, Galileo_Ephemeris> get_galileo_ephemeris_map() const;
101 
102  /*!
103  * \brief Get latest set of Galileo almanac from PVT block
104  */
105  std::map<int, Galileo_Almanac> get_galileo_almanac_map() const;
106 
107  /*!
108  * \brief Get latest set of BeiDou DNAV ephemeris from PVT block
109  */
110  std::map<int, Beidou_Dnav_Ephemeris> get_beidou_dnav_ephemeris_map() const;
111 
112  /*!
113  * \brief Get latest set of BeiDou DNAV almanac from PVT block
114  */
115  std::map<int, Beidou_Dnav_Almanac> get_beidou_dnav_almanac_map() const;
116 
117  /*!
118  * \brief Clear all ephemeris information and the almanacs for GPS and Galileo
119  */
120  void clear_ephemeris();
121 
122  /*!
123  * \brief Get the latest Position WGS84 [deg], Ground Velocity, Course over Ground, and UTC Time, if available
124  */
125  bool get_latest_PVT(double* longitude_deg,
126  double* latitude_deg,
127  double* height_m,
128  double* ground_speed_kmh,
129  double* course_over_ground_deg,
130  time_t* UTC_time) const;
131 
132  int work(int noutput_items, gr_vector_const_void_star& input_items,
133  gr_vector_void_star& output_items); //!< PVT Signal Processing
134 
135 private:
136  friend rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
137  const Pvt_Conf& conf_,
138  const rtk_t& rtk);
139 
140  rtklib_pvt_gs(uint32_t nchannels,
141  const Pvt_Conf& conf_,
142  const rtk_t& rtk);
143 
144  void log_source_timetag_info(double RX_time_ns, double TAG_time_ns);
145 
146  void msg_handler_telemetry(const pmt::pmt_t& msg);
147 
148  void msg_handler_has_data(const pmt::pmt_t& msg);
149 
150  void msg_handler_osnma(const pmt::pmt_t& msg);
151 
152  void initialize_and_apply_carrier_phase_offset();
153 
154  void apply_rx_clock_offset(std::map<int, Gnss_Synchro>& observables_map,
155  double rx_clock_offset_s);
156 
157  void update_HAS_corrections();
158 
159  std::map<int, Gnss_Synchro> interpolate_observables(const std::map<int, Gnss_Synchro>& observables_map_t0,
160  const std::map<int, Gnss_Synchro>& observables_map_t1,
161  double rx_time_s);
162 
163  inline std::time_t convert_to_time_t(const boost::posix_time::ptime pt) const
164  {
165  return (pt - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds();
166  }
167 
168  std::vector<std::string> split_string(const std::string& s, char delim) const;
169 
170  bool send_ttff_msg(double ttff) const;
171  bool save_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
172  bool load_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
173 
174  std::fstream d_log_timetag_file;
175 
176  std::shared_ptr<Rtklib_Solver> d_internal_pvt_solver;
177  std::shared_ptr<Rtklib_Solver> d_user_pvt_solver;
178 
179  std::unique_ptr<boost::interprocess::message_queue> d_mq;
180 
181  std::unique_ptr<Rinex_Printer> d_rp;
182  std::unique_ptr<Kml_Printer> d_kml_dump;
183  std::unique_ptr<Gpx_Printer> d_gpx_dump;
184  std::unique_ptr<Nmea_Printer> d_nmea_printer;
185  std::unique_ptr<GeoJSON_Printer> d_geojson_printer;
186  std::unique_ptr<Rtcm_Printer> d_rtcm_printer;
187  std::unique_ptr<Monitor_Pvt_Udp_Sink> d_udp_sink_ptr;
188  std::unique_ptr<Monitor_Ephemeris_Udp_Sink> d_eph_udp_sink_ptr;
189  std::unique_ptr<Has_Simple_Printer> d_has_simple_printer;
190  std::unique_ptr<An_Packet_Printer> d_an_printer;
191 
192  std::chrono::time_point<std::chrono::system_clock> d_start;
193  std::chrono::time_point<std::chrono::system_clock> d_end;
194 
195  std::string d_queue_name;
196  std::string d_dump_filename;
197  std::string d_xml_base_path;
198  std::string d_local_time_str;
199 
200  std::vector<bool> d_channel_initialized;
201  std::vector<double> d_initial_carrier_phase_offset_estimation_rads;
202 
203  std::map<int, Gnss_Synchro> d_gnss_observables_map;
204  std::map<int, Gnss_Synchro> d_gnss_observables_map_t0;
205  std::map<int, Gnss_Synchro> d_gnss_observables_map_t1;
206  std::map<uint32_t, std::set<uint32_t>> d_auth_nav_data_map;
207 
208  std::queue<GnssTime> d_TimeChannelTagTimestamps;
209 
210  boost::posix_time::time_duration d_utc_diff_time;
211  std::unique_ptr<Geohash> d_geohash;
212 
213  size_t d_gps_ephemeris_sptr_type_hash_code;
214  size_t d_gps_iono_sptr_type_hash_code;
215  size_t d_gps_utc_model_sptr_type_hash_code;
216  size_t d_gps_cnav_ephemeris_sptr_type_hash_code;
217  size_t d_gps_cnav_iono_sptr_type_hash_code;
218  size_t d_gps_cnav_utc_model_sptr_type_hash_code;
219  size_t d_gps_almanac_sptr_type_hash_code;
220  size_t d_galileo_ephemeris_sptr_type_hash_code;
221  size_t d_galileo_iono_sptr_type_hash_code;
222  size_t d_galileo_utc_model_sptr_type_hash_code;
223  size_t d_galileo_almanac_helper_sptr_type_hash_code;
224  size_t d_galileo_almanac_sptr_type_hash_code;
225  size_t d_glonass_gnav_ephemeris_sptr_type_hash_code;
226  size_t d_glonass_gnav_utc_model_sptr_type_hash_code;
227  size_t d_glonass_gnav_almanac_sptr_type_hash_code;
228  size_t d_beidou_dnav_ephemeris_sptr_type_hash_code;
229  size_t d_beidou_dnav_iono_sptr_type_hash_code;
230  size_t d_beidou_dnav_utc_model_sptr_type_hash_code;
231  size_t d_beidou_dnav_almanac_sptr_type_hash_code;
232  size_t d_galileo_has_data_sptr_type_hash_code;
233 
234  double d_rinex_version;
235  double d_rx_time;
236  uint64_t d_local_counter_ms;
237  uint64_t d_timestamp_rx_clock_offset_correction_msg_ms;
238 
239  int32_t d_rinexobs_rate_ms;
240  int32_t d_rtcm_MT1045_rate_ms; // Galileo Broadcast Ephemeris
241  int32_t d_rtcm_MT1019_rate_ms; // GPS Broadcast Ephemeris (orbits)
242  int32_t d_rtcm_MT1020_rate_ms; // GLONASS Broadcast Ephemeris (orbits)
243  int32_t d_rtcm_MT1077_rate_ms; // The type 7 Multiple Signal Message format for the USA’s GPS system, popular
244  int32_t d_rtcm_MT1087_rate_ms; // GLONASS MSM7. The type 7 Multiple Signal Message format for the Russian GLONASS system
245  int32_t d_rtcm_MT1097_rate_ms; // Galileo MSM7. The type 7 Multiple Signal Message format for Europe’s Galileo system
246  int32_t d_rtcm_MSM_rate_ms;
247  int32_t d_kml_rate_ms;
248  int32_t d_gpx_rate_ms;
249  int32_t d_geojson_rate_ms;
250  int32_t d_nmea_rate_ms;
251  int32_t d_an_rate_ms;
252  int32_t d_output_rate_ms;
253  int32_t d_display_rate_ms;
254  int32_t d_report_rate_ms;
255  int32_t d_max_obs_block_rx_clock_offset_ms;
256 
257  uint32_t d_nchannels;
258  uint32_t d_type_of_rx;
259  uint32_t d_observable_interval_ms;
260  uint32_t d_pvt_errors_counter;
261 
262  bool d_dump;
263  bool d_dump_mat;
264  bool d_rinex_output_enabled;
265  bool d_geojson_output_enabled;
266  bool d_gpx_output_enabled;
267  bool d_kml_output_enabled;
268  bool d_nmea_output_file_enabled;
269  bool d_rtcm_enabled;
270  bool d_first_fix;
271  bool d_xml_storage;
272  bool d_flag_monitor_pvt_enabled;
273  bool d_flag_monitor_ephemeris_enabled;
274  bool d_show_local_time_zone;
275  bool d_enable_rx_clock_correction;
276  bool d_enable_has_messages;
277  bool d_an_printer_enabled;
278  bool d_log_timetag;
279  bool d_use_has_corrections;
280  bool d_use_unhealthy_sats;
281  bool d_osnma_strict;
282 };
283 
284 
285 /** \} */
286 /** \} */
287 #endif // GNSS_SDR_RTKLIB_PVT_GS_H
This class is a storage for the BeiDou D1 almanac.
class that stores both the receiver time, relative to the receiver start and the GNSS time (absolute)...
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
Definition: gps_ephemeris.h:40
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...
Prints HAS messages content in a txt file. See HAS-SIS-ICD for a message description.
Class for Galileo OSNMA data storage.
class that prints PVT solutions in a serial device following a custom version of the Advanced Navigat...
Class that handles the generation of Receiver INdependent EXchange format (RINEX) files...
Definition: rinex_printer.h:83
This class is a storage for Galileo HAS message type 1, as defined in Galileo High Accuracy Service S...
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:48
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:82
This file implements std::make_unique for C++11.
This class implements a PVT solution based on RTKLIB.
Definition: rtklib_solver.h:81
This is a storage class for the Beidou SV ephemeris data as described in BeiDou Navigation Satellite ...
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
This interface represents a GNSS block.
~rtklib_pvt_gs()
Default destructor.
Class for geohash encoding / decoding See https://en.wikipedia.org/wiki/Geohash.
Definition: geohash.h:34
This class provides a implementation of a subset of the NMEA-0183 standard for interfacing marine ele...
Definition: nmea_printer.h:44
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-200M.
Definition: gps_almanac.h:35
Prints PVT information to GPX format file.
Definition: gpx_printer.h:39
Prints PVT information to OGC KML format file (can be viewed with Google Earth)
Definition: kml_printer.h:38
Definition: rtklib.h:1066
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.