1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into tracking_debug

This commit is contained in:
Javier Arribas 2019-07-04 09:41:13 +02:00
commit b9ca99303c
5 changed files with 53 additions and 42 deletions

View File

@ -100,7 +100,8 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GROSMOSDR DEFAULT_MSG GROSMOSDR_LIBRARIES GROSMOSDR_INCLUDE_DIR) find_package_handle_standard_args(GROSMOSDR DEFAULT_MSG GROSMOSDR_LIBRARIES GROSMOSDR_INCLUDE_DIR)
if(GROSMOSDR_PKG_VERSION) if(GROSMOSDR_PKG_VERSION)
set(GROSMOSDR_VERSION ${GROSMOSDR_PKG_VERSION}) set(GROSMOSDR_VERSION_AUX ${GROSMOSDR_PKG_VERSION})
string(REGEX REPLACE "^v" "" GROSMOSDR_VERSION ${GROSMOSDR_VERSION_AUX})
endif() endif()
set_package_properties(GROSMOSDR PROPERTIES set_package_properties(GROSMOSDR PROPERTIES

View File

@ -50,6 +50,7 @@ public:
GOOGLE_PROTOBUF_VERIFY_VERSION; GOOGLE_PROTOBUF_VERIFY_VERSION;
monitor_.New(); monitor_.New();
} }
~Serdes_Monitor_Pvt() ~Serdes_Monitor_Pvt()
{ {
// google::protobuf::ShutdownProtobufLibrary(); // google::protobuf::ShutdownProtobufLibrary();
@ -94,7 +95,6 @@ public:
return data; return data;
} }
inline Monitor_Pvt readProtobuffer(const gnss_sdr::MonitorPvt& mon) //!< Deserialization inline Monitor_Pvt readProtobuffer(const gnss_sdr::MonitorPvt& mon) //!< Deserialization
{ {
Monitor_Pvt monitor; Monitor_Pvt monitor;

View File

@ -34,7 +34,7 @@
#ifndef GNSS_SDR_HYBRID_OBSERVABLES_GS_H #ifndef GNSS_SDR_HYBRID_OBSERVABLES_GS_H
#define GNSS_SDR_HYBRID_OBSERVABLES_GS_H #define GNSS_SDR_HYBRID_OBSERVABLES_GS_H
#include <boost/circular_buffer.hpp> // for boost::curcular_buffer #include <boost/circular_buffer.hpp> // for boost::circular_buffer
#include <boost/shared_ptr.hpp> // for boost::shared_ptr #include <boost/shared_ptr.hpp> // for boost::shared_ptr
#include <gnuradio/block.h> // for block #include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_int #include <gnuradio/types.h> // for gr_vector_int
@ -50,8 +50,12 @@ class Gnss_circular_deque;
using hybrid_observables_gs_sptr = boost::shared_ptr<hybrid_observables_gs>; using hybrid_observables_gs_sptr = boost::shared_ptr<hybrid_observables_gs>;
hybrid_observables_gs_sptr hybrid_observables_gs_sptr hybrid_observables_gs_make(
hybrid_observables_gs_make(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, bool dump_mat, std::string dump_filename); unsigned int nchannels_in,
unsigned int nchannels_out,
bool dump,
bool dump_mat,
std::string dump_filename);
/*! /*!
* \brief This class implements a block that computes observables * \brief This class implements a block that computes observables
@ -60,38 +64,44 @@ class hybrid_observables_gs : public gr::block
{ {
public: public:
~hybrid_observables_gs(); ~hybrid_observables_gs();
void forecast(int noutput_items, gr_vector_int& ninput_items_required);
int general_work(int noutput_items, gr_vector_int& ninput_items, int general_work(int noutput_items, gr_vector_int& ninput_items,
gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); gr_vector_const_void_star& input_items, gr_vector_void_star& output_items);
void forecast(int noutput_items, gr_vector_int& ninput_items_required);
private: private:
friend hybrid_observables_gs_sptr friend hybrid_observables_gs_sptr hybrid_observables_gs_make(
hybrid_observables_gs_make(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); uint32_t nchannels_in,
hybrid_observables_gs(uint32_t nchannels_in, uint32_t nchannels_out, bool dump, bool dump_mat, std::string dump_filename); uint32_t nchannels_out,
void msg_handler_pvt_to_observables(const pmt::pmt_t& msg); bool dump,
bool interpolate_data(Gnss_Synchro& out, const uint32_t& ch, const double& ti); bool dump_mat,
bool interp_trk_obs(Gnss_Synchro& interpolated_obs, const uint32_t& ch, const uint64_t& rx_clock); std::string dump_filename);
double compute_T_rx_s(const Gnss_Synchro& a);
void compute_pranges(std::vector<Gnss_Synchro>& data);
void update_TOW(const std::vector<Gnss_Synchro>& data);
int32_t save_matfile();
//time history hybrid_observables_gs(
boost::circular_buffer<uint64_t> d_Rx_clock_buffer; uint32_t nchannels_in,
//Tracking observable history uint32_t nchannels_out,
Gnss_circular_deque<Gnss_Synchro>* d_gnss_synchro_history; bool dump,
//rx time follow GPST bool dump_mat,
bool T_rx_TOW_set; std::string dump_filename);
bool T_rx_TOW_set; // rx time follow GPST
bool d_dump;
bool d_dump_mat;
uint32_t T_rx_TOW_ms; uint32_t T_rx_TOW_ms;
uint32_t T_rx_remnant_to_20ms; uint32_t T_rx_remnant_to_20ms;
uint32_t T_rx_step_ms; uint32_t T_rx_step_ms;
double T_rx_offset_ms;
bool d_dump;
bool d_dump_mat;
uint32_t d_nchannels_in; uint32_t d_nchannels_in;
uint32_t d_nchannels_out; uint32_t d_nchannels_out;
double T_rx_offset_ms;
std::string d_dump_filename; std::string d_dump_filename;
std::ofstream d_dump_file; std::ofstream d_dump_file;
boost::circular_buffer<uint64_t> d_Rx_clock_buffer; // time history
Gnss_circular_deque<Gnss_Synchro>* d_gnss_synchro_history; // Tracking observable history
void msg_handler_pvt_to_observables(const pmt::pmt_t& msg);
double compute_T_rx_s(const Gnss_Synchro& a);
bool interp_trk_obs(Gnss_Synchro& interpolated_obs, const uint32_t& ch, const uint64_t& rx_clock);
void update_TOW(const std::vector<Gnss_Synchro>& data);
void compute_pranges(std::vector<Gnss_Synchro>& data);
int32_t save_matfile();
}; };
#endif #endif

View File

@ -34,7 +34,7 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gnss_synchro.pb.h" // file created by Protocol Buffers at compile time #include "gnss_synchro.pb.h" // file created by Protocol Buffers at compile time
#include <cstring> // for memcpy #include <array>
#include <vector> #include <vector>
@ -52,6 +52,7 @@ public:
GOOGLE_PROTOBUF_VERIFY_VERSION; GOOGLE_PROTOBUF_VERIFY_VERSION;
observables.New(); observables.New();
} }
~Serdes_Gnss_Synchro() ~Serdes_Gnss_Synchro()
{ {
google::protobuf::ShutdownProtobufLibrary(); google::protobuf::ShutdownProtobufLibrary();
@ -60,21 +61,17 @@ public:
inline std::string createProtobuffer(const std::vector<Gnss_Synchro>& vgs) //!< Serialization into a string inline std::string createProtobuffer(const std::vector<Gnss_Synchro>& vgs) //!< Serialization into a string
{ {
observables.Clear(); observables.Clear();
std::string data; std::string data;
for (auto gs : vgs) for (auto gs : vgs)
{ {
gnss_sdr::GnssSynchro* obs = observables.add_observable(); gnss_sdr::GnssSynchro* obs = observables.add_observable();
char c[2]; char c = gs.System;
c[0] = gs.System; const std::string sys(1, c);
c[1] = '\0';
const std::string sys(c);
char cc[3]; std::array<char, 2> cc;
cc[0] = gs.Signal[0]; cc[0] = gs.Signal[0];
cc[1] = gs.Signal[1]; cc[1] = gs.Signal[1];
cc[2] = '\0'; const std::string sig(cc.cbegin(), cc.cend());
const std::string sig(cc);
obs->set_system(sys); obs->set_system(sys);
obs->set_signal(sig); obs->set_signal(sig);
@ -109,20 +106,18 @@ public:
return data; return data;
} }
inline std::vector<Gnss_Synchro> readProtobuffer(const gnss_sdr::Observables& obs) const //!< Deserialization
inline std::vector<Gnss_Synchro> readProtobuffer(const gnss_sdr::Observables& obs) //!< Deserialization
{ {
std::vector<Gnss_Synchro> vgs; std::vector<Gnss_Synchro> vgs;
vgs.reserve(obs.observable_size()); vgs.reserve(obs.observable_size());
for (int i = 0; i < obs.observable_size(); ++i) for (int i = 0; i < obs.observable_size(); ++i)
{ {
const gnss_sdr::GnssSynchro& gs_read = obs.observable(i); const gnss_sdr::GnssSynchro& gs_read = obs.observable(i);
Gnss_Synchro gs = Gnss_Synchro(); Gnss_Synchro gs = Gnss_Synchro();
const std::string& sys = gs_read.system(); gs.System = gs_read.system()[0];
gs.System = *sys.c_str(); gs.Signal[0] = gs_read.signal()[0];
const std::string& sig = gs_read.signal(); gs.Signal[1] = gs_read.signal()[1];
std::memcpy(static_cast<void*>(gs.Signal), sig.c_str(), 3); gs.Signal[2] = '\0';
gs.PRN = gs_read.prn(); gs.PRN = gs_read.prn();
gs.Channel_ID = gs_read.channel_id(); gs.Channel_ID = gs_read.channel_id();
@ -153,6 +148,7 @@ public:
} }
return vgs; return vgs;
} }
private: private:
gnss_sdr::Observables observables; gnss_sdr::Observables observables;
}; };

View File

@ -95,13 +95,17 @@ TEST(Protobuf, Works)
Gnss_Synchro gs_read = vgs_read[0]; Gnss_Synchro gs_read = vgs_read[0];
uint32_t prn_read = gs_read.PRN; uint32_t prn_read = gs_read.PRN;
uint32_t prn_read2 = vgs_read[1].PRN; uint32_t prn_read2 = vgs_read[1].PRN;
std::string system_read(1, gs_read.System);
std::string signal_read(gs_read.Signal);
// or without the need of gnss_synchro: // or without the need of gnss_synchro:
int obs_size = obs.observable_size(); int obs_size = obs.observable_size();
uint32_t prn_read3 = obs.observable(0).prn(); uint32_t prn_read3 = obs.observable(0).prn();
EXPECT_EQ(prn_true, prn_read); EXPECT_EQ(sig, signal_read);
EXPECT_EQ(sys, system_read);
EXPECT_EQ(prn_true2, prn_read2); EXPECT_EQ(prn_true2, prn_read2);
EXPECT_EQ(prn_true, prn_read3); EXPECT_EQ(prn_true, prn_read3);
EXPECT_EQ(prn_read, prn_read3);
EXPECT_EQ(2, obs_size); EXPECT_EQ(2, obs_size);
} }