mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-10-25 12:37:40 +00:00
Major changes:
- Fir_Filter implementation for InputFilter block in SignalConditioner - Tests for InputFilter and Resampler - Fixed some bugs git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@176 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
@@ -78,6 +78,10 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
|
||||
dump_, dump_filename_);
|
||||
stream_to_vector_ = gr_make_stream_to_vector(item_size_,
|
||||
vector_length_);
|
||||
DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id()
|
||||
<< ")";
|
||||
DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id()
|
||||
<< ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,8 +89,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
|
||||
<< " unknown acquisition item type";
|
||||
}
|
||||
|
||||
DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id()
|
||||
<< ")";
|
||||
|
||||
}
|
||||
|
||||
GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition()
|
||||
|
||||
@@ -50,7 +50,6 @@ SignalConditioner::SignalConditioner(ConfigurationInterface *configuration,
|
||||
in_filt_(in_filt), res_(res), role_(role), implementation_(implementation),
|
||||
queue_(queue)
|
||||
{
|
||||
// stop_ = false;
|
||||
connected_ = false;
|
||||
}
|
||||
|
||||
|
||||
166
src/algorithms/input_filter/adapters/fir_filter.cc
Normal file
166
src/algorithms/input_filter/adapters/fir_filter.cc
Normal file
@@ -0,0 +1,166 @@
|
||||
/*!
|
||||
* \file fir_filter.cc
|
||||
* \brief Adapts a gnuradio gr_fir_filter designed with gr_remez
|
||||
* \author Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "fir_filter.h"
|
||||
#include "configuration_interface.h"
|
||||
#include <string>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/gr_io_signature.h>
|
||||
#include <gnuradio/gr_file_sink.h>
|
||||
#include <gnuradio/gr_remez.h>
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams,
|
||||
gr_msg_queue_sptr queue) :
|
||||
config_(configuration), role_(role), in_streams_(in_streams), out_streams_(
|
||||
out_streams), queue_(queue) {
|
||||
|
||||
size_t item_size;
|
||||
(*this).init();
|
||||
|
||||
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare(
|
||||
"gr_complex") == 0) && (output_item_type_.compare("gr_complex")
|
||||
== 0)) {
|
||||
item_size = sizeof(gr_complex);
|
||||
fir_filter_ccf_ = gr_make_fir_filter_ccf(1, taps_);
|
||||
DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")";
|
||||
|
||||
} else {
|
||||
LOG_AT_LEVEL(ERROR) << taps_item_type_
|
||||
<< " unknown input filter item type";
|
||||
}
|
||||
if (dump_) {
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr_make_file_sink(item_size, dump_filename_.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FirFilter::~FirFilter() {
|
||||
}
|
||||
|
||||
void FirFilter::connect(gr_top_block_sptr top_block) {
|
||||
|
||||
if (dump_) {
|
||||
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
||||
} else {
|
||||
DLOG(INFO) << "Nothing to connect internally";
|
||||
}
|
||||
}
|
||||
|
||||
void FirFilter::disconnect(gr_top_block_sptr top_block) {
|
||||
|
||||
if (dump_) {
|
||||
top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gr_basic_block_sptr FirFilter::get_left_block() {
|
||||
return fir_filter_ccf_;
|
||||
}
|
||||
|
||||
gr_basic_block_sptr FirFilter::get_right_block() {
|
||||
return fir_filter_ccf_;
|
||||
}
|
||||
|
||||
void FirFilter::init() {
|
||||
std::string default_input_item_type = "gr_complex";
|
||||
std::string default_output_item_type = "gr_complex";
|
||||
std::string default_taps_item_type = "float";
|
||||
std::string default_dump_filename = "../data/input_filter.dat";
|
||||
int default_number_of_taps = 6;
|
||||
unsigned int default_number_of_bands = 2;
|
||||
std::vector<double> default_bands = { 0.0, 0.4, 0.6, 1.0 };
|
||||
std::vector<double> default_ampl = { 1.0, 1.0, 0.0, 0.0 };
|
||||
std::vector<double> default_error_w = { 1.0, 1.0 };
|
||||
std::string default_filter_type = "bandpass";
|
||||
int default_grid_density = 16;
|
||||
|
||||
DLOG(INFO) << "role " << role_;
|
||||
|
||||
input_item_type_ = config_->property(role_ + ".input_item_type",
|
||||
default_input_item_type);
|
||||
output_item_type_ = config_->property(role_ + ".output_item_type",
|
||||
default_output_item_type);
|
||||
taps_item_type_ = config_->property(role_ + ".taps_item_type",
|
||||
default_taps_item_type);
|
||||
|
||||
dump_ = config_->property(role_ + ".dump", false);
|
||||
dump_filename_ = config_->property(role_ + ".dump_filename",
|
||||
default_dump_filename);
|
||||
int number_of_taps = config_->property(role_ + ".number_of_taps",
|
||||
default_number_of_taps);
|
||||
unsigned int number_of_bands = config_->property(role_ + ".number_of_bands",
|
||||
default_number_of_bands);
|
||||
|
||||
std::vector<double> bands;
|
||||
std::vector<double> ampl;
|
||||
std::vector<double> error_w;
|
||||
std::string option;
|
||||
double option_value;
|
||||
|
||||
for (unsigned int i = 0; i < number_of_bands; i++) {
|
||||
|
||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
||||
option_value = config_->property(role_ + option, default_bands[i]);
|
||||
bands.push_back(option_value);
|
||||
|
||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
||||
option_value = config_->property(role_ + option, default_bands[i]);
|
||||
bands.push_back(option_value);
|
||||
|
||||
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_begin";
|
||||
option_value = config_->property(role_ + option, default_bands[i]);
|
||||
ampl.push_back(option_value);
|
||||
|
||||
option = ".ampl" + boost::lexical_cast<std::string>(i + 1) + "_end";
|
||||
option_value = config_->property(role_ + option, default_bands[i]);
|
||||
ampl.push_back(option_value);
|
||||
|
||||
option = ".band" + boost::lexical_cast<std::string>(i + 1) + "_error";
|
||||
option_value = config_->property(role_ + option, default_bands[i]);
|
||||
error_w.push_back(option_value);
|
||||
}
|
||||
|
||||
std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type);
|
||||
int grid_density = config_->property(role_ + ".grid_density", default_grid_density);
|
||||
|
||||
std::vector<double> taps_d = gr_remez(number_of_taps - 1, bands, ampl,
|
||||
error_w, filter_type, grid_density);
|
||||
taps_.reserve(taps_d.size());
|
||||
for (std::vector<double>::iterator it = taps_d.begin(); it != taps_d.end(); it++) {
|
||||
taps_.push_back(float(*it));
|
||||
}
|
||||
}
|
||||
102
src/algorithms/input_filter/adapters/fir_filter.h
Normal file
102
src/algorithms/input_filter/adapters/fir_filter.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*!
|
||||
* \file fir_filter.h
|
||||
* \brief Adapts a gnuradio gr_fir_filter designed with gr_remez
|
||||
* \author Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef FIR_FILTER_H_
|
||||
#define FIR_FILTER_H_
|
||||
|
||||
#include "gnss_synchro.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include <gnuradio/gr_fir_filter_ccc.h>
|
||||
#include <gnuradio/gr_fir_filter_ccf.h>
|
||||
#include <gnuradio/gr_fir_filter_fcc.h>
|
||||
#include <gnuradio/gr_fir_filter_fff.h>
|
||||
#include <gnuradio/gr_fir_filter_fsf.h>
|
||||
#include <gnuradio/gr_fir_filter_scc.h>
|
||||
#include <gnuradio/gr_msg_queue.h>
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class FirFilter: public GNSSBlockInterface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
FirFilter(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams,
|
||||
unsigned int out_streams, gr_msg_queue_sptr queue);
|
||||
|
||||
virtual ~FirFilter();
|
||||
|
||||
std::string role()
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
std::string implementation()
|
||||
{
|
||||
return "Fir_Filter";
|
||||
}
|
||||
size_t item_size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void connect(gr_top_block_sptr top_block);
|
||||
void disconnect(gr_top_block_sptr top_block);
|
||||
gr_basic_block_sptr get_left_block();
|
||||
gr_basic_block_sptr get_right_block();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
gr_fir_filter_ccf_sptr fir_filter_ccf_;
|
||||
ConfigurationInterface* config_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
|
||||
std::string input_item_type_;
|
||||
std::string output_item_type_;
|
||||
std::string taps_item_type_;
|
||||
std::vector <float> taps_;
|
||||
|
||||
std::string role_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
gr_msg_queue_sptr queue_;
|
||||
gr_block_sptr file_sink_;
|
||||
|
||||
void init();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_H_ */
|
||||
3
src/algorithms/input_filter/adapters/jamfile.jam
Normal file
3
src/algorithms/input_filter/adapters/jamfile.jam
Normal file
@@ -0,0 +1,3 @@
|
||||
project : build-dir ../../../../build ;
|
||||
|
||||
obj fir_filter : fir_filter.cc ;
|
||||
@@ -1,2 +1,2 @@
|
||||
# build-project adapters ;
|
||||
build-project adapters ;
|
||||
# build-project gnuradio_blocks ;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
build-project acquisition ;
|
||||
build-project channel ;
|
||||
build-project conditioner ;
|
||||
build-project input_filter ;
|
||||
build-project libs ;
|
||||
build-project observables ;
|
||||
build-project output_filter ;
|
||||
build-project PVT ;
|
||||
build-project resampler ;
|
||||
build-project signal_source ;
|
||||
build-project tracking ;
|
||||
build-project telemetry_decoder ;
|
||||
build-project observables ;
|
||||
build-project PVT ;
|
||||
build-project output_filter ;
|
||||
@@ -63,6 +63,11 @@ DirectResamplerConditioner::DirectResamplerConditioner(
|
||||
item_size_ = sizeof(gr_complex);
|
||||
resampler_ = direct_resampler_make_conditioner_cc(sample_freq_in_,
|
||||
sample_freq_out_);
|
||||
DLOG(INFO) << "sample_freq_in " << sample_freq_in_;
|
||||
DLOG(INFO) << "sample_freq_out" << sample_freq_out_;
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")";
|
||||
|
||||
}
|
||||
// else if (item_type_.compare("short") == 0)
|
||||
// {
|
||||
@@ -73,7 +78,7 @@ DirectResamplerConditioner::DirectResamplerConditioner(
|
||||
else
|
||||
{
|
||||
LOG_AT_LEVEL(WARNING) << item_type_
|
||||
<< " unrecognized item type. Using short";
|
||||
<< " unrecognized item type for resampler";
|
||||
item_size_ = sizeof(short);
|
||||
}
|
||||
|
||||
@@ -83,10 +88,7 @@ DirectResamplerConditioner::DirectResamplerConditioner(
|
||||
file_sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
|
||||
}
|
||||
|
||||
DLOG(INFO) << "sample_freq_in " << sample_freq_in_;
|
||||
DLOG(INFO) << "sample_freq_out" << sample_freq_out_;
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")";
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* \file gnss_block_factory.cc
|
||||
* \brief This class implements a factory that returns instances of GNSS blocks.
|
||||
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
||||
* Luis Esteve, 2011. luis(at)epsilon-formacion.com
|
||||
* Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
||||
* Javier Arribas, 2011. jarribas(at)cttc.es
|
||||
*
|
||||
* This class encapsulates the complexity behind the instantiation
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@@ -50,6 +50,7 @@
|
||||
//#include "usrp1_signal_source.h"
|
||||
#include "signal_conditioner.h"
|
||||
#include "direct_resampler_conditioner.h"
|
||||
#include "fir_filter.h"
|
||||
#include "gps_l1_ca_gps_sdr_acquisition.h"
|
||||
#include "gps_l1_ca_pcps_acquisition.h"
|
||||
#include "gps_l1_ca_tong_pcps_acquisition.h"
|
||||
@@ -260,7 +261,11 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock(
|
||||
// DATA TYPE ADAPTER -----------------------------------------------------------
|
||||
|
||||
// INPUT FILTER ----------------------------------------------------------------
|
||||
|
||||
else if (implementation.compare("Fir_Filter") == 0)
|
||||
{
|
||||
block = new FirFilter(configuration, role, in_streams,
|
||||
out_streams, queue);
|
||||
}
|
||||
// RESAMPLER -------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ exe gnss-sdr : main.cc
|
||||
../algorithms/channel/adapters//channel
|
||||
../algorithms/channel/libs//gps_l1_ca_channel_fsm
|
||||
../algorithms/conditioner/adapters//signal_conditioner
|
||||
../algorithms/input_filter/adapters//fir_filter
|
||||
../algorithms/libs//gps_sdr_signal_processing
|
||||
../algorithms/libs//gnss_sdr_valve
|
||||
../algorithms/libs//pass_through
|
||||
|
||||
127
src/tests/gnss_block/fir_filter_test.cc
Normal file
127
src/tests/gnss_block/fir_filter_test.cc
Normal file
@@ -0,0 +1,127 @@
|
||||
/*!
|
||||
* \file fir_filter_test.cc
|
||||
* \brief Test for the fir filter.
|
||||
* \author Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <sys/time.h>
|
||||
#include <iostream>
|
||||
#include <gnuradio/gr_top_block.h>
|
||||
#include <gnuradio/gr_sig_source_c.h>
|
||||
#include <gnuradio/gr_msg_queue.h>
|
||||
#include <gnuradio/gr_null_sink.h>
|
||||
|
||||
#include "gnss_block_factory.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include "in_memory_configuration.h"
|
||||
#include "gnss_sdr_valve.h"
|
||||
#include "fir_filter.h"
|
||||
|
||||
DEFINE_string(filter_test_output_filename, "../src/tests/data/fir_filter_test_output.dat", "Dump filename")
|
||||
;
|
||||
|
||||
class Fir_Filter_Test: public ::testing::Test {
|
||||
protected:
|
||||
Fir_Filter_Test() {
|
||||
queue = gr_make_msg_queue(0);
|
||||
top_block = gr_make_top_block("Fir filter test");
|
||||
factory = new GNSSBlockFactory();
|
||||
config = new InMemoryConfiguration();
|
||||
config->set_property("InputFilter.number_of_taps", "4");
|
||||
config->set_property("InputFilter.number_of_bands", "2");
|
||||
|
||||
config->set_property("InputFilter.band1_begin", "0.0");
|
||||
config->set_property("InputFilter.band1_end", "0.45");
|
||||
config->set_property("InputFilter.band2_begin", "0.55");
|
||||
config->set_property("InputFilter.band2_end", "1.0");
|
||||
|
||||
config->set_property("InputFilter.ampl1_begin", "1.0");
|
||||
config->set_property("InputFilter.ampl1_end", "1.0");
|
||||
config->set_property("InputFilter.ampl2_begin", "0.0");
|
||||
config->set_property("InputFilter.ampl2_end", "0.0");
|
||||
|
||||
config->set_property("InputFilter.band1_error", "1.0");
|
||||
config->set_property("InputFilter.band2_error", "1.0");
|
||||
|
||||
config->set_property("InputFilter.filter_type", "bandpass");
|
||||
config->set_property("InputFilter.grid_density", "16");
|
||||
|
||||
// config->set_property("InputFilter.dump", "true");
|
||||
|
||||
gnss_block = factory->GetBlock(config, "InputFilter", "Fir_Filter", 1,
|
||||
1, queue);
|
||||
|
||||
item_size = sizeof(gr_complex);
|
||||
|
||||
}
|
||||
~Fir_Filter_Test() {
|
||||
delete factory;
|
||||
delete config;
|
||||
}
|
||||
gr_msg_queue_sptr queue;
|
||||
gr_top_block_sptr top_block;
|
||||
GNSSBlockFactory* factory;
|
||||
InMemoryConfiguration* config;
|
||||
GNSSBlockInterface* gnss_block;
|
||||
size_t item_size;
|
||||
|
||||
};
|
||||
|
||||
TEST_F(Fir_Filter_Test, InstantiationConnectAndRunTest)
|
||||
{
|
||||
int fs_in = 8000000;
|
||||
int nsamples = 10000000;
|
||||
struct timeval tv;
|
||||
long long int begin;
|
||||
long long int end;
|
||||
|
||||
ASSERT_NE( (int)gnss_block, NULL)
|
||||
<< "Function factory->GetInputFilter(config, queue) fails." << std::endl;
|
||||
|
||||
ASSERT_NO_THROW( {
|
||||
gnss_block->connect(top_block);
|
||||
gr_sig_source_c_sptr source = gr_make_sig_source_c(fs_in,GR_SIN_WAVE, 1000, 1, 0);
|
||||
gr_block_sptr valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue);
|
||||
gr_block_sptr null_sink = gr_make_null_sink(item_size);
|
||||
|
||||
top_block->connect(source, 0, valve, 0);
|
||||
top_block->connect(valve, 0, gnss_block->get_left_block(), 0);
|
||||
top_block->connect(gnss_block->get_right_block(), 0, null_sink, 0);
|
||||
}) << "Failure connecting the top_block."<< std::endl;
|
||||
|
||||
EXPECT_NO_THROW( {
|
||||
gettimeofday(&tv, NULL);
|
||||
begin = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
end = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
}) << "Failure running he top_block."<< std::endl;
|
||||
std::cout << "Filtered " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
|
||||
/**
|
||||
* Copyright notice
|
||||
*/
|
||||
|
||||
/**
|
||||
* Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Executes a resampler based on some input parameters.
|
||||
* This is intended to check performance of resampling implementations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
#include <gr_top_block.h>
|
||||
#include <gr_file_source.h>
|
||||
#include <gr_null_sink.h>
|
||||
#include <gr_rational_resampler_base_ccf.h>
|
||||
#include <gr_firdes.h>
|
||||
|
||||
#include "gnss_sdr_direct_resampler_ccf.h"
|
||||
|
||||
DEFINE_string(signal_file, "signal_samples/signal.dat",
|
||||
"Path to the file containing the signal samples");
|
||||
|
||||
DEFINE_int64(fs_in, 8000000, "FS of the signal in Hz");
|
||||
DEFINE_int64(fs_out, 2048000, "FS of the resampled signal in Hz");
|
||||
|
||||
int mcd(int a, int b){
|
||||
if (a==0) return b;
|
||||
return mcd(b%a,a);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
|
||||
LOG_AT_LEVEL(INFO) << "Frequency IN " << FLAGS_fs_in;
|
||||
LOG_AT_LEVEL(INFO) << "Frequency OUT " << FLAGS_fs_out;
|
||||
|
||||
gr_top_block_sptr top_block = gr_make_top_block("gnss_sdr_direct_resampler_test");
|
||||
gr_file_source_sptr source = gr_make_file_source(sizeof(gr_complex),FLAGS_signal_file.c_str());
|
||||
|
||||
gnss_sdr_direct_resampler_ccf_sptr resampler = gnss_sdr_make_direct_resampler_ccf(FLAGS_fs_in, FLAGS_fs_out);
|
||||
gr_block_sptr sink = gr_make_null_sink(sizeof(gr_complex));
|
||||
|
||||
top_block->connect(source, 0, resampler, 0);
|
||||
top_block->connect(resampler, 0, sink, 0);
|
||||
|
||||
LOG_AT_LEVEL(INFO) << "Run";
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
long long int end = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds";
|
||||
std::cout << (end - begin) << std::endl;
|
||||
top_block->stop();
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <gr_sig_source_c.h>
|
||||
#include <gr_head.h>
|
||||
#include <gr_null_sink.h>
|
||||
#include <gr_top_block.h>
|
||||
#include <gr_msg_queue.h>
|
||||
#include <gr_file_source.h>
|
||||
|
||||
#include "gnss_block_factory.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include "in_memory_configuration.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
DEFINE_string(fs_in, "4000000", "FS of the input signal");
|
||||
DEFINE_string(fs_out, "2048000", "FS of the output signal");
|
||||
DEFINE_string(dump_filename, "./data/signal_conditioner_test.dat", "Dump filename");
|
||||
DEFINE_string(signal_filename, "./signal_samples/usrp_30.dat", "Name of the file containing the signal samples");
|
||||
DEFINE_string(item_type, "short", "Type of data for samples");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
gr_msg_queue_sptr queue = gr_make_msg_queue(0);
|
||||
|
||||
DLOG(INFO) << "fs_in " << FLAGS_fs_in;
|
||||
DLOG(INFO) << "fs_out " << FLAGS_fs_out;
|
||||
|
||||
gr_top_block_sptr top_block = gr_make_top_block("signal conditioner test");
|
||||
|
||||
GNSSBlockFactory* factory = new GNSSBlockFactory();
|
||||
InMemoryConfiguration* config = new InMemoryConfiguration();
|
||||
|
||||
config->set_property("SignalConditioner.implementation", "DirectResampler");
|
||||
config->set_property("SignalConditioner.sample_freq_in", FLAGS_fs_in.c_str());
|
||||
config->set_property("SignalConditioner.sample_freq_out", FLAGS_fs_out.c_str());
|
||||
config->set_property("SignalConditioner.dump", "true");
|
||||
config->set_property("SignalConditioner.dump_filename", FLAGS_dump_filename);
|
||||
config->set_property("SignalConditioner.item_type", FLAGS_item_type);
|
||||
|
||||
GNSSBlockInterface* gnss_block = factory->GetSignalConditioner(config, queue);
|
||||
gnss_block->connect(top_block);
|
||||
|
||||
size_t item_size;
|
||||
|
||||
if(FLAGS_item_type.compare("short") == 0) {
|
||||
item_size = sizeof(short);
|
||||
} else if(FLAGS_item_type.compare("gr_complex") == 0) {
|
||||
item_size = sizeof(gr_complex);
|
||||
} else {
|
||||
item_size = sizeof(short);
|
||||
}
|
||||
|
||||
gr_block_sptr null_sink = gr_make_null_sink(item_size);
|
||||
gr_block_sptr file_source = gr_make_file_source(item_size, FLAGS_signal_filename.c_str());
|
||||
|
||||
top_block->connect(file_source, 0, gnss_block->get_left_block(), 0);
|
||||
top_block->connect(gnss_block->get_right_block(), 0, null_sink, 0);
|
||||
|
||||
LOG_AT_LEVEL(INFO) << "Run";
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
long long int begin = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
top_block->run(); // Start threads and wait
|
||||
gettimeofday(&tv, NULL);
|
||||
long long int end = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds";
|
||||
std::cout << (end - begin) << std::endl;
|
||||
top_block->stop();
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ TEST(Direct_Resampler_Conditioner_Cc_Test, InstantiationAndRunTest) {
|
||||
long long int begin;
|
||||
long long int end;
|
||||
|
||||
EXPECT_NO_THROW( {
|
||||
EXPECT_NO_THROW({
|
||||
|
||||
direct_resampler_conditioner_cc_sptr resampler = direct_resampler_make_conditioner_cc(fs_in, fs_out);
|
||||
|
||||
@@ -80,7 +80,7 @@ TEST(Direct_Resampler_Conditioner_Cc_Test, InstantiationAndRunTest) {
|
||||
gettimeofday(&tv, NULL);
|
||||
end = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
top_block->stop();
|
||||
}) << "Connection failure of direct_resampler_conditioner.";
|
||||
}) << "Failure running direct_resampler_conditioner.";
|
||||
|
||||
std::cout << "Resampled " << nsamples << " samples in " << (end-begin) << " microseconds" << std::endl;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ exe run_tests : test_main.cc
|
||||
../algorithms/channel/adapters//channel
|
||||
../algorithms/channel/libs//gps_l1_ca_channel_fsm
|
||||
../algorithms/conditioner/adapters//signal_conditioner
|
||||
../algorithms/input_filter/adapters//fir_filter
|
||||
../algorithms/libs//gps_sdr_signal_processing
|
||||
../algorithms/libs//gnss_sdr_valve
|
||||
../algorithms/libs//pass_through
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
#include "arithmetic/complex_arithmetic_libc.cc"
|
||||
#include "arithmetic/correlations_libc.cc"
|
||||
#include "arithmetic/cordic_test.cc"
|
||||
|
||||
#include "gnss_block/fir_filter_test.cc"
|
||||
#include "gnss_block/direct_resampler_conditioner_test.cc"
|
||||
|
||||
concurrent_queue<Gps_Navigation_Message> global_gps_nav_msg_queue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user