2015-05-05 16:18:16 +00:00
|
|
|
/*!
|
|
|
|
* \file gps_l2_m_dll_pll_tracking_test.cc
|
|
|
|
* \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking
|
|
|
|
* implementation based on some input parameters.
|
|
|
|
* \author Javier Arribas, 2015. jarribas(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
* Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors)
|
2015-05-05 16:18:16 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-05-05 16:18:16 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2019-07-18 17:29:14 +00:00
|
|
|
#include "concurrent_queue.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "gnss_block_factory.h"
|
|
|
|
#include "gnss_block_interface.h"
|
|
|
|
#include "gnss_sdr_valve.h"
|
|
|
|
#include "gnss_synchro.h"
|
2019-07-26 10:38:20 +00:00
|
|
|
#include "gps_l2_m_dll_pll_tracking.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "in_memory_configuration.h"
|
|
|
|
#include "tracking_interface.h"
|
2015-05-05 16:18:16 +00:00
|
|
|
#include <gnuradio/analog/sig_source_waveform.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/blocks/file_source.h>
|
|
|
|
#include <gnuradio/blocks/null_sink.h>
|
|
|
|
#include <gnuradio/blocks/skiphead.h>
|
|
|
|
#include <gnuradio/top_block.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <chrono>
|
2019-02-11 17:38:42 +00:00
|
|
|
#include <utility>
|
2020-04-26 06:41:49 +00:00
|
|
|
#if HAS_GENERIC_LAMBDA
|
|
|
|
#else
|
2020-06-06 21:41:38 +00:00
|
|
|
#include <boost/bind/bind.hpp>
|
2020-04-26 06:41:49 +00:00
|
|
|
#endif
|
2018-08-31 11:52:35 +00:00
|
|
|
#ifdef GR_GREATER_38
|
|
|
|
#include <gnuradio/analog/sig_source.h>
|
|
|
|
#else
|
2015-05-05 16:18:16 +00:00
|
|
|
#include <gnuradio/analog/sig_source_c.h>
|
2018-08-31 11:52:35 +00:00
|
|
|
#endif
|
2020-04-02 21:59:35 +00:00
|
|
|
#if GNURADIO_USES_STD_POINTERS
|
|
|
|
#include <memory>
|
|
|
|
#else
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#endif
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2016-04-25 13:53:01 +00:00
|
|
|
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
|
|
|
|
class GpsL2MDllPllTrackingTest_msg_rx;
|
|
|
|
|
2020-04-02 21:59:35 +00:00
|
|
|
#if GNURADIO_USES_STD_POINTERS
|
2020-04-02 11:23:20 +00:00
|
|
|
using GpsL2MDllPllTrackingTest_msg_rx_sptr = std::shared_ptr<GpsL2MDllPllTrackingTest_msg_rx>;
|
2020-04-02 21:59:35 +00:00
|
|
|
#else
|
|
|
|
using GpsL2MDllPllTrackingTest_msg_rx_sptr = boost::shared_ptr<GpsL2MDllPllTrackingTest_msg_rx>;
|
|
|
|
#endif
|
2016-04-25 13:53:01 +00:00
|
|
|
|
|
|
|
GpsL2MDllPllTrackingTest_msg_rx_sptr GpsL2MDllPllTrackingTest_msg_rx_make();
|
|
|
|
|
|
|
|
class GpsL2MDllPllTrackingTest_msg_rx : public gr::block
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend GpsL2MDllPllTrackingTest_msg_rx_sptr GpsL2MDllPllTrackingTest_msg_rx_make();
|
|
|
|
void msg_handler_events(pmt::pmt_t msg);
|
|
|
|
GpsL2MDllPllTrackingTest_msg_rx();
|
|
|
|
|
|
|
|
public:
|
2016-04-25 18:20:41 +00:00
|
|
|
int rx_message;
|
2018-03-03 01:03:39 +00:00
|
|
|
~GpsL2MDllPllTrackingTest_msg_rx(); //!< Default destructor
|
2016-04-25 13:53:01 +00:00
|
|
|
};
|
|
|
|
|
2017-08-11 11:11:38 +00:00
|
|
|
|
2016-04-25 13:53:01 +00:00
|
|
|
GpsL2MDllPllTrackingTest_msg_rx_sptr GpsL2MDllPllTrackingTest_msg_rx_make()
|
|
|
|
{
|
|
|
|
return GpsL2MDllPllTrackingTest_msg_rx_sptr(new GpsL2MDllPllTrackingTest_msg_rx());
|
|
|
|
}
|
|
|
|
|
2017-08-11 11:11:38 +00:00
|
|
|
|
2016-04-25 13:53:01 +00:00
|
|
|
void GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
|
|
|
|
{
|
2016-05-01 07:19:30 +00:00
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2019-02-11 17:38:42 +00:00
|
|
|
int64_t message = pmt::to_long(std::move(msg));
|
2016-05-01 07:19:30 +00:00
|
|
|
rx_message = message;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (boost::bad_any_cast& e)
|
|
|
|
{
|
2016-05-01 10:39:40 +00:00
|
|
|
LOG(WARNING) << "msg_handler_telemetry Bad any cast!";
|
2016-04-25 18:20:41 +00:00
|
|
|
rx_message = 0;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2016-04-25 13:53:01 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 11:11:38 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
GpsL2MDllPllTrackingTest_msg_rx::GpsL2MDllPllTrackingTest_msg_rx() : gr::block("GpsL2MDllPllTrackingTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
|
2016-04-25 13:53:01 +00:00
|
|
|
{
|
|
|
|
this->message_port_register_in(pmt::mp("events"));
|
2020-04-26 06:41:49 +00:00
|
|
|
this->set_msg_handler(pmt::mp("events"),
|
|
|
|
#if HAS_GENERIC_LAMBDA
|
2020-06-08 18:04:01 +00:00
|
|
|
[this](auto&& PH1) { msg_handler_events(PH1); });
|
2020-04-26 06:41:49 +00:00
|
|
|
#else
|
2020-05-18 20:50:34 +00:00
|
|
|
#if BOOST_173_OR_GREATER
|
2020-05-18 16:58:39 +00:00
|
|
|
boost::bind(&GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events, this, boost::placeholders::_1));
|
2020-05-18 20:50:34 +00:00
|
|
|
#else
|
|
|
|
boost::bind(&GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events, this, _1));
|
|
|
|
#endif
|
2020-04-26 06:41:49 +00:00
|
|
|
#endif
|
2016-04-25 18:20:41 +00:00
|
|
|
rx_message = 0;
|
2016-04-25 13:53:01 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 11:11:38 +00:00
|
|
|
|
2019-02-11 20:13:02 +00:00
|
|
|
GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx() = default;
|
2016-04-25 13:53:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ###########################################################
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
class GpsL2MDllPllTrackingTest : public ::testing::Test
|
2015-05-05 16:18:16 +00:00
|
|
|
{
|
|
|
|
protected:
|
2016-05-02 21:46:30 +00:00
|
|
|
GpsL2MDllPllTrackingTest()
|
2015-05-05 16:18:16 +00:00
|
|
|
{
|
|
|
|
factory = std::make_shared<GNSSBlockFactory>();
|
|
|
|
config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
item_size = sizeof(gr_complex);
|
2015-05-15 09:47:34 +00:00
|
|
|
gnss_synchro = Gnss_Synchro();
|
2015-05-05 16:18:16 +00:00
|
|
|
}
|
|
|
|
|
2019-02-11 20:13:02 +00:00
|
|
|
~GpsL2MDllPllTrackingTest() = default;
|
2015-05-05 16:18:16 +00:00
|
|
|
|
|
|
|
void init();
|
|
|
|
|
2019-07-16 15:41:12 +00:00
|
|
|
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
|
2015-05-05 16:18:16 +00:00
|
|
|
gr::top_block_sptr top_block;
|
|
|
|
std::shared_ptr<GNSSBlockFactory> factory;
|
|
|
|
std::shared_ptr<InMemoryConfiguration> config;
|
|
|
|
Gnss_Synchro gnss_synchro;
|
|
|
|
size_t item_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void GpsL2MDllPllTrackingTest::init()
|
|
|
|
{
|
|
|
|
gnss_synchro.Channel_ID = 0;
|
|
|
|
gnss_synchro.System = 'G';
|
|
|
|
std::string signal = "2S";
|
|
|
|
signal.copy(gnss_synchro.Signal, 2, 0);
|
2015-05-06 14:33:51 +00:00
|
|
|
gnss_synchro.PRN = 7;
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2017-09-02 09:24:44 +00:00
|
|
|
config->set_property("GNSS-SDR.internal_fs_sps", "5000000");
|
2015-05-12 11:13:51 +00:00
|
|
|
config->set_property("Tracking_2S.item_type", "gr_complex");
|
2016-05-01 07:19:30 +00:00
|
|
|
config->set_property("Tracking_2S.dump", "false");
|
2015-05-12 11:13:51 +00:00
|
|
|
config->set_property("Tracking_2S.dump_filename", "../data/L2m_tracking_ch_");
|
|
|
|
config->set_property("Tracking_2S.implementation", "GPS_L2_M_DLL_PLL_Tracking");
|
|
|
|
config->set_property("Tracking_2S.early_late_space_chips", "0.5");
|
|
|
|
config->set_property("Tracking_2S.order", "2");
|
|
|
|
config->set_property("Tracking_2S.pll_bw_hz", "2");
|
|
|
|
config->set_property("Tracking_2S.dll_bw_hz", "0.5");
|
2015-05-05 16:18:16 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 03:18:38 +00:00
|
|
|
|
2015-05-05 16:18:16 +00:00
|
|
|
TEST_F(GpsL2MDllPllTrackingTest, ValidationOfResults)
|
|
|
|
{
|
2017-08-11 03:18:38 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
2017-10-28 22:44:38 +00:00
|
|
|
std::chrono::duration<double> elapsed_seconds(0.0);
|
2015-05-06 14:33:51 +00:00
|
|
|
int fs_in = 5000000;
|
2017-10-28 22:44:38 +00:00
|
|
|
int nsamples = fs_in * 9;
|
2016-04-25 13:53:01 +00:00
|
|
|
|
2015-05-05 16:18:16 +00:00
|
|
|
init();
|
2019-07-18 17:29:14 +00:00
|
|
|
queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
|
2015-05-05 16:18:16 +00:00
|
|
|
top_block = gr::make_top_block("Tracking test");
|
2016-05-09 09:51:42 +00:00
|
|
|
std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL2MDllPllTracking>(config.get(), "Tracking_2S", 1, 1);
|
2020-04-02 21:59:35 +00:00
|
|
|
auto msg_rx = GpsL2MDllPllTrackingTest_msg_rx_make();
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2015-05-06 14:33:51 +00:00
|
|
|
gnss_synchro.Acq_delay_samples = 1;
|
2016-04-25 13:53:01 +00:00
|
|
|
gnss_synchro.Acq_doppler_hz = 1200;
|
2015-05-05 16:18:16 +00:00
|
|
|
gnss_synchro.Acq_samplestamp_samples = 0;
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_NO_THROW({
|
2015-05-05 16:18:16 +00:00
|
|
|
tracking->set_channel(gnss_synchro.Channel_ID);
|
2017-10-28 22:44:38 +00:00
|
|
|
}) << "Failure setting channel.";
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_NO_THROW({
|
2015-05-05 16:18:16 +00:00
|
|
|
tracking->set_gnss_synchro(&gnss_synchro);
|
2017-10-28 22:44:38 +00:00
|
|
|
}) << "Failure setting gnss_synchro.";
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_NO_THROW({
|
2015-05-05 16:18:16 +00:00
|
|
|
tracking->connect(top_block);
|
2017-10-28 22:44:38 +00:00
|
|
|
}) << "Failure connecting tracking to the top_block.";
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
ASSERT_NO_THROW({
|
2019-08-18 23:29:04 +00:00
|
|
|
// gr::analog::sig_source_c::sptr source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0));
|
2015-05-05 16:18:16 +00:00
|
|
|
std::string path = std::string(TEST_PATH);
|
2018-03-03 01:03:39 +00:00
|
|
|
std::string file = path + "signal_samples/gps_l2c_m_prn7_5msps.dat";
|
|
|
|
const char* file_name = file.c_str();
|
2015-05-05 16:18:16 +00:00
|
|
|
gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(gr_complex), file_name, false);
|
2020-04-02 21:59:35 +00:00
|
|
|
auto valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
|
2015-05-05 16:18:16 +00:00
|
|
|
gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro));
|
|
|
|
top_block->connect(file_source, 0, valve, 0);
|
|
|
|
top_block->connect(valve, 0, tracking->get_left_block(), 0);
|
|
|
|
top_block->connect(tracking->get_right_block(), 0, sink, 0);
|
2016-05-01 07:19:30 +00:00
|
|
|
top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
|
2017-10-28 22:44:38 +00:00
|
|
|
}) << "Failure connecting the blocks of tracking test.";
|
2015-05-05 16:18:16 +00:00
|
|
|
|
|
|
|
tracking->start_tracking();
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-08-11 03:18:38 +00:00
|
|
|
start = std::chrono::system_clock::now();
|
2018-03-03 01:03:39 +00:00
|
|
|
top_block->run(); // Start threads and wait
|
2017-08-11 03:18:38 +00:00
|
|
|
end = std::chrono::system_clock::now();
|
|
|
|
elapsed_seconds = end - start;
|
2017-10-28 22:44:38 +00:00
|
|
|
}) << "Failure running the top_block.";
|
2015-05-05 16:18:16 +00:00
|
|
|
|
2016-04-25 13:53:01 +00:00
|
|
|
// TODO: Verify tracking results
|
2018-03-03 01:03:39 +00:00
|
|
|
std::cout << "Tracked " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
2015-05-05 16:18:16 +00:00
|
|
|
}
|