diff --git a/docs/changelog b/docs/changelog index 42942beff..549c049c3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ ### Improvements in Availability - Fixed bug that caused a random deadlock in the Observables block, preventing the computation of PVT fixes. +- Fixed bug in Galileo INAV message decoding when PLL is locked at 180 degrees, which prevented from correct navigation message decoding in some situations. ### Improvements in Efficiency @@ -42,6 +43,7 @@ - The receiver now admits FPGA off-loading, allowing for real time operation at high sampling rates and higher number of signals and channels. - Fixed program termination (avoiding hangs and segfaults in some platforms/configurations). - CMake now generates a summary of enabled/disabled features. This info is also stored in a file called features.log in the building directory. +- New parameter PVT.show_local_time_zone displays time in the local time zone. Subject to the proper system configuration of the machine running the software receiver. - Improved information provided to the user in case of failure. diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 7a6ae02ce..ca19c2006 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -714,6 +714,9 @@ Rtklib_Pvt::Rtklib_Pvt(ConfigurationInterface* configuration, pvt_output_parameters.udp_addresses = configuration->property(role + ".monitor_client_addresses", std::string("127.0.0.1")); pvt_output_parameters.udp_port = configuration->property(role + ".monitor_udp_port", 1234); + // Show time in local zone + pvt_output_parameters.show_local_time_zone = configuration->property(role + ".show_local_time_zone", false); + // make PVT object pvt_ = rtklib_make_pvt_gs(in_streams_, pvt_output_parameters, rtk); DLOG(INFO) << "pvt(" << pvt_->unique_id() << ")"; diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index da71df27f..09e49a576 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -76,7 +76,10 @@ #include // for sort, unique #include // for exception #include // for ofstream +#include // for put_time, setprecision #include // for operator<< +#include // for locale +#include // for ostringstream #include // for length_error #include // for IPC_CREAT #include // for msgctl @@ -361,6 +364,39 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, throw std::exception(); } + // Display time in local time zone + d_show_local_time_zone = conf_.show_local_time_zone; + time_t when = std::time(nullptr); + auto const tm = *std::localtime(&when); + std::ostringstream os; + os << std::put_time(&tm, "%z"); + std::string utc_diff_str = os.str(); // in ISO 8601 format: "+HHMM" or "-HHMM" + if (utc_diff_str.empty()) + { + utc_diff_str = "+0000"; + } + int h = std::stoi(utc_diff_str.substr(0, 3), nullptr, 10); + int m = std::stoi(utc_diff_str[0] + utc_diff_str.substr(3), nullptr, 10); + d_utc_diff_time = boost::posix_time::hours(h) + boost::posix_time::minutes(m); + std::ostringstream os2; + os2 << std::put_time(&tm, "%Z"); + std::string time_zone_abrv = os2.str(); + if (time_zone_abrv.empty()) + { + if (utc_diff_str == "+0000") + { + d_local_time_str = " UTC"; + } + else + { + d_local_time_str = " (UTC " + utc_diff_str.substr(0, 3) + ":" + utc_diff_str.substr(3, 2) + ")"; + } + } + else + { + d_local_time_str = std::string(" ") + time_zone_abrv + " (UTC " + utc_diff_str.substr(0, 3) + ":" + utc_diff_str.substr(3, 2) + ")"; + } + d_pvt_solver = std::make_shared(static_cast(nchannels), dump_ls_pvt_filename, d_dump, d_dump_mat, rtk); d_pvt_solver->set_averaging_depth(1); start = std::chrono::system_clock::now(); @@ -1464,8 +1500,16 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item if (first_fix == true) { - std::cout << "First position fix at " << boost::posix_time::to_simple_string(d_pvt_solver->get_position_UTC_time()) - << " UTC is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + if (d_show_local_time_zone) + { + boost::posix_time::ptime time_first_solution = d_pvt_solver->get_position_UTC_time() + d_utc_diff_time; + std::cout << "First position fix at " << time_first_solution << d_local_time_str; + } + else + { + std::cout << "First position fix at " << d_pvt_solver->get_position_UTC_time() << " UTC"; + } + std::cout << " is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() << " [deg], Height= " << d_pvt_solver->get_height() << " [m]" << std::endl; ttff_msgbuf ttff; ttff.mtype = 1; @@ -3287,18 +3331,31 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item // DEBUG MESSAGE: Display position in console output if (d_pvt_solver->is_valid_position() and flag_display_pvt) { + boost::posix_time::ptime time_solution; + std::string UTC_solution_str; + if (d_show_local_time_zone) + { + time_solution = d_pvt_solver->get_position_UTC_time() + d_utc_diff_time; + UTC_solution_str = d_local_time_str; + } + else + { + time_solution = d_pvt_solver->get_position_UTC_time(); + UTC_solution_str = " UTC"; + } std::streamsize ss = std::cout.precision(); // save current precision std::cout.setf(std::ios::fixed, std::ios::floatfield); auto facet = new boost::posix_time::time_facet("%Y-%b-%d %H:%M:%S.%f %z"); std::cout.imbue(std::locale(std::cout.getloc(), facet)); + std::cout + << TEXT_BOLD_GREEN + << "Position at " << time_solution << UTC_solution_str + << " using " << d_pvt_solver->get_num_valid_observations() + << std::fixed << std::setprecision(9) + << " observations is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() + << std::fixed << std::setprecision(3) + << " [deg], Height = " << d_pvt_solver->get_height() << " [m]" << TEXT_RESET << std::endl; - std::cout << TEXT_BOLD_GREEN - << "Position at " << d_pvt_solver->get_position_UTC_time() - << " UTC using " << d_pvt_solver->get_num_valid_observations() - << std::fixed << std::setprecision(9) - << " observations is Lat = " << d_pvt_solver->get_latitude() << " [deg], Long = " << d_pvt_solver->get_longitude() - << std::fixed << std::setprecision(3) - << " [deg], Height = " << d_pvt_solver->get_height() << " [m]" << TEXT_RESET << std::endl; std::cout << std::setprecision(ss); DLOG(INFO) << "RX clock offset: " << d_pvt_solver->get_time_offset_s() << "[s]"; diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h index 4e3df2672..9744426d1 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h @@ -162,6 +162,10 @@ private: std::unique_ptr udp_sink_ptr; std::vector split_string(const std::string& s, char delim) const; + bool d_show_local_time_zone; + std::string d_local_time_str; + boost::posix_time::time_duration d_utc_diff_time; + public: ~rtklib_pvt_gs(); //!< Default destructor diff --git a/src/algorithms/PVT/libs/pvt_conf.cc b/src/algorithms/PVT/libs/pvt_conf.cc index 6a1e1023c..bd74b4900 100644 --- a/src/algorithms/PVT/libs/pvt_conf.cc +++ b/src/algorithms/PVT/libs/pvt_conf.cc @@ -70,4 +70,6 @@ Pvt_Conf::Pvt_Conf() monitor_enabled = false; udp_port = 0; + + show_local_time_zone = false; } diff --git a/src/algorithms/PVT/libs/pvt_conf.h b/src/algorithms/PVT/libs/pvt_conf.h index 484961cb2..f22eb8fe2 100644 --- a/src/algorithms/PVT/libs/pvt_conf.h +++ b/src/algorithms/PVT/libs/pvt_conf.h @@ -83,6 +83,8 @@ public: std::string udp_addresses; int udp_port; + bool show_local_time_zone; + Pvt_Conf(); }; diff --git a/src/algorithms/PVT/libs/rtcm.h b/src/algorithms/PVT/libs/rtcm.h index 28ef66e71..6fd3129b8 100644 --- a/src/algorithms/PVT/libs/rtcm.h +++ b/src/algorithms/PVT/libs/rtcm.h @@ -58,7 +58,7 @@ /*! - * \brief This class implements the generation and reading of some Message Types + * \brief This class implements the generation and reading of some Message Types * defined in the RTCM 3.2 Standard, plus some utilities to handle messages. * * Generation of the following Message Types: @@ -144,6 +144,7 @@ public: * \return string with message contents */ std::string print_MT1009(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id); + /*! * \brief Prints Extended L1-Only GLONASS RTK Observables * \details This GLONASS message type is used when only L1 data is present and bandwidth is very tight, often 1012 is used in such cases. @@ -154,6 +155,7 @@ public: * \return string with message contents */ std::string print_MT1010(const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double obs_time, const std::map& observables, uint16_t station_id); + /*! * \brief Prints L1&L2 GLONASS RTK Observables * \details This GLONASS message type is not generally used or supported; type 1012 is to be preferred @@ -164,6 +166,7 @@ public: * \return string with message contents */ std::string print_MT1011(const Glonass_Gnav_Ephemeris& glonass_gnav_ephL1, const Glonass_Gnav_Ephemeris& glonass_gnav_ephL2, double obs_time, const std::map& observables, uint16_t station_id); + /*! * \brief Prints Extended L1&L2 GLONASS RTK Observables * \details This GLONASS message type is the most common observational message type, with L1/L2/SNR content. This is one of the most common messages found. @@ -335,6 +338,7 @@ public: uint32_t lock_time(const Gps_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); //!< Returns the time period in which GPS L1 signals have been continually tracked. uint32_t lock_time(const Gps_CNAV_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); //!< Returns the time period in which GPS L2 signals have been continually tracked. uint32_t lock_time(const Galileo_Ephemeris& eph, double obs_time, const Gnss_Synchro& gnss_synchro); //!< Returns the time period in which Galileo signals have been continually tracked. + /*! * \brief Locks time period in which GLONASS signals have been continually tracked. * \note Code added as part of GSoC 2017 program diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 35c7b3939..83935ef39 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -51,7 +51,6 @@ *----------------------------------------------------------------------------*/ #include "rtklib_rtkcmn.h" -//#include #include #include #include