From fd69416f4e602d0c1a28e566ba2110fbccc227b6 Mon Sep 17 00:00:00 2001 From: "M.A.Gomez" Date: Sat, 11 Mar 2023 18:56:08 +0000 Subject: [PATCH] fix: bug in mat vtl and pvt files --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 3 ++ src/algorithms/PVT/libs/rtklib_solver.cc | 28 +++++++++++++------ src/algorithms/PVT/libs/rtklib_solver.h | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index e43cda93f..236cd78d6 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -251,6 +251,9 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, std::cerr << "GNSS-SDR cannot create dump file for the PVT block. Wrong permissions?\n"; d_dump = false; } + // TODO: if(vtl_enable) then + // uint end_filename = d_dump_filename.length()-4; + // d_vtl_dump_filename = d_dump_filename.insert(end_filename, "_vtl"); } // initialize kml_printer diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 2b474868d..f5696a96b 100755 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -162,14 +162,17 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, LOG(WARNING) << "Exception opening RTKLIB dump file " << e.what(); } } + // TODO: if(vtl_enable) then if (d_vtl_dump_file.is_open() == false) { try { d_vtl_dump_file.exceptions(std::ofstream::failbit | std::ofstream::badbit); - int end_filename = d_dump_filename.length()-4; - d_vtl_dump_file.open(d_dump_filename.insert(end_filename, "_vtl"), std::ios::out | std::ios::binary); - LOG(INFO) << "PVT VTL dump enabled Log file: " << d_dump_filename + "_vtl"; + uint end_filename = d_dump_filename.length()-4; + d_vtl_dump_filename = d_dump_filename; + d_vtl_dump_filename = d_vtl_dump_filename.insert(end_filename, "_vtl"); + d_vtl_dump_file.open(d_vtl_dump_filename, std::ios::out | std::ios::binary); + LOG(INFO) << "PVT VTL dump enabled Log file: " << d_vtl_dump_filename; } catch (const std::ofstream::failure &e) { @@ -209,20 +212,30 @@ Rtklib_Solver::~Rtklib_Solver() try { save_matfile(); - save_vtl_matfile(); } catch (const std::exception &ex) { LOG(WARNING) << "Exception in destructor saving the PVT .mat dump file " << ex.what(); } } + if (d_flag_dump_mat_enabled) + { + try + { + save_vtl_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor saving the PVT VTL .mat dump file " << ex.what(); + } + } } bool Rtklib_Solver::save_vtl_matfile() const { // READ DUMP FILE - const std::string dump_filename = d_dump_filename+ "_vtl"; + const std::string dump_filename = d_vtl_dump_filename; const int32_t number_of_double_vars = 27; const int32_t number_of_uint32_vars = 2; const int32_t number_of_uint8_vars = 1; @@ -233,7 +246,7 @@ bool Rtklib_Solver::save_vtl_matfile() const dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); try { - dump_file.open(dump_filename.c_str(), std::ios::binary | std::ios::ate); + dump_file.open(dump_filename, std::ios::binary | std::ios::ate); } catch (const std::ifstream::failure &e) { @@ -254,7 +267,6 @@ bool Rtklib_Solver::save_vtl_matfile() const return false; } - //todo: cambiarlo auto TOW_at_current_symbol_ms = std::vector(num_epoch); auto week = std::vector(num_epoch); auto RX_time = std::vector(num_epoch); @@ -328,7 +340,7 @@ bool Rtklib_Solver::save_vtl_matfile() const } catch (const std::ifstream::failure &e) { - std::cerr << "Problem reading dump file:" << e.what() << '\n'; + std::cerr << "Problem reading VTL dump file:" << e.what() << '\n'; return false; } diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index d6781beb8..3f3b05ad3 100755 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -152,6 +152,7 @@ private: std::map> d_has_obs_corr_map; // first key is signal, second key is PRN std::string d_dump_filename; + std::string d_vtl_dump_filename; std::ofstream d_dump_file; std::ofstream d_vtl_dump_file; rtk_t d_rtk{};