1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-18 11:09:56 +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:
Luis Esteve 2012-02-24 16:06:14 +00:00
parent 17bf90e1c5
commit c0aca3b5d0
19 changed files with 629 additions and 199 deletions

View File

@ -1,13 +1,9 @@
; MASTER configuration file
; This file should be updated with the latest changes in the configuration parameters, as a sample configuration file.
; use RELATIVE file path in this configuration file
; Sample for a configuration file for GNSS-SDR
[GNSS-SDR]
;######### GLOBAL OPTIONS ##################
;internal_fs_hz: Internal signal sampling frequency after the signal conditioning stage [Hz].
GNSS-SDR.internal_fs_hz=4000000
GNSS-SDR.internal_fs_hz=2046000
;######### CONTROL_THREAD CONFIG ############
ControlThread.wait_for_flowgraph=false
@ -39,13 +35,97 @@ SignalSource.dump=false
SignalSource.enable_throttle_control=false
;######### SIGNAL_CONDITIONER CONFIG ############
;## Enables and configures a real-time resampler. Please disable it in this version.
;implementation: Pass_Through disables this block
SignalConditioner.implementation=Pass_Through
SignalConditioner.item_type=gr_complex
SignalConditioner.sample_freq_in=4000000
SignalConditioner.sample_freq_out=4000000
SignalConditioner.dump=false
;## It holds blocks to change data type, filter and resample input data.
;#implementation: Pass_Through disables this block
SignalConditioner.implementation=Signal_Conditioner
;######### DATA_TYPE_ADAPTER CONFIG ############
;## Changes the type of input data. Please disable it in this version.
;#implementation: Pass_Through disables this block
DataTypeAdapter.implementation=Pass_Through
;######### INPUT_FILTER CONFIG ############
;## Filter the input data. Can be combined with frequency translation for IF signals
;#implementation: Pass_Through disables this block
;InputFilter.implementation=Fir_Filter
InputFilter.implementation=Pass_Through
;#dump: Dump the filtered data to a file.
InputFilter.dump=false
;#dump_filename: Log path and filename.
InputFilter.dump=../data/input_filter.dat
;#The following options are used in the filter design of Fir_Filter implementation.
;#These options are based on parameters of gnuradio's function: gr_remez.
;#These function calculates the optimal (in the Chebyshev/minimax sense) FIR filter inpulse reponse given a set of band edges, the desired reponse on those bands, and the weight given to the error in those bands.
;#input_item_type: Type and resolution for input signal samples. Use only gr_complex in this version.
InputFilter.input_item_type=gr_complex
;#outut_item_type: Type and resolution for output filtered signal samples. Use only gr_complex in this version.
InputFilter.output_item_type=gr_complex
;#taps_item_type: Type and resolution for the taps of the filter. Use only float in this version.
InputFilter.taps_item_type=float
;#number_of_taps: Number of taps in the filter. Increasing this parameter increases the processing time
InputFilter.number_of_taps=5
;#number_of _bands: Number of frequency bands in the filter.
InputFilter.number_of_bands=2
;#bands: frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...].
;#Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2)
;#The number of band_begin and band_end elements must match the number of bands
InputFilter.band1_begin=0.0
InputFilter.band1_end=0.45
InputFilter.band2_begin=0.55
InputFilter.band2_end=1.0
;#ampl: desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...].
;#The number of ampl_begin and ampl_end elements must match the number of bands
InputFilter.ampl1_begin=1.0
InputFilter.ampl1_end=1.0
InputFilter.ampl2_begin=0.0
InputFilter.ampl2_end=0.0
;#band_error: weighting applied to each band (usually 1).
;#The number of band_error elements must match the number of bands
InputFilter.band1_error=1.0
InputFilter.band2_error=1.0
;#filter_type: one of "bandpass", "hilbert" or "differentiator"
InputFilter.filter_type=bandpass
;#grid_density: determines how accurately the filter will be constructed.
;The minimum value is 16; higher values are slower to compute the filter.
InputFilter.grid_density=16
;######### RESAMPLER CONFIG ############
;## Resamples the input data.
;#implementation: Pass_Through disables this block
Resampler.implementation=Direct_Resampler
;Resampler.implementation=Pass_Through
;#dump: Dump the filtered data to a file.
InputFilter.dump=false
;#dump_filename: Log path and filename.
InputFilter.dump=../data/resampler.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
Resampler.item_type=gr_complex
;#sample_freq_in: the sample frequency of the input signal
Resampler.sample_freq_in=4000000
;#sample_freq_out: the desired sample frequency of the output signal
Resampler.sample_freq_out=2046000
;######### CHANNELS GLOBAL CONFIG ############
;#count: Number of available satellite channels.
@ -130,7 +210,7 @@ Channel2.system=GPS
Channel2.signal=1C
Channel2.satellite=21
;######### CHANNEL 2 CONFIG ############
;######### CHANNEL 3 CONFIG ############
Channel3.system=GPS
Channel3.signal=1C
@ -176,21 +256,21 @@ Acquisition0.doppler_step=250
;######### ACQUISITION CH 1 CONFIG ############
Acquisition1.implementation=GPS_L1_CA_PCPS_Acquisition
Acquisition1.threshold=7000
Acquisition1.threshold=70
Acquisition1.doppler_max=10000
Acquisition1.doppler_step=250
;Acquisition1.repeat_satellite=true
;######### ACQUISITION CH 2 CONFIG ############
Acquisition2.implementation=GPS_L1_CA_PCPS_Acquisition
Acquisition2.threshold=7000
Acquisition2.threshold=70
Acquisition2.doppler_max=10000
Acquisition2.doppler_step=250
;Acquisition2.repeat_satellite=true
;######### ACQUISITION CH 3 CONFIG ############
Acquisition3.implementation=GPS_L1_CA_PCPS_Acquisition
Acquisition3.threshold=7000
Acquisition3.threshold=70
Acquisition3.doppler_max=10000
Acquisition3.doppler_step=250
;Acquisition3.repeat_satellite=true

