mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-19 08:35:16 +00:00
Added RTKLib solver unit test
This commit is contained in:
@@ -50,6 +50,10 @@ namespace bc = boost::math;
|
||||
namespace bc = boost::integer;
|
||||
#endif
|
||||
|
||||
//includes used by the observables serializarion (export observables for rtklib unit test)
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
@@ -507,6 +511,53 @@ bool rtklib_pvt_cc::send_sys_v_ttff_msg(ttff_msgbuf ttff)
|
||||
}
|
||||
|
||||
|
||||
bool rtklib_pvt_cc::save_gnss_synchro_map_xml(const std::string file_name)
|
||||
{
|
||||
if (gnss_observables_map.empty() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map);
|
||||
ofs.close();
|
||||
LOG(INFO) << "Saved gnss_sychro map data";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG(WARNING) << e.what();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << "Failed to save gnss_synchro, map is empty";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool rtklib_pvt_cc::load_gnss_synchro_map_xml(const std::string file_name)
|
||||
{
|
||||
//load from xml (boost serialize)
|
||||
try
|
||||
{
|
||||
std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
|
||||
boost::archive::xml_iarchive xml(ifs);
|
||||
gnss_observables_map.clear();
|
||||
xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map);
|
||||
ifs.close();
|
||||
return true;
|
||||
//std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cout << e.what() << "File: " << file_name;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items __attribute__((unused)))
|
||||
{
|
||||
@@ -526,7 +577,6 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item
|
||||
|
||||
gnss_observables_map.clear();
|
||||
const Gnss_Synchro** in = reinterpret_cast<const Gnss_Synchro**>(&input_items[0]); // Get the input buffer pointer
|
||||
|
||||
// ############ 1. READ PSEUDORANGES ####
|
||||
for (uint32_t i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
@@ -610,8 +660,15 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item
|
||||
// it->second.Pseudorange_m = it->second.Pseudorange_m - d_ls_pvt->get_time_offset_s() * GPS_C_m_s;
|
||||
// }
|
||||
|
||||
|
||||
if (d_ls_pvt->get_PVT(gnss_observables_map, false))
|
||||
{
|
||||
//Optional debug code: export observables snapshot for rtklib unit testing
|
||||
//std::cout << "step 1: save gnss_synchro map" << std::endl;
|
||||
//save_gnss_synchro_map_xml("./gnss_synchro_map.xml");
|
||||
//getchar(); //stop the execution
|
||||
//end debug
|
||||
|
||||
if (current_RX_time_ms % d_display_rate_ms == 0)
|
||||
{
|
||||
flag_display_pvt = true;
|
||||
@@ -2060,7 +2117,6 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item
|
||||
{
|
||||
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));
|
||||
|
||||
|
||||
@@ -152,6 +152,10 @@ private:
|
||||
bool send_sys_v_ttff_msg(ttff_msgbuf ttff);
|
||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
|
||||
bool save_gnss_synchro_map_xml(const std::string file_name); //debug helper function
|
||||
|
||||
bool load_gnss_synchro_map_xml(const std::string file_name); //debug helper function
|
||||
|
||||
public:
|
||||
rtklib_pvt_cc(uint32_t nchannels,
|
||||
bool dump, std::string dump_filename,
|
||||
|
||||
@@ -76,12 +76,13 @@ private:
|
||||
rtk_t rtk_;
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
sol_t pvt_sol;
|
||||
|
||||
bool d_flag_dump_enabled;
|
||||
int d_nchannels; // Number of available channels for positioning
|
||||
double dop_[4];
|
||||
|
||||
public:
|
||||
sol_t pvt_sol;
|
||||
rtklib_solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, rtk_t& rtk);
|
||||
~rtklib_solver();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user