From 305a81a4131ac1eea0a0edbe71654f0fc529444e Mon Sep 17 00:00:00 2001 From: Damian Miralles Date: Sun, 20 Aug 2017 21:23:57 -0700 Subject: [PATCH] tel_dec: Fixing GLONASS GNAV Telemetry Decoder Fixes GLONASS L1 CA telemetry decoder and creating connections with observables blocks before PVT computation. Fixes documentation and code style in the block --- .../glonass_l1_ca_telemetry_decoder.cc | 4 +-- .../glonass_l1_ca_telemetry_decoder.h | 1 + .../glonass_l1_ca_telemetry_decoder_cc.cc | 25 ++++++++++++----- .../glonass_l1_ca_telemetry_decoder_cc.h | 27 ++++++++++--------- src/core/receiver/gnss_block_factory.cc | 13 +++++++++ 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc index 868fb3304..924efd2da 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc @@ -2,6 +2,7 @@ * \file glonass_l1_ca_telemetry_decoder.cc * \brief Implementation of an adapter of a GLONASS L1 C/A NAV data decoder block * to a TelemetryDecoderInterface + * \note Code added as part of GSoC 2017 program * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com * * ------------------------------------------------------------------------- @@ -36,7 +37,6 @@ #include "concurrent_queue.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" -#include "glonass_gnav_iono.h" #include "glonass_gnav_utc_model.h" #include "configuration_interface.h" @@ -55,7 +55,7 @@ GlonassL1CaTelemetryDecoder::GlonassL1CaTelemetryDecoder(ConfigurationInterface* dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); // make telemetry decoder object - telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_cc(satellite_, dump_); // TODO fix me + telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_cc(satellite_, dump_); DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; DLOG(INFO) << "global navigation message queue assigned to telemetry_decoder ("<< telemetry_decoder_->unique_id() << ")"; diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h index d9d883a71..e79f586c9 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h @@ -2,6 +2,7 @@ * \file glonass_l1_ca_telemetry_decoder.h * \brief Interface of an adapter of a GLONASS L1 C/A NAV data decoder block * to a TelemetryDecoderInterface + * \note Code added as part of GSoC 2017 program * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com * * ------------------------------------------------------------------------- diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index 6318977f5..c0273edaf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -1,8 +1,9 @@ /*! - * \file galileo_e1b_telemetry_decoder_cc.cc - * \brief Implementation of a Galileo INAV message demodulator block - * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com - * \author Javier Arribas 2013. jarribas(at)cttc.es + * \file glonass_l1_ca_telemetry_decoder_cc.cc + * \brief Implementation of an adapter of a GLONASS L1 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \note Code added as part of GSoC 2017 program + * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com * * ------------------------------------------------------------------------- * @@ -30,7 +31,7 @@ */ -#include "galileo_e1b_telemetry_decoder_cc.h" +#include "glonass_l1_ca_telemetry_decoder_cc.h" #include #include #include @@ -67,7 +68,7 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( // initialize internal vars d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "Initializing GLONASS L1CA TELEMETRY PROCESSING"; + LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY PROCESSING"; // TODO. WHAT IS THIS? d_samples_per_symbol = ( GLONASS_L1_CODE_CHIP_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS ) / GLONASS_L1_CA_SYMBOL_RATE_BPS; @@ -115,7 +116,17 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( glonass_l1_ca_telemetry_decoder_cc::~glonass_l1_ca_telemetry_decoder_cc() { delete d_preambles_symbols; - d_dump_file.close(); + if(d_dump_file.is_open() == true) + { + try + { + d_dump_file.close(); + } + catch(const std::exception & ex) + { + LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); + } + } } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index bfd9d975e..eab2136e2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -1,6 +1,8 @@ /*! * \file glonass_l1_ca_telemetry_decoder_cc.h - * \brief Interface of a GLONASS GNAV message demodulator block + * \brief Implementation of an adapter of a GLONASS L1 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \note Code added as part of GSoC 2017 program * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com * * ------------------------------------------------------------------------- @@ -40,7 +42,6 @@ #include "glonass_gnav_navigation_message.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" -#include "glonass_gnav_iono.h" #include "glonass_gnav_utc_model.h" #include "gnss_synchro.h" @@ -53,15 +54,17 @@ typedef boost::shared_ptr glonass_l1_ca_tele glonass_l1_ca_telemetry_decoder_cc_sptr glonass_l1_ca_make_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump); /*! - * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD + * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1 + * \note Code added as part of GSoC 2017 program + * \see GLONASS ICD * */ class glonass_l1_ca_telemetry_decoder_cc : public gr::block { public: - ~glonass_l1_ca_telemetry_decoder_cc(); - void set_satellite(Gnss_Satellite satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel + ~glonass_l1_ca_telemetry_decoder_cc(); //!< Class destructor + void set_satellite(Gnss_Satellite satellite); //!< Set satellite PRN + void set_channel(int channel); //!< Set receiver's channel /*! * \brief This is where all signal processing takes place @@ -74,7 +77,7 @@ private: glonass_l1_ca_make_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump); glonass_l1_ca_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump); - void decode_word(double *symbols,int frame_length); + void decode_word(double *symbols); //!< Preamble decoding unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; @@ -91,11 +94,11 @@ private: unsigned int d_stat; //!< Status of decoder bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) - bool d_flag_preamble; - int d_CRC_error_counter; - bool flag_TOW_set; //!< - double delta_t; //!< GPS-GLONASS time offset - + bool d_flag_preamble; //!< Flag indicating when preamble was found + int d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset + //!< Navigation Message variable Glonass_Gnav_Navigation_Message d_nav; diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 7cba2a649..1f9c73529 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -92,6 +92,7 @@ #include "gps_l2c_telemetry_decoder.h" #include "galileo_e1b_telemetry_decoder.h" #include "galileo_e5a_telemetry_decoder.h" +#include "glonass_l1_ca_telemetry_decoder.h" #include "sbas_l1_telemetry_decoder.h" #include "hybrid_observables.h" #include "rtklib_pvt.h" @@ -1203,6 +1204,12 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams)); block = std::move(block_); } + else if (implementation.compare("GLONASS_L1_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GlonassL1CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } // OBSERVABLES ----------------------------------------------------------------- else if ((implementation.compare("Hybrid_Observables") == 0) || (implementation.compare("GPS_L1_CA_Observables") == 0) || (implementation.compare("GPS_L2C_Observables") == 0) || @@ -1347,6 +1354,12 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( out_streams)); block = std::move(block_); } + else if (implementation.compare("GLONASS_L1_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GlonassL1CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } else { // Log fatal. This causes execution to stop.