View File

@ -7,7 +7,7 @@
;######### GLOBAL OPTIONS ##################
;internal_fs_hz: Internal signal sampling frequency after the signal conditioning stage [Hz].
GNSS-SDR.internal_fs_hz=4000000
GNSS-SDR.internal_fs_hz=2046000
;######### CONTROL_THREAD CONFIG ############
ControlThread.wait_for_flowgraph=false
@ -17,7 +17,7 @@ ControlThread.wait_for_flowgraph=false
SignalSource.implementation=File_Signal_Source
;#filename: path to file with the captured GNSS signal samples to be processed
SignalSource.filename=../data/agilent_cap2.dat
SignalSource.filename=/home/luis/Project/signals/cap2/agilent_cap2.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
SignalSource.item_type=gr_complex
@ -39,13 +39,97 @@ SignalSource.dump=false
SignalSource.enable_throttle_control=false
;######### SIGNAL_CONDITIONER CONFIG ############
;## Enables and configures a real-time resampler. Please disable it in this version.
;implementation: Pass_Through disables this block
SignalConditioner.implementation=Pass_Through
SignalConditioner.item_type=gr_complex
SignalConditioner.sample_freq_in=4000000
SignalConditioner.sample_freq_out=4000000
SignalConditioner.dump=false
;## It holds blocks to change data type, filter and resample input data.
;#implementation: Pass_Through disables this block
SignalConditioner.implementation=Signal_Conditioner
;######### DATA_TYPE_ADAPTER CONFIG ############
;## Changes the type of input data. Please disable it in this version.
;#implementation: Pass_Through disables this block
DataTypeAdapter.implementation=Pass_Through
;######### INPUT_FILTER CONFIG ############
;## Filter the input data. Can be combined with frequency translation for IF signals
;#implementation: Pass_Through disables this block
;InputFilter.implementation=Fir_Filter
InputFilter.implementation=Pass_Through
;#dump: Dump the filtered data to a file.
InputFilter.dump=false
;#dump_filename: Log path and filename.
InputFilter.dump=../data/input_filter.dat
;#The following options are used in the filter design of Fir_Filter implementation.
;#These options are based on parameters of gnuradio's function: gr_remez.
;#These function calculates the optimal (in the Chebyshev/minimax sense) FIR filter inpulse reponse given a set of band edges, the desired reponse on those bands, and the weight given to the error in those bands.
;#input_item_type: Type and resolution for input signal samples. Use only gr_complex in this version.
InputFilter.input_item_type=gr_complex
;#outut_item_type: Type and resolution for output filtered signal samples. Use only gr_complex in this version.
InputFilter.output_item_type=gr_complex
;#taps_item_type: Type and resolution for the taps of the filter. Use only float in this version.
InputFilter.taps_item_type=float
;#number_of_taps: Number of taps in the filter. Increasing this parameter increases the processing time
InputFilter.number_of_taps=5
;#number_of _bands: Number of frequency bands in the filter.
InputFilter.number_of_bands=2
;#bands: frequency at the band edges [ b1 e1 b2 e2 b3 e3 ...].
;#Frequency is in the range [0, 1], with 1 being the Nyquist frequency (Fs/2)
;#The number of band_begin and band_end elements must match the number of bands
InputFilter.band1_begin=0.0
InputFilter.band1_end=0.45
InputFilter.band2_begin=0.55
InputFilter.band2_end=1.0
;#ampl: desired amplitude at the band edges [ a(b1) a(e1) a(b2) a(e2) ...].
;#The number of ampl_begin and ampl_end elements must match the number of bands
InputFilter.ampl1_begin=1.0
InputFilter.ampl1_end=1.0
InputFilter.ampl2_begin=0.0
InputFilter.ampl2_end=0.0
;#band_error: weighting applied to each band (usually 1).
;#The number of band_error elements must match the number of bands
InputFilter.band1_error=1.0
InputFilter.band2_error=1.0
;#filter_type: one of "bandpass", "hilbert" or "differentiator"
InputFilter.filter_type=bandpass
;#grid_density: determines how accurately the filter will be constructed.
;The minimum value is 16; higher values are slower to compute the filter.
InputFilter.grid_density=16
;######### RESAMPLER CONFIG ############
;## Resamples the input data.
;#implementation: Pass_Through disables this block
Resampler.implementation=Direct_Resampler
;Resampler.implementation=Pass_Through
;#dump: Dump the filtered data to a file.
InputFilter.dump=false
;#dump_filename: Log path and filename.
InputFilter.dump=../data/resampler.dat
;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version.
Resampler.item_type=gr_complex
;#sample_freq_in: the sample frequency of the input signal
Resampler.sample_freq_in=4000000
;#sample_freq_out: the desired sample frequency of the output signal
Resampler.sample_freq_out=2046000
;######### CHANNELS GLOBAL CONFIG ############
;#count: Number of available satellite channels.
@ -116,7 +200,7 @@ Channel0.system=GPS
Channel0.signal=1C
;#satellite: Satellite PRN ID for this channel. Disable this option to random search
Channel0.satellite=1
Channel0.satellite=2
;######### CHANNEL 1 CONFIG ############
@ -130,6 +214,12 @@ Channel2.system=GPS
Channel2.signal=1C
Channel2.satellite=21
;######### CHANNEL 3 CONFIG ############
Channel3.system=GPS
Channel3.signal=1C
Channel3.satellite=13
;######### ACQUISITION GLOBAL CONFIG ############
@ -220,8 +310,7 @@ Acquisition7.doppler_step=250
;######### TRACKING GLOBAL CONFIG ############
;#implementatiion: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking]
Tracking.implementation=GPS_L1_CA_DLL_PLL_Tracking
Tracking.implementation=GPS_L1_CA_DLL_FLL_PLL_Tracking
;#item_type: Type and resolution for each of the signal samples. Use only [gr_complex] in this version.
Tracking.item_type=gr_complex
@ -281,7 +370,7 @@ PVT.averaging_depth=2
PVT.flag_averaging=true
;#dump: Enable or disable the PVT internal binary data file logging [true] or [false]
PVT.dump=true
PVT.dump=false
;#dump_filename: Log path and filename without extension. Notice that PVT will add ".dat" to the binary dump and ".kml" to GoogleEarth dump.
PVT.dump_filename=./PVT

View File

@ -25,6 +25,8 @@ project : requirements
<include>src/algorithms/channel/libs
<include>src/algorithms/conditioner/adapters
<include>src/algorithms/conditioner/gnuradio_blocks
<include>src/algorithms/input_filter/adapters
<include>src/algorithms/input_filter/gnuradio_blocks
<include>src/algorithms/libs
<include>src/algorithms/observables/adapters
<include>src/algorithms/observables/gnuradio_blocks

View File

@ -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()

View File

@ -50,7 +50,6 @@ SignalConditioner::SignalConditioner(ConfigurationInterface *configuration,
in_filt_(in_filt), res_(res), role_(role), implementation_(implementation),
queue_(queue)
{
// stop_ = false;
connected_ = false;
}

View 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));
}
}

View 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_ */

View File

@ -0,0 +1,3 @@
project : build-dir ../../../../build ;
obj fir_filter : fir_filter.cc ;

View File

@ -1,2 +1,2 @@
# build-project adapters ;
build-project adapters ;
# build-project gnuradio_blocks ;

View File

@ -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 ;

View File

@ -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() << ")";

View File

@ -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 -------------------------------------------------------------------

View File

@ -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

View 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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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

View File

@ -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;