1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-05-06 09:24:12 +00:00

Adding signal processing unit testing auxiliarily libs to enable automating testing with gnss-simulator-in-the-loop

This commit is contained in:
Javier Arribas 2017-02-01 19:24:25 +01:00
parent ae55c151e1
commit fca151ad6b
5 changed files with 150 additions and 3 deletions

View File

@ -16,6 +16,9 @@
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. # along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
# #
add_subdirectory(unit-tests/signal-processing-blocks/libs)
################################################################################ ################################################################################
# Google Test - https://github.com/google/googletest # Google Test - https://github.com/google/googletest
################################################################################ ################################################################################
@ -230,6 +233,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs ${CMAKE_SOURCE_DIR}/src/algorithms/PVT/libs
${CMAKE_SOURCE_DIR}/src/tests/unit-tests/signal-processing-blocks/libs
${GLOG_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS}
@ -271,6 +275,7 @@ if(ENABLE_UNIT_TESTING)
signal_generator_blocks signal_generator_blocks
signal_generator_adapters signal_generator_adapters
pvt_gr_blocks pvt_gr_blocks
signak_processing_testing_lib
${VOLK_GNSSSDR_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES}
${GNSS_SDR_TEST_OPTIONAL_LIBS} ${GNSS_SDR_TEST_OPTIONAL_LIBS}
) )

View File

@ -0,0 +1,35 @@
# Copyright (C) 2012-2015 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
#
set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
tracking_obs_reader.cc
)
include_directories(
$(CMAKE_CURRENT_SOURCE_DIR)
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
)
file(GLOB SIGNAL_PROCESSING_TESTING_LIB_HEADERS "*.h")
list(SORT SIGNAL_PROCESSING_TESTING_LIB_HEADERS)
add_library(signak_processing_testing_lib ${SIGNAL_PROCESSING_TESTING_LIB_SOURCES} ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS})
source_group(Headers FILES ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS})

View File

@ -0,0 +1,57 @@
//
// Created by javier on 1/2/2017.
//
#include "tracking_obs_reader.h"
bool tracking_obs_reader::read_binary_obs(double &signal_timestamp_s,
double &acc_carrier_phase_cycles,
double &doppler_l1_hz,
double &prn_delay_chips,
double &tow)
{
try {
d_dump_file.read((char *) &signal_timestamp_s, sizeof(double));
d_dump_file.read((char *) &acc_carrier_phase_cycles, sizeof(double));
d_dump_file.read((char *) &doppler_l1_hz, sizeof(double));
d_dump_file.read((char *) &prn_delay_chips, sizeof(double));
d_dump_file.read((char *) &tow, sizeof(double));
}
catch (const std::ifstream::failure &e) {
std::cout << "Exception writing tracking obs dump file " << e.what() << std::endl;
}
return true;
}
bool tracking_obs_reader::restart() {
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
}
bool tracking_obs_reader::open_obs_file(std::string out_file) {
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Observables dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl;
return true;
}
catch (const std::ifstream::failure & e)
{
std::cout << "Problem opening Observables dump Log file: " << d_dump_filename.c_str()<< std::endl;
return false;
}
}else{
return false;
}
}
tracking_obs_reader::~tracking_obs_reader() {
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}

View File

@ -0,0 +1,33 @@
//
// Created by javier on 23/1/2017.
//
#ifndef GNSS_SIM_tracking_obs_reader_H
#define GNSS_SIM_tracking_obs_reader_H
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
class tracking_obs_reader {
public:
~tracking_obs_reader();
bool read_binary_obs(double &signal_timestamp_s,
double &acc_carrier_phase_cycles,
double &doppler_l1_hz,
double &prn_delay_chips,
double &tow);
bool restart();
bool open_obs_file(std::string out_file);
bool d_dump;
private:
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif //GNSS_SIM_tracking_obs_reader_H

View File

@ -51,6 +51,8 @@
#include "gnss_synchro.h" #include "gnss_synchro.h"
#include "gps_l1_ca_telemetry_decoder.h" #include "gps_l1_ca_telemetry_decoder.h"
#include "gps_l1_ca_dll_pll_tracking.h" #include "gps_l1_ca_dll_pll_tracking.h"
#include "gps_l1_ca_dll_pll_c_aid_tracking.h"
#include "tracking_obs_reader.h"
// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### // ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES #########
class GpsL1CADllPllTelemetryDecoderTest_msg_rx; class GpsL1CADllPllTelemetryDecoderTest_msg_rx;
@ -200,8 +202,8 @@ void GpsL1CATelemetryDecoderTest::init()
config->set_property("Tracking_1C.if", "0"); config->set_property("Tracking_1C.if", "0");
config->set_property("Tracking_1C.dump", "true"); config->set_property("Tracking_1C.dump", "true");
config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_");
config->set_property("Tracking_1C.pll_bw_hz", "30.0"); config->set_property("Tracking_1C.pll_bw_hz", "20.0");
config->set_property("Tracking_1C.dll_bw_hz", "4.0"); config->set_property("Tracking_1C.dll_bw_hz", "1.5");
config->set_property("Tracking_1C.early_late_space_chips", "0.5"); config->set_property("Tracking_1C.early_late_space_chips", "0.5");
config->set_property("TelemetryDecoder_1C.dump","true"); config->set_property("TelemetryDecoder_1C.dump","true");
@ -217,9 +219,24 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
int fs_in = 2600000; int fs_in = 2600000;
init(); init();
//todo: call here the gnss simulator
//open true observables log file written by the simulator
tracking_obs_reader true_obs_data;
ASSERT_NO_THROW({
if (true_obs_data.open_obs_file("signal_samples/gps_l1_ca_obs_prn1.dat")==false)
{
throw std::exception();
};
})<< "Failure opening true observables file" << std::endl;
queue = gr::msg_queue::make(0); queue = gr::msg_queue::make(0);
top_block = gr::make_top_block("Telemetry_Decoder test"); top_block = gr::make_top_block("Telemetry_Decoder test");
std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL1CaDllPllTracking>(config.get(), "Tracking_1C", 1, 1); std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL1CaDllPllTracking>(config.get(), "Tracking_1C", 1, 1);
//std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL1CaDllPllCAidTracking>(config.get(), "Tracking_1C", 1, 1);
boost::shared_ptr<GpsL1CADllPllTelemetryDecoderTest_msg_rx> msg_rx = GpsL1CADllPllTelemetryDecoderTest_msg_rx_make(); boost::shared_ptr<GpsL1CADllPllTelemetryDecoderTest_msg_rx> msg_rx = GpsL1CADllPllTelemetryDecoderTest_msg_rx_make();
gnss_synchro.Acq_delay_samples = (1023-994.622/1023)*fs_in*1e-3; gnss_synchro.Acq_delay_samples = (1023-994.622/1023)*fs_in*1e-3;
@ -245,7 +262,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults)
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
std::string path = std::string(TEST_PATH); std::string path = std::string(TEST_PATH);
std::string file = path + "signal_samples/gps_l1ca_prn1_2.6msps.dat"; std::string file = path + "signal_samples/signal_out.dat";
const char * file_name = file.c_str(); const char * file_name = file.c_str();
gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false);
//boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); //boost::shared_ptr<gr::block> valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);