GNSS-SDR  0.0.14
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_synchro.h"
22 #include "rtklib.h"
23 #include <boost/date_time/gregorian/gregorian.hpp>
24 #include <boost/date_time/posix_time/posix_time.hpp>
25 #include <gnuradio/sync_block.h> // for sync_block
26 #include <gnuradio/types.h> // for gr_vector_const_void_star
27 #include <pmt/pmt.h> // for pmt_t
28 #include <chrono> // for system_clock
29 #include <cstddef> // for size_t
30 #include <cstdint> // for int32_t
31 #include <ctime> // for time_t
32 #include <map> // for map
33 #include <memory> // for shared_ptr, unique_ptr
34 #include <string> // for string
35 #include <sys/types.h> // for key_t
36 #include <vector> // for vector
37 
38 /** \addtogroup PVT
39  * \{ */
40 /** \addtogroup PVT_gnuradio_blocks pvt_gr_blocks
41  * GNU Radio blocks for the computation of PVT solutions.
42  * \{ */
43 
44 
47 class Galileo_Almanac;
48 class Galileo_Ephemeris;
49 class GeoJSON_Printer;
50 class Gps_Almanac;
51 class Gps_Ephemeris;
52 class Gpx_Printer;
53 class Kml_Printer;
55 class Nmea_Printer;
56 class Pvt_Conf;
57 class Rinex_Printer;
58 class Rtcm_Printer;
59 class Rtklib_Solver;
60 class rtklib_pvt_gs;
61 
62 using rtklib_pvt_gs_sptr = gnss_shared_ptr<rtklib_pvt_gs>;
63 
64 rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
65  const Pvt_Conf& conf_,
66  const rtk_t& rtk);
67 
68 /*!
69  * \brief This class implements a block that computes the PVT solution using the RTKLIB integrated library
70  */
71 class rtklib_pvt_gs : public gr::sync_block
72 {
73 public:
74  ~rtklib_pvt_gs(); //!< Default destructor
75 
76  /*!
77  * \brief Get latest set of GPS ephemeris from PVT block
78  */
79  std::map<int, Gps_Ephemeris> get_gps_ephemeris_map() const;
80 
81  /*!
82  * \brief Get latest set of GPS almanac from PVT block
83  */
84  std::map<int, Gps_Almanac> get_gps_almanac_map() const;
85 
86  /*!
87  * \brief Get latest set of Galileo ephemeris from PVT block
88  */
89  std::map<int, Galileo_Ephemeris> get_galileo_ephemeris_map() const;
90 
91  /*!
92  * \brief Get latest set of Galileo almanac from PVT block
93  */
94  std::map<int, Galileo_Almanac> get_galileo_almanac_map() const;
95 
96  /*!
97  * \brief Get latest set of BeiDou DNAV ephemeris from PVT block
98  */
99  std::map<int, Beidou_Dnav_Ephemeris> get_beidou_dnav_ephemeris_map() const;
100 
101  /*!
102  * \brief Get latest set of BeiDou DNAV almanac from PVT block
103  */
104  std::map<int, Beidou_Dnav_Almanac> get_beidou_dnav_almanac_map() const;
105 
106  /*!
107  * \brief Clear all ephemeris information and the almanacs for GPS and Galileo
108  */
109  void clear_ephemeris();
110 
111  /*!
112  * \brief Get the latest Position WGS84 [deg], Ground Velocity, Course over Ground, and UTC Time, if available
113  */
114  bool get_latest_PVT(double* longitude_deg,
115  double* latitude_deg,
116  double* height_m,
117  double* ground_speed_kmh,
118  double* course_over_ground_deg,
119  time_t* UTC_time) const;
120 
121  int work(int noutput_items, gr_vector_const_void_star& input_items,
122  gr_vector_void_star& output_items); //!< PVT Signal Processing
123 
124 private:
125  friend rtklib_pvt_gs_sptr rtklib_make_pvt_gs(uint32_t nchannels,
126  const Pvt_Conf& conf_,
127  const rtk_t& rtk);
128 
129  rtklib_pvt_gs(uint32_t nchannels,
130  const Pvt_Conf& conf_,
131  const rtk_t& rtk);
132 
133  void msg_handler_telemetry(const pmt::pmt_t& msg);
134 
135  void initialize_and_apply_carrier_phase_offset();
136 
137  void apply_rx_clock_offset(std::map<int, Gnss_Synchro>& observables_map,
138  double rx_clock_offset_s);
139 
140  std::map<int, Gnss_Synchro> interpolate_observables(const std::map<int, Gnss_Synchro>& observables_map_t0,
141  const std::map<int, Gnss_Synchro>& observables_map_t1,
142  double rx_time_s);
143 
144  inline std::time_t convert_to_time_t(const boost::posix_time::ptime pt) const
145  {
146  return (pt - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds();
147  }
148 
149  std::vector<std::string> split_string(const std::string& s, char delim) const;
150 
151  typedef struct
152  {
153  long mtype; // NOLINT(google-runtime-int) required by SysV queue messaging
154  double ttff;
155  } d_ttff_msgbuf;
156  bool send_sys_v_ttff_msg(d_ttff_msgbuf ttff) const;
157 
158  bool save_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
159  bool load_gnss_synchro_map_xml(const std::string& file_name); // debug helper function
160 
161  std::shared_ptr<Rtklib_Solver> d_internal_pvt_solver;
162  std::shared_ptr<Rtklib_Solver> d_user_pvt_solver;
163 
164  std::unique_ptr<Rinex_Printer> d_rp;
165  std::unique_ptr<Kml_Printer> d_kml_dump;
166  std::unique_ptr<Gpx_Printer> d_gpx_dump;
167  std::unique_ptr<Nmea_Printer> d_nmea_printer;
168  std::unique_ptr<GeoJSON_Printer> d_geojson_printer;
169  std::unique_ptr<Rtcm_Printer> d_rtcm_printer;
170  std::unique_ptr<Monitor_Pvt_Udp_Sink> d_udp_sink_ptr;
171 
172  std::chrono::time_point<std::chrono::system_clock> d_start;
173  std::chrono::time_point<std::chrono::system_clock> d_end;
174 
175  std::string d_dump_filename;
176  std::string d_xml_base_path;
177  std::string d_local_time_str;
178 
179  std::vector<bool> d_channel_initialized;
180  std::vector<double> d_initial_carrier_phase_offset_estimation_rads;
181 
182  enum StringValue_
183  {
184  evGPS_1C,
185  evGPS_2S,
186  evGPS_L5,
187  evSBAS_1C,
188  evGAL_1B,
189  evGAL_5X,
190  evGAL_E6,
191  evGAL_7X,
192  evGLO_1G,
193  evGLO_2G,
194  evBDS_B1,
195  evBDS_B2,
196  evBDS_B3
197  };
198  std::map<std::string, StringValue_> d_mapStringValues;
199  std::map<int, Gnss_Synchro> d_gnss_observables_map;
200  std::map<int, Gnss_Synchro> d_gnss_observables_map_t0;
201  std::map<int, Gnss_Synchro> d_gnss_observables_map_t1;
202 
203  boost::posix_time::time_duration d_utc_diff_time;
204 
205  size_t d_gps_ephemeris_sptr_type_hash_code;
206  size_t d_gps_iono_sptr_type_hash_code;
207  size_t d_gps_utc_model_sptr_type_hash_code;
208  size_t d_gps_cnav_ephemeris_sptr_type_hash_code;
209  size_t d_gps_cnav_iono_sptr_type_hash_code;
210  size_t d_gps_cnav_utc_model_sptr_type_hash_code;
211  size_t d_gps_almanac_sptr_type_hash_code;
212  size_t d_galileo_ephemeris_sptr_type_hash_code;
213  size_t d_galileo_iono_sptr_type_hash_code;
214  size_t d_galileo_utc_model_sptr_type_hash_code;
215  size_t d_galileo_almanac_helper_sptr_type_hash_code;
216  size_t d_galileo_almanac_sptr_type_hash_code;
217  size_t d_glonass_gnav_ephemeris_sptr_type_hash_code;
218  size_t d_glonass_gnav_utc_model_sptr_type_hash_code;
219  size_t d_glonass_gnav_almanac_sptr_type_hash_code;
220  size_t d_beidou_dnav_ephemeris_sptr_type_hash_code;
221  size_t d_beidou_dnav_iono_sptr_type_hash_code;
222  size_t d_beidou_dnav_utc_model_sptr_type_hash_code;
223  size_t d_beidou_dnav_almanac_sptr_type_hash_code;
224 
225  double d_rinex_version;
226  double d_rx_time;
227 
228  key_t d_sysv_msg_key;
229  int d_sysv_msqid;
230 
231  int32_t d_rinexobs_rate_ms;
232  int32_t d_rtcm_MT1045_rate_ms; // Galileo Broadcast Ephemeris
233  int32_t d_rtcm_MT1019_rate_ms; // GPS Broadcast Ephemeris (orbits)
234  int32_t d_rtcm_MT1020_rate_ms; // GLONASS Broadcast Ephemeris (orbits)
235  int32_t d_rtcm_MT1077_rate_ms; // The type 7 Multiple Signal Message format for the USA’s GPS system, popular
236  int32_t d_rtcm_MT1087_rate_ms; // GLONASS MSM7. The type 7 Multiple Signal Message format for the Russian GLONASS system
237  int32_t d_rtcm_MT1097_rate_ms; // Galileo MSM7. The type 7 Multiple Signal Message format for Europe’s Galileo system
238  int32_t d_rtcm_MSM_rate_ms;
239  int32_t d_kml_rate_ms;
240  int32_t d_gpx_rate_ms;
241  int32_t d_geojson_rate_ms;
242  int32_t d_nmea_rate_ms;
243  int32_t d_last_status_print_seg; // for status printer
244  int32_t d_output_rate_ms;
245  int32_t d_display_rate_ms;
246  int32_t d_report_rate_ms;
247  int32_t d_max_obs_block_rx_clock_offset_ms;
248 
249  uint32_t d_nchannels;
250  uint32_t d_type_of_rx;
251 
252  bool d_dump;
253  bool d_dump_mat;
254  bool d_rinex_output_enabled;
255  bool d_geojson_output_enabled;
256  bool d_gpx_output_enabled;
257  bool d_kml_output_enabled;
258  bool d_nmea_output_file_enabled;
259  bool d_rtcm_enabled;
260  bool d_first_fix;
261  bool d_xml_storage;
262  bool d_flag_monitor_pvt_enabled;
263  bool d_show_local_time_zone;
264  bool d_waiting_obs_block_rx_clock_offset_correction_msg;
265  bool d_enable_rx_clock_correction;
266 };
267 
268 
269 /** \} */
270 /** \} */
271 #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:38
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:82
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:47
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:71
This class implements a PVT solution based on RTKLIB.
Definition: rtklib_solver.h:75
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
This interface represents a GNSS block.
~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: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-200K.
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:1067
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.