mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-11-04 17:16:26 +00:00
Replace <ctime> library by <chrono>
and also replace C-style casts by C++ casts. Added/removed some blank lines here and there to match coding style of other tests.
This commit is contained in:
parent
1e59501cb5
commit
8bbe4edc64
@ -1,4 +1,4 @@
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <gnuradio/top_block.h>
|
||||
#include <gnuradio/blocks/file_source.h>
|
||||
@ -72,6 +72,7 @@ GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::GlonassL1CaPcpsAcquisitionGSoC201
|
||||
rx_message = 0;
|
||||
}
|
||||
|
||||
|
||||
GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::~GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx()
|
||||
{}
|
||||
|
||||
@ -138,6 +139,7 @@ protected:
|
||||
double Pfa_a;
|
||||
};
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::init()
|
||||
{
|
||||
message = 0;
|
||||
@ -153,6 +155,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::init()
|
||||
Pfa_a = 0;
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_1()
|
||||
{
|
||||
gnss_synchro.Channel_ID = 0;
|
||||
@ -222,6 +225,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_1()
|
||||
config->set_property("Acquisition.dump", "false");
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_2()
|
||||
{
|
||||
gnss_synchro.Channel_ID = 0;
|
||||
@ -309,12 +313,14 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::config_2()
|
||||
config->set_property("Acquisition.dump", "false");
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::start_queue()
|
||||
{
|
||||
stop = false;
|
||||
ch_thread = boost::thread(&GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message, this);
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message()
|
||||
{
|
||||
struct timeval tv;
|
||||
@ -339,6 +345,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::wait_message()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::process_message()
|
||||
{
|
||||
if (message == 1)
|
||||
@ -347,7 +354,7 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::process_message()
|
||||
|
||||
// The term -5 is here to correct the additional delay introduced by the FIR filter
|
||||
// The value 511.0 must be a variable, chips/length
|
||||
double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*511.0/((double)fs_in*1e-3));
|
||||
double delay_error_chips = std::abs(static_cast<double>(expected_delay_chips) - (static_cast<double>(gnss_synchro.Acq_delay_samples) - 5.0 ) * 511.0 / (static_cast<double>(fs_in) * 1e-3));
|
||||
double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
|
||||
|
||||
mse_delay += std::pow(delay_error_chips, 2);
|
||||
@ -361,16 +368,16 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::process_message()
|
||||
|
||||
realization_counter++;
|
||||
|
||||
std::cout << "Progress: " << round((float)realization_counter/num_of_realizations*100) << "% \r" << std::flush;
|
||||
std::cout << "Progress: " << round(static_cast<float>(realization_counter) / static_cast<float>(num_of_realizations) * 100.0) << "% \r" << std::flush;
|
||||
|
||||
if (realization_counter == num_of_realizations)
|
||||
{
|
||||
mse_delay /= num_of_realizations;
|
||||
mse_doppler /= num_of_realizations;
|
||||
|
||||
Pd = (double)correct_estimation_counter / (double)num_of_realizations;
|
||||
Pfa_a = (double)detection_counter / (double)num_of_realizations;
|
||||
Pfa_p = (double)(detection_counter - correct_estimation_counter) / (double)num_of_realizations;
|
||||
Pd = static_cast<double>(correct_estimation_counter) / static_cast<double>(num_of_realizations);
|
||||
Pfa_a = static_cast<double>(detection_counter) / static_cast<double>(num_of_realizations);
|
||||
Pfa_p = (static_cast<double>(detection_counter) - static_cast<double>( correct_estimation_counter)) / static_cast<double>(num_of_realizations);
|
||||
|
||||
mean_acq_time_us /= num_of_realizations;
|
||||
|
||||
@ -379,11 +386,13 @@ void GlonassL1CaPcpsAcquisitionGSoC2017Test::process_message()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GlonassL1CaPcpsAcquisitionGSoC2017Test::stop_queue()
|
||||
{
|
||||
stop = true;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, Instantiate)
|
||||
{
|
||||
config_1();
|
||||
@ -391,12 +400,12 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, Instantiate)
|
||||
delete acquisition;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ConnectAndRun)
|
||||
{
|
||||
int nsamples = floor(fs_in*integration_time_ms*1e-3);
|
||||
struct timeval tv;
|
||||
long long int begin = 0;
|
||||
long long int end = 0;
|
||||
int nsamples = floor(fs_in * integration_time_ms * 1e-3);
|
||||
std::chrono::time_point<std::chrono::system_clock> begin, end;
|
||||
std::chrono::duration<double> elapsed_seconds(0);
|
||||
queue = gr::msg_queue::make(0);
|
||||
top_block = gr::make_top_block("Acquisition test");
|
||||
|
||||
@ -414,18 +423,18 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ConnectAndRun)
|
||||
}) << "Failure connecting the blocks of acquisition test."<< std::endl;
|
||||
|
||||
EXPECT_NO_THROW( {
|
||||
gettimeofday(&tv, NULL);
|
||||
begin = tv.tv_sec *1e6 + tv.tv_usec;
|
||||
begin = std::chrono::system_clock::now();
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
end = tv.tv_sec *1e6 + tv.tv_usec;
|
||||
end = std::chrono::system_clock::now();
|
||||
elapsed_seconds = end - begin;
|
||||
}) << "Failure running the top_block."<< std::endl;
|
||||
|
||||
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
|
||||
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
||||
|
||||
delete acquisition;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults)
|
||||
{
|
||||
config_1();
|
||||
@ -495,18 +504,18 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults)
|
||||
}) << "Failure running the top_block."<< std::endl;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
|
||||
if (message == 1)
|
||||
{
|
||||
EXPECT_EQ((unsigned int) 1, correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
|
||||
}
|
||||
{
|
||||
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
|
||||
if (message == 1)
|
||||
{
|
||||
EXPECT_EQ(static_cast<unsigned int>(1), correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
|
||||
}
|
||||
{
|
||||
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
|
||||
}
|
||||
#ifdef OLD_BOOST
|
||||
ASSERT_NO_THROW( {
|
||||
ch_thread.timed_join(boost::posix_time::seconds(1));
|
||||
@ -522,6 +531,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults)
|
||||
delete acquisition;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResultsProbabilities)
|
||||
{
|
||||
config_2();
|
||||
@ -592,15 +602,15 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResultsProbabilities)
|
||||
}) << "Failure running the top_block."<< std::endl;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
std::cout << "Estimated probability of detection = " << Pd << std::endl;
|
||||
std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl;
|
||||
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; }
|
||||
{
|
||||
std::cout << "Estimated probability of detection = " << Pd << std::endl;
|
||||
std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl;
|
||||
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; }
|
||||
else if (i == 1)
|
||||
{
|
||||
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
|
||||
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
|
||||
}
|
||||
{
|
||||
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
|
||||
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
|
||||
}
|
||||
#ifdef OLD_BOOST
|
||||
ASSERT_NO_THROW( {
|
||||
ch_thread.timed_join(boost::posix_time::seconds(1));
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/chrono.hpp>
|
||||
@ -119,20 +119,19 @@ void GlonassL1CaPcpsAcquisitionTest::init()
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionTest, Instantiate)
|
||||
{
|
||||
init();
|
||||
boost::shared_ptr<GlonassL1CaPcpsAcquisition> acquisition = boost::make_shared<GlonassL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionTest, ConnectAndRun)
|
||||
{
|
||||
int fs_in = 62314000;
|
||||
int nsamples = 62314;
|
||||
struct timeval tv;
|
||||
long long int begin = 0;
|
||||
long long int end = 0;
|
||||
std::chrono::time_point<std::chrono::system_clock> begin, end;
|
||||
std::chrono::duration<double> elapsed_seconds(0);
|
||||
gr::msg_queue::sptr queue = gr::msg_queue::make(0);
|
||||
|
||||
top_block = gr::make_top_block("Acquisition test");
|
||||
@ -151,21 +150,20 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ConnectAndRun)
|
||||
}) << "Failure connecting the blocks of acquisition test." << std::endl;
|
||||
|
||||
EXPECT_NO_THROW( {
|
||||
gettimeofday(&tv, NULL);
|
||||
begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
begin = std::chrono::system_clock::now();
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
end = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
end = std::chrono::system_clock::now();
|
||||
elapsed_seconds = end - begin;
|
||||
}) << "Failure running the top_block." << std::endl;
|
||||
|
||||
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
|
||||
std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults)
|
||||
{
|
||||
struct timeval tv;
|
||||
long long int begin = 0;
|
||||
long long int end = 0;
|
||||
std::chrono::time_point<std::chrono::system_clock> begin, end;
|
||||
std::chrono::duration<double> elapsed_seconds(0);
|
||||
top_block = gr::make_top_block("Acquisition test");
|
||||
|
||||
double expected_delay_samples = 31874;
|
||||
@ -213,21 +211,20 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults)
|
||||
acquisition->init();
|
||||
|
||||
EXPECT_NO_THROW( {
|
||||
gettimeofday(&tv, NULL);
|
||||
begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
begin = std::chrono::system_clock::now();
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
end = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
end = std::chrono::system_clock::now();
|
||||
elapsed_seconds = end - begin;
|
||||
}) << "Failure running the top_block." << std::endl;
|
||||
|
||||
|
||||
unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
|
||||
std::cout << "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
|
||||
std::cout << "Acquired " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl;
|
||||
|
||||
ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
|
||||
|
||||
double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
|
||||
float delay_error_chips = (float)(delay_error_samples * 511 / 62316);
|
||||
float delay_error_chips = static_cast<float>(delay_error_samples) * 511.0 / 62316.0;
|
||||
double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz);
|
||||
|
||||
EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)";
|
||||
|
Loading…
Reference in New Issue
Block a user