mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-18 16:15:21 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into glonass
This commit is contained in:
@@ -46,7 +46,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
|
||||
{
|
||||
configuration_ = configuration;
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_filename = "../data/acquisition.dat";
|
||||
std::string default_dump_filename = "./data/acquisition.dat";
|
||||
|
||||
DLOG(INFO) << "role " << role;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ set(INPUT_FILTER_ADAPTER_SOURCES
|
||||
freq_xlating_fir_filter.cc
|
||||
beamformer_filter.cc
|
||||
pulse_blanking_filter.cc
|
||||
notch_filter.cc
|
||||
notch_filter_lite.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
||||
125
src/algorithms/input_filter/adapters/notch_filter.cc
Normal file
125
src/algorithms/input_filter/adapters/notch_filter.cc
Normal file
@@ -0,0 +1,125 @@
|
||||
/*!
|
||||
* \file notch_filter.cc
|
||||
* \brief Adapts a gnuradio gr_notch_filter
|
||||
* \author Antonio Ramos, 2017. antonio.ramosdet(at)gmail.com
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "notch_filter.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include "configuration_interface.h"
|
||||
#include "notch_cc.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
NotchFilter::NotchFilter(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams) :
|
||||
role_(role), in_streams_(in_streams),
|
||||
out_streams_(out_streams)
|
||||
{
|
||||
size_t item_size_;
|
||||
float pfa;
|
||||
float default_pfa = 0.001;
|
||||
float p_c_factor;
|
||||
float default_p_c_factor = 0.9;
|
||||
int length_;
|
||||
int default_length_ = 32;
|
||||
int n_segments_est;
|
||||
int default_n_segments_est = 12500;
|
||||
int n_segments_reset;
|
||||
int default_n_segments_reset = 5000000;
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/input_filter.dat";
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
DLOG(INFO) << "dump_ is " << dump_;
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
||||
pfa = configuration->property(role + ".pfa", default_pfa);
|
||||
p_c_factor = configuration->property(role + ".p_c_factor", default_p_c_factor);
|
||||
length_ = configuration->property(role + ".length", default_length_);
|
||||
n_segments_est = configuration->property(role + ".segments_est", default_n_segments_est);
|
||||
n_segments_reset = configuration->property(role + ".segments_reset", default_n_segments_reset);
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
notch_filter_ = make_notch_filter(pfa, p_c_factor, length_, n_segments_est, n_segments_reset);
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "input filter(" << notch_filter_->unique_id() << ")";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type for notch filter";
|
||||
item_size_ = sizeof(gr_complex);
|
||||
}
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NotchFilter::~NotchFilter()
|
||||
{}
|
||||
|
||||
|
||||
void NotchFilter::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(notch_filter_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected notch filter output to file sink";
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG(INFO) << "nothing to connect internally";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotchFilter::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(notch_filter_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr NotchFilter::get_left_block()
|
||||
{
|
||||
return notch_filter_;
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr NotchFilter::get_right_block()
|
||||
{
|
||||
return notch_filter_;
|
||||
}
|
||||
84
src/algorithms/input_filter/adapters/notch_filter.h
Normal file
84
src/algorithms/input_filter/adapters/notch_filter.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*!
|
||||
* \file notch_filter.h
|
||||
* \brief Adapter of a multistate Notch filter
|
||||
* \author Antonio Ramos, 2017. antonio.ramosdet(at)gmail.com
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_NOTCH_FILTER_H_
|
||||
#define GNSS_SDR_NOTCH_FILTER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include "gnss_block_interface.h"
|
||||
#include "notch_cc.h"
|
||||
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class NotchFilter: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
NotchFilter(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams,
|
||||
unsigned int out_streams);
|
||||
|
||||
virtual ~NotchFilter();
|
||||
std::string role()
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
|
||||
//! Returns "Notch_Filter"
|
||||
std::string implementation()
|
||||
{
|
||||
return "Notch_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:
|
||||
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::string role_;
|
||||
std::string item_type_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
notch_sptr notch_filter_;
|
||||
};
|
||||
|
||||
#endif //GNSS_SDR_NOTCH_FILTER_H_
|
||||
132
src/algorithms/input_filter/adapters/notch_filter_lite.cc
Normal file
132
src/algorithms/input_filter/adapters/notch_filter_lite.cc
Normal file
@@ -0,0 +1,132 @@
|
||||
/*!
|
||||
* \file notch_filter_lite.cc
|
||||
* \brief Adapts a gnuradio gr_notch_filter_lite
|
||||
* \author Antonio Ramos, 2017. antonio.ramosdet(at)gmail.com
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "notch_filter_lite.h"
|
||||
#include <cmath>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include "configuration_interface.h"
|
||||
#include "notch_lite_cc.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
NotchFilterLite::NotchFilterLite(ConfigurationInterface* configuration, std::string role,
|
||||
unsigned int in_streams, unsigned int out_streams) :
|
||||
role_(role), in_streams_(in_streams),
|
||||
out_streams_(out_streams)
|
||||
{
|
||||
size_t item_size_;
|
||||
float p_c_factor;
|
||||
float default_p_c_factor = 0.9;
|
||||
float pfa;
|
||||
float default_pfa = 0.001;
|
||||
int length_;
|
||||
int default_length_ = 32;
|
||||
int n_segments_est;
|
||||
int default_n_segments_est = 12500;
|
||||
int n_segments_reset;
|
||||
int default_n_segments_reset = 5000000;
|
||||
float default_samp_freq = 4000000;
|
||||
float samp_freq = configuration->property("SignalSource.sampling_frequency", default_samp_freq);
|
||||
float default_coeff_rate = samp_freq * 0.1;
|
||||
float coeff_rate;
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/input_filter.dat";
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
DLOG(INFO) << "dump_ is " << dump_;
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
||||
p_c_factor = configuration->property(role + ".p_c_factor", default_p_c_factor);
|
||||
pfa = configuration->property(role + ".pfa", default_pfa);
|
||||
coeff_rate = configuration->property(role + ".coeff_rate", default_coeff_rate);
|
||||
length_ = configuration->property(role + ".length", default_length_);
|
||||
n_segments_est = configuration->property(role + ".segments_est", default_n_segments_est);
|
||||
n_segments_reset = configuration->property(role + ".segments_reset", default_n_segments_reset);
|
||||
int n_segments_coeff = static_cast<int>((samp_freq / coeff_rate) / static_cast<float>(length_));
|
||||
n_segments_coeff = std::max(1, n_segments_coeff);
|
||||
if (item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size_ = sizeof(gr_complex);
|
||||
notch_filter_lite_ = make_notch_filter_lite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff);
|
||||
DLOG(INFO) << "Item size " << item_size_;
|
||||
DLOG(INFO) << "input filter(" << notch_filter_lite_->unique_id() << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WARNING) << item_type_ << " unrecognized item type for notch filter";
|
||||
item_size_ = sizeof(gr_complex);
|
||||
}
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NotchFilterLite::~NotchFilterLite()
|
||||
{}
|
||||
|
||||
|
||||
void NotchFilterLite::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(notch_filter_lite_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected notch filter output to file sink";
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG(INFO) << "nothing to connect internally";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotchFilterLite::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(notch_filter_lite_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr NotchFilterLite::get_left_block()
|
||||
{
|
||||
return notch_filter_lite_;
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr NotchFilterLite::get_right_block()
|
||||
{
|
||||
return notch_filter_lite_;
|
||||
}
|
||||
84
src/algorithms/input_filter/adapters/notch_filter_lite.h
Normal file
84
src/algorithms/input_filter/adapters/notch_filter_lite.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*!
|
||||
* \file notch_filter_lite.h
|
||||
* \brief Adapts a ligth version of a multistate notch filter
|
||||
* \author Antonio Ramos, 2017. antonio.ramosdet(at)gmail.com
|
||||
*
|
||||
* Detailed description of the file here if needed.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_NOTCH_FILTER_LITE_H_
|
||||
#define GNSS_SDR_NOTCH_FILTER_LITE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include "gnss_block_interface.h"
|
||||
#include "notch_lite_cc.h"
|
||||
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class NotchFilterLite: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
NotchFilterLite(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_streams,
|
||||
unsigned int out_streams);
|
||||
|
||||
virtual ~NotchFilterLite();
|
||||
std::string role()
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
|
||||
//! Returns "Notch_Filter_Lite"
|
||||
std::string implementation()
|
||||
{
|
||||
return "Notch_Filter_Lite";
|
||||
}
|
||||
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:
|
||||
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
std::string role_;
|
||||
std::string item_type_;
|
||||
unsigned int in_streams_;
|
||||
unsigned int out_streams_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
notch_lite_sptr notch_filter_lite_;
|
||||
};
|
||||
|
||||
#endif //GNSS_SDR_NOTCH_FILTER_LITE_H_
|
||||
@@ -2,7 +2,7 @@
|
||||
* \file pulse_blanking_filter.cc
|
||||
* \brief Instantiates the GNSS-SDR pulse blanking filter
|
||||
* \author Javier Arribas 2017
|
||||
*
|
||||
* Antonio Ramos 2017
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "pulse_blanking_filter.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <glog/logging.h>
|
||||
#include "configuration_interface.h"
|
||||
|
||||
@@ -42,25 +41,29 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration,
|
||||
out_streams_(out_streams)
|
||||
{
|
||||
size_t item_size;
|
||||
|
||||
std::string default_input_item_type = "gr_complex";
|
||||
std::string default_output_item_type = "gr_complex";
|
||||
std::string default_dump_filename = "../data/input_filter.dat";
|
||||
|
||||
|
||||
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);
|
||||
dump_ = config_->property(role_ + ".dump", false);
|
||||
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
|
||||
|
||||
double Pfa = config_->property(role_ + ".Pfa", 0.001);
|
||||
|
||||
float default_pfa_ = 0.04;
|
||||
float pfa = config_->property(role_ + ".pfa", default_pfa_);
|
||||
int default_length_ = 32;
|
||||
int length_ = config_->property(role_ + ".length", default_length_);
|
||||
int default_n_segments_est = 12500;
|
||||
int n_segments_est = config_->property(role_ + ".segments_est", default_n_segments_est);
|
||||
int default_n_segments_reset = 5000000;
|
||||
int n_segments_reset = config_->property(role_ + ".segments_reset", default_n_segments_reset);
|
||||
if (input_item_type_.compare("gr_complex") == 0)
|
||||
{
|
||||
item_size = sizeof(gr_complex); //output
|
||||
input_size_ = sizeof(gr_complex); //input
|
||||
pulse_blanking_cc_ = make_pulse_blanking_cc(Pfa);
|
||||
pulse_blanking_cc_ = make_pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* \file pulse_blanking_filter.h
|
||||
* \brief Instantiates the GNSS-SDR pulse blanking filter
|
||||
* \author Javier Arribas 2017
|
||||
* Antonio Ramos 2017
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
@@ -39,9 +40,6 @@
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
/*!
|
||||
* \brief TODO
|
||||
*/
|
||||
class PulseBlankingFilter: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#
|
||||
|
||||
|
||||
set(INPUT_FILTER_GR_BLOCKS_SOURCES
|
||||
set(INPUT_FILTER_GR_BLOCKS_SOURCES
|
||||
beamformer.cc
|
||||
pulse_blanking_cc.cc
|
||||
notch_cc.cc
|
||||
notch_lite_cc.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@@ -27,6 +29,8 @@ include_directories(
|
||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||
${GNURADIO_BLOCKS_INCLUDE_DIRS}
|
||||
${VOLK_GNSSSDR_INCLUDE_DIRS}
|
||||
${GLOG_INCLUDE_DIRS}
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
file(GLOB INPUT_FILTER_GR_BLOCKS_HEADERS "*.h")
|
||||
@@ -37,5 +41,7 @@ source_group(Headers FILES ${INPUT_FILTER_GR_BLOCKS_HEADERS})
|
||||
target_link_libraries(input_filter_gr_blocks ${GNURADIO_FILTER_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${LOG4CPP_LIBRARIES})
|
||||
|
||||
if(NOT VOLK_GNSSSDR_FOUND)
|
||||
add_dependencies(input_filter_gr_blocks volk_gnsssdr_module)
|
||||
endif(NOT VOLK_GNSSSDR_FOUND)
|
||||
add_dependencies(input_filter_gr_blocks volk_gnsssdr_module glog-${glog_RELEASE})
|
||||
else(NOT VOLK_GNSSSDR_FOUND)
|
||||
add_dependencies(input_filter_gr_blocks glog-${glog_RELEASE})
|
||||
endif(NOT VOLK_GNSSSDR_FOUND)
|
||||
|
||||
149
src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc
Normal file
149
src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc
Normal file
@@ -0,0 +1,149 @@
|
||||
/*!
|
||||
* \file notch_cc.cc
|
||||
* \brief Implements a multi state notch filter algorithm
|
||||
* \author Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "notch_cc.h"
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h>
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
notch_sptr make_notch_filter(float pfa, float p_c_factor,
|
||||
int length_, int n_segments_est, int n_segments_reset)
|
||||
{
|
||||
return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset));
|
||||
}
|
||||
|
||||
|
||||
Notch::Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset) : gr::block("Notch",
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
||||
{
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
|
||||
set_alignment(std::max(1, alignment_multiple));
|
||||
set_history(2);
|
||||
this->pfa = pfa;
|
||||
noise_pow_est = 0.0;
|
||||
this->p_c_factor = gr_complex(p_c_factor , 0);
|
||||
this->length_ = length_; //Set the number of samples per segment
|
||||
filter_state_ = false; //Initial state of the filter
|
||||
n_deg_fred = 2 * length_; //Number of dregrees of freedom
|
||||
n_segments = 0;
|
||||
this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation
|
||||
this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated
|
||||
z_0 = gr_complex(0 , 0);
|
||||
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
|
||||
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
|
||||
c_samples = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
|
||||
angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||
last_out = gr_complex(0,0);
|
||||
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
|
||||
}
|
||||
|
||||
|
||||
Notch::~Notch()
|
||||
{
|
||||
volk_free(c_samples);
|
||||
volk_free(angle_);
|
||||
volk_free(power_spect);
|
||||
}
|
||||
|
||||
void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
|
||||
{
|
||||
for(unsigned int aux = 0; aux < ninput_items_required.size(); aux++)
|
||||
{
|
||||
ninput_items_required[aux] = length_;
|
||||
}
|
||||
}
|
||||
|
||||
int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
{
|
||||
int index_out = 0;
|
||||
float sig2dB = 0.0;
|
||||
float sig2lin = 0.0;
|
||||
lv_32fc_t dot_prod_;
|
||||
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
in++;
|
||||
while((index_out + length_) < noutput_items)
|
||||
{
|
||||
if((n_segments < n_segments_est) && (filter_state_ == false))
|
||||
{
|
||||
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
|
||||
d_fft->execute();
|
||||
volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_);
|
||||
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
||||
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / (static_cast<float>(n_deg_fred) );
|
||||
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / (static_cast<float>(n_segments + 1));
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
}
|
||||
else
|
||||
{
|
||||
volk_32fc_x2_conjugate_dot_prod_32fc(&dot_prod_, in, in, length_);
|
||||
if( (lv_creal(dot_prod_) / noise_pow_est) > thres_)
|
||||
{
|
||||
if(filter_state_ == false)
|
||||
{
|
||||
filter_state_ = true;
|
||||
last_out = gr_complex(0,0);
|
||||
}
|
||||
volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_);
|
||||
volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast<float>(1.0), length_);
|
||||
for(int aux = 0; aux < length_; aux++)
|
||||
{
|
||||
z_0 = std::exp(gr_complex(0,1) * (*(angle_ + aux)));
|
||||
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
|
||||
last_out = *(out + aux);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (n_segments > n_segments_reset)
|
||||
{
|
||||
n_segments = 0;
|
||||
}
|
||||
filter_state_ = false;
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
}
|
||||
}
|
||||
index_out += length_;
|
||||
n_segments++;
|
||||
in += length_;
|
||||
out += length_;
|
||||
}
|
||||
consume_each(index_out);
|
||||
return index_out;
|
||||
}
|
||||
84
src/algorithms/input_filter/gnuradio_blocks/notch_cc.h
Normal file
84
src/algorithms/input_filter/gnuradio_blocks/notch_cc.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*!
|
||||
* \file notch_cc.h
|
||||
* \brief Implements a notch filter algorithm
|
||||
* \author Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_NOTCH_H_
|
||||
#define GNSS_SDR_NOTCH_H_
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/block.h>
|
||||
#include <gnuradio/fft/fft.h>
|
||||
#include <memory>
|
||||
|
||||
class Notch;
|
||||
|
||||
typedef boost::shared_ptr<Notch> notch_sptr;
|
||||
|
||||
notch_sptr make_notch_filter(float pfa, float p_c_factor,
|
||||
int length_, int n_segments_est, int n_segments_reset);
|
||||
|
||||
/*!
|
||||
* \brief This class implements a real-time software-defined multi state notch filter
|
||||
*/
|
||||
|
||||
class Notch : public gr::block
|
||||
{
|
||||
private:
|
||||
|
||||
float pfa;
|
||||
float noise_pow_est;
|
||||
float thres_;
|
||||
int length_;
|
||||
int n_deg_fred;
|
||||
unsigned int n_segments;
|
||||
unsigned int n_segments_est;
|
||||
unsigned int n_segments_reset;
|
||||
bool filter_state_;
|
||||
gr_complex last_out;
|
||||
gr_complex z_0;
|
||||
gr_complex p_c_factor;
|
||||
gr_complex* c_samples;
|
||||
float* angle_;
|
||||
float* power_spect;
|
||||
std::unique_ptr<gr::fft::fft_complex> d_fft;
|
||||
|
||||
public:
|
||||
|
||||
Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset);
|
||||
|
||||
~Notch();
|
||||
|
||||
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
|
||||
|
||||
int general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif //GNSS_SDR_NOTCH_H_
|
||||
159
src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc
Normal file
159
src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc
Normal file
@@ -0,0 +1,159 @@
|
||||
/*!
|
||||
* \file notch_lite_cc.cc
|
||||
* \brief Implements a multi state notch filter algorithm
|
||||
* \author Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "notch_lite_cc.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h>
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff)
|
||||
{
|
||||
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
|
||||
}
|
||||
|
||||
NotchLite::NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) : gr::block("NotchLite",
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
||||
{
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
|
||||
set_alignment(std::max(1, alignment_multiple));
|
||||
set_history(2);
|
||||
this->p_c_factor = gr_complex(p_c_factor , 0);
|
||||
this->n_segments_est = n_segments_est;
|
||||
this->n_segments_reset = n_segments_reset;
|
||||
this->n_segments_coeff_reset = n_segments_coeff;
|
||||
this->n_segments_coeff = 0;
|
||||
this->length_ = length_;
|
||||
set_output_multiple(length_);
|
||||
this->pfa = pfa;
|
||||
n_segments = 0;
|
||||
n_deg_fred = 2 * length_;
|
||||
noise_pow_est = 0.0;
|
||||
filter_state_ = false;
|
||||
z_0 = gr_complex(0 , 0);
|
||||
last_out = gr_complex(0, 0);
|
||||
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
|
||||
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
|
||||
c_samples1 = gr_complex(0, 0);
|
||||
c_samples2 = gr_complex(0, 0);
|
||||
angle1 = 0.0;
|
||||
angle2 = 0.0;
|
||||
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
|
||||
}
|
||||
|
||||
NotchLite::~NotchLite()
|
||||
{
|
||||
volk_free(power_spect);
|
||||
}
|
||||
|
||||
void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
|
||||
{
|
||||
for(unsigned int aux = 0; aux < ninput_items_required.size(); aux++)
|
||||
{
|
||||
ninput_items_required[aux] = length_;
|
||||
}
|
||||
}
|
||||
|
||||
int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
{
|
||||
int index_out = 0;
|
||||
float sig2dB = 0.0;
|
||||
float sig2lin = 0.0;
|
||||
lv_32fc_t dot_prod_;
|
||||
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
in++;
|
||||
while((index_out + length_) < noutput_items)
|
||||
{
|
||||
if((n_segments < n_segments_est) && (filter_state_ == false))
|
||||
{
|
||||
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
|
||||
d_fft->execute();
|
||||
volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_);
|
||||
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
||||
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / static_cast<float>(n_deg_fred);
|
||||
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / static_cast<float>(n_segments + 1);
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
}
|
||||
else
|
||||
{
|
||||
volk_32fc_x2_conjugate_dot_prod_32fc(&dot_prod_, in, in, length_);
|
||||
if( (lv_creal(dot_prod_) / noise_pow_est) > thres_)
|
||||
{
|
||||
if(filter_state_ == false)
|
||||
{
|
||||
filter_state_ = true;
|
||||
last_out = gr_complex(0,0);
|
||||
n_segments_coeff = 0;
|
||||
}
|
||||
if(n_segments_coeff == 0)
|
||||
{
|
||||
volk_32fc_x2_multiply_conjugate_32fc(&c_samples1, (in + 1), in, 1);
|
||||
volk_32fc_s32f_atan2_32f(&angle1, &c_samples1, static_cast<float>(1.0), 1);
|
||||
volk_32fc_x2_multiply_conjugate_32fc(&c_samples2, (in + length_ - 1), (in + length_ - 2), 1);
|
||||
volk_32fc_s32f_atan2_32f(&angle2, &c_samples2, static_cast<float>(1.0), 1);
|
||||
float angle_ = (angle1 + angle2) / 2.0;
|
||||
z_0 = std::exp(gr_complex(0,1) * angle_);
|
||||
}
|
||||
for(int aux = 0; aux < length_; aux++)
|
||||
{
|
||||
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
|
||||
last_out = *(out + aux);
|
||||
}
|
||||
n_segments_coeff++;
|
||||
n_segments_coeff = n_segments_coeff % n_segments_coeff_reset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (n_segments > n_segments_reset)
|
||||
{
|
||||
n_segments = 0;
|
||||
}
|
||||
filter_state_ = false;
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
}
|
||||
}
|
||||
index_out += length_;
|
||||
n_segments++;
|
||||
in += length_;
|
||||
out += length_;
|
||||
}
|
||||
consume_each(index_out);
|
||||
return index_out;
|
||||
}
|
||||
87
src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h
Normal file
87
src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*!
|
||||
* \file notch_lite_cc.h
|
||||
* \brief Implements a notch filter ligth algorithm
|
||||
* \author Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_NOTCH_LITE_H_
|
||||
#define GNSS_SDR_NOTCH_LITE_H_
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/block.h>
|
||||
#include <gnuradio/fft/fft.h>
|
||||
#include <memory>
|
||||
|
||||
class NotchLite;
|
||||
|
||||
typedef boost::shared_ptr<NotchLite> notch_lite_sptr;
|
||||
|
||||
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff);
|
||||
|
||||
/*!
|
||||
* \brief This class implements a real-time software-defined multi state notch filter ligth version
|
||||
*/
|
||||
|
||||
class NotchLite : public gr::block
|
||||
{
|
||||
private:
|
||||
|
||||
int length_;
|
||||
int n_segments;
|
||||
int n_segments_est;
|
||||
int n_segments_reset;
|
||||
int n_segments_coeff_reset;
|
||||
int n_segments_coeff;
|
||||
int n_deg_fred;
|
||||
float pfa;
|
||||
float thres_;
|
||||
float noise_pow_est;
|
||||
bool filter_state_;
|
||||
gr_complex last_out;
|
||||
gr_complex z_0;
|
||||
gr_complex p_c_factor;
|
||||
gr_complex c_samples1;
|
||||
gr_complex c_samples2;
|
||||
float angle1;
|
||||
float angle2;
|
||||
float* power_spect;
|
||||
std::unique_ptr<gr::fft::fft_complex> d_fft;
|
||||
|
||||
public:
|
||||
|
||||
NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff);
|
||||
|
||||
~NotchLite();
|
||||
|
||||
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
|
||||
|
||||
int general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif //GNSS_SDR_NOTCH_LITE_H_
|
||||
@@ -1,8 +1,8 @@
|
||||
/*!
|
||||
* \file pulse_blanking_cc.cc
|
||||
* \brief Implements a simple pulse blanking algorithm
|
||||
* \brief Implements a pulse blanking algorithm
|
||||
* \author Javier Arribas (jarribas(at)cttc.es)
|
||||
*
|
||||
* Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
@@ -30,61 +30,98 @@
|
||||
|
||||
#include "pulse_blanking_cc.h"
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h>
|
||||
#include <volk_gnsssdr/volk_gnsssdr.h>
|
||||
|
||||
|
||||
pulse_blanking_cc_sptr make_pulse_blanking_cc(double Pfa)
|
||||
using google::LogMessage;
|
||||
|
||||
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_,
|
||||
int n_segments_est, int n_segments_reset)
|
||||
{
|
||||
return pulse_blanking_cc_sptr(new pulse_blanking_cc(Pfa));
|
||||
return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset));
|
||||
}
|
||||
|
||||
|
||||
|
||||
pulse_blanking_cc::pulse_blanking_cc(double Pfa) : gr::block("pulse_blanking_cc",
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
||||
pulse_blanking_cc::pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset) : gr::block("pulse_blanking_cc",
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
||||
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
||||
{
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
|
||||
set_alignment(std::max(1, alignment_multiple));
|
||||
d_Pfa = Pfa;
|
||||
this->pfa = pfa;
|
||||
this->length_ = length_;
|
||||
last_filtered = false;
|
||||
n_segments = 0;
|
||||
this->n_segments_est = n_segments_est;
|
||||
this->n_segments_reset = n_segments_reset;
|
||||
noise_power_estimation = 0.0;
|
||||
n_deg_fred = 2 * length_;
|
||||
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
|
||||
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
|
||||
zeros_ = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
|
||||
for (int aux = 0; aux < length_; aux++)
|
||||
{
|
||||
zeros_[aux] = gr_complex(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int pulse_blanking_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
|
||||
pulse_blanking_cc::~pulse_blanking_cc()
|
||||
{
|
||||
volk_free(zeros_);
|
||||
}
|
||||
|
||||
void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
|
||||
{
|
||||
for(unsigned int aux=0; aux < ninput_items_required.size(); aux++)
|
||||
{
|
||||
ninput_items_required[aux] = length_;
|
||||
}
|
||||
}
|
||||
|
||||
int pulse_blanking_cc::general_work (int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
{
|
||||
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
|
||||
// 1- (optional) Compute the input signal power estimation
|
||||
//float mean;
|
||||
//float stddev;
|
||||
//volk_32f_stddev_and_mean_32f_x2(&stddev, &mean, in, noutput_items);
|
||||
|
||||
float* magnitude;
|
||||
magnitude = static_cast<float*>(volk_gnsssdr_malloc(noutput_items * sizeof(float), volk_gnsssdr_get_alignment()));
|
||||
|
||||
float var;
|
||||
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||
float* magnitude = static_cast<float *>(volk_malloc(noutput_items * sizeof(float), volk_get_alignment()));
|
||||
volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items);
|
||||
volk_32f_accumulator_s32f(&var, magnitude, noutput_items);
|
||||
var /= static_cast<float>(noutput_items);
|
||||
// compute pulse blanking threshold (Paper Borio 2016)
|
||||
|
||||
float Th = sqrt(-2.0 * var * log10(d_Pfa));
|
||||
|
||||
//apply the pulse blanking
|
||||
//todo: write volk kernel to optimize the blanking
|
||||
memcpy(out,in, sizeof(gr_complex)*noutput_items);
|
||||
for (int n = 0; n < noutput_items; n++)
|
||||
int sample_index = 0;
|
||||
float segment_energy;
|
||||
while((sample_index + length_) < noutput_items)
|
||||
{
|
||||
if (std::abs(out[n]) > Th)
|
||||
volk_32f_accumulator_s32f(&segment_energy, (magnitude + sample_index), length_);
|
||||
if((n_segments < n_segments_est) && (last_filtered == false))
|
||||
{
|
||||
out[n] = gr_complex(0,0);
|
||||
noise_power_estimation = ( static_cast<float>(n_segments) * noise_power_estimation + segment_energy / static_cast<float>(n_deg_fred) ) / static_cast<float>(n_segments + 1);
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if((segment_energy / noise_power_estimation) > thres_)
|
||||
{
|
||||
memcpy(out, zeros_, sizeof(gr_complex) * length_);
|
||||
last_filtered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(out, in, sizeof(gr_complex) * length_);
|
||||
last_filtered = false;
|
||||
if (n_segments > n_segments_reset)
|
||||
{
|
||||
n_segments = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
in += length_;
|
||||
out += length_;
|
||||
sample_index += length_;
|
||||
n_segments++;
|
||||
}
|
||||
consume_each(noutput_items);
|
||||
return noutput_items;
|
||||
volk_free(magnitude);
|
||||
consume_each(sample_index);
|
||||
return sample_index;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*!
|
||||
* \file pulse_blanking_cc.h
|
||||
* \brief Implements a simple pulse blanking algorithm
|
||||
* \brief Implements a pulse blanking algorithm
|
||||
* \author Javier Arribas (jarribas(at)cttc.es)
|
||||
*
|
||||
* Antonio Ramos (antonio.ramosdet(at)gmail.com)
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||
@@ -38,22 +38,35 @@ class pulse_blanking_cc;
|
||||
|
||||
typedef boost::shared_ptr<pulse_blanking_cc> pulse_blanking_cc_sptr;
|
||||
|
||||
pulse_blanking_cc_sptr make_pulse_blanking_cc(double Pfa);
|
||||
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief This class adapts a short (16-bits) interleaved sample stream
|
||||
* into a std::complex<short> stream
|
||||
*/
|
||||
class pulse_blanking_cc : public gr::block
|
||||
{
|
||||
private:
|
||||
friend pulse_blanking_cc_sptr make_pulse_blanking_cc(double Pfa);
|
||||
double d_Pfa;
|
||||
|
||||
int length_;
|
||||
int n_segments;
|
||||
int n_segments_est;
|
||||
int n_segments_reset;
|
||||
int n_deg_fred;
|
||||
bool last_filtered;
|
||||
float noise_power_estimation;
|
||||
float thres_;
|
||||
float pfa;
|
||||
gr_complex* zeros_;
|
||||
|
||||
public:
|
||||
pulse_blanking_cc(double Pfa);
|
||||
|
||||
pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset);
|
||||
|
||||
~pulse_blanking_cc();
|
||||
|
||||
int general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
|
||||
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -192,7 +192,9 @@ install(FILES
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_prefs.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_complex.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_common.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/saturation_arithmetic.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_avx_intrinsics.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_sse_intrinsics.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_sse3_intrinsics.h
|
||||
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_neon_intrinsics.h
|
||||
${PROJECT_BINARY_DIR}/include/volk_gnsssdr/volk_gnsssdr.h
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
# define __VOLK_ATTR_UNUSED __attribute__((unused))
|
||||
# define __VOLK_ATTR_INLINE __attribute__((always_inline))
|
||||
# define __VOLK_ATTR_DEPRECATED __attribute__((deprecated))
|
||||
# define __VOLK_ASM __asm__
|
||||
# define __VOLK_VOLATILE __volatile__
|
||||
# if __GNUC__ >= 4
|
||||
# define __VOLK_ATTR_EXPORT __attribute__((visibility("default")))
|
||||
# define __VOLK_ATTR_IMPORT __attribute__((visibility("default")))
|
||||
@@ -63,6 +65,8 @@
|
||||
# define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
|
||||
# define __VOLK_ATTR_EXPORT __declspec(dllexport)
|
||||
# define __VOLK_ATTR_IMPORT __declspec(dllimport)
|
||||
# define __VOLK_ASM __asm
|
||||
# define __VOLK_VOLATILE
|
||||
#else
|
||||
# define __VOLK_ATTR_ALIGNED(x)
|
||||
# define __VOLK_ATTR_UNUSED
|
||||
@@ -70,6 +74,8 @@
|
||||
# define __VOLK_ATTR_DEPRECATED
|
||||
# define __VOLK_ATTR_EXPORT
|
||||
# define __VOLK_ATTR_IMPORT
|
||||
# define __VOLK_ASM __asm__
|
||||
# define __VOLK_VOLATILE __volatile__
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -717,11 +717,11 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc,
|
||||
{
|
||||
if(both_sigs[j].is_signed)
|
||||
{
|
||||
fail = icompare((int16_t *) test_data[generic_offset][j], (int16_t *) test_data[i][j], vlen*(both_sigs[j].is_complex ? 2 : 1), tol_i);
|
||||
fail = icompare((int8_t *) test_data[generic_offset][j], (int8_t *) test_data[i][j], vlen*(both_sigs[j].is_complex ? 2 : 1), tol_i);
|
||||
}
|
||||
else
|
||||
{
|
||||
fail = icompare((uint16_t *) test_data[generic_offset][j], (uint16_t *) test_data[i][j], vlen*(both_sigs[j].is_complex ? 2 : 1), tol_i);
|
||||
fail = icompare((uint8_t *) test_data[generic_offset][j], (uint8_t *) test_data[i][j], vlen*(both_sigs[j].is_complex ? 2 : 1), tol_i);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
#ifndef GNSS_SDR_VOLK_QA_UTILS_H
|
||||
#define GNSS_SDR_VOLK_QA_UTILS_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define _DARWIN_C_SOURCE
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
@@ -42,7 +42,7 @@ struct VOLK_CPU volk_gnsssdr_cpu;
|
||||
#if ((__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 2) || (__clang_major__ >= 3)) && defined(HAVE_XGETBV)
|
||||
static inline unsigned long long _xgetbv(unsigned int index){
|
||||
unsigned int eax, edx;
|
||||
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
|
||||
__VOLK_ASM __VOLK_VOLATILE ("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
|
||||
return ((unsigned long long)edx << 32) | eax;
|
||||
}
|
||||
#define __xgetbv() _xgetbv(0)
|
||||
|
||||
@@ -46,345 +46,342 @@ using google::LogMessage;
|
||||
|
||||
hybrid_observables_cc_sptr hybrid_make_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history)
|
||||
{
|
||||
return hybrid_observables_cc_sptr(new hybrid_observables_cc(nchannels, dump, dump_filename, deep_history));
|
||||
return hybrid_observables_cc_sptr(new hybrid_observables_cc(nchannels, dump, dump_filename, deep_history));
|
||||
}
|
||||
|
||||
|
||||
hybrid_observables_cc::hybrid_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history) :
|
||||
gr::block("hybrid_observables_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)))
|
||||
gr::block("hybrid_observables_cc", gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)))
|
||||
{
|
||||
// initialize internal vars
|
||||
d_dump = dump;
|
||||
d_nchannels = nchannels;
|
||||
d_dump_filename = dump_filename;
|
||||
history_deep = deep_history;
|
||||
T_rx_s = 0.0;
|
||||
T_rx_step_s = 1e-3;// todo: move to gnss-sdr config
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
d_gnss_synchro_history_queue.push_back(std::deque<Gnss_Synchro>());
|
||||
}
|
||||
//todo: this is a gnuradio scheduler hack.
|
||||
// Migrate the queues to gnuradio set_history to see if the scheduler can handle
|
||||
// the multiple output flow
|
||||
d_max_noutputs = 100;
|
||||
this->set_min_noutput_items(100);
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
{
|
||||
if (d_dump_file.is_open() == false)
|
||||
// initialize internal vars
|
||||
d_dump = dump;
|
||||
d_nchannels = nchannels;
|
||||
d_dump_filename = dump_filename;
|
||||
history_deep = deep_history;
|
||||
T_rx_s = 0.0;
|
||||
T_rx_step_s = 1e-3; // todo: move to gnss-sdr config
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.exceptions (std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
|
||||
LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str();
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
LOG(WARNING) << "Exception opening observables dump file " << e.what();
|
||||
}
|
||||
d_gnss_synchro_history_queue.push_back(std::deque<Gnss_Synchro>());
|
||||
}
|
||||
// todo: this is a gnuradio scheduler hack.
|
||||
// Migrate the queues to gnuradio set_history to see if the scheduler can handle
|
||||
// the multiple output flow
|
||||
d_max_noutputs = 100;
|
||||
this->set_min_noutput_items(100);
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump == true)
|
||||
{
|
||||
if (d_dump_file.is_open() == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.exceptions (std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
|
||||
LOG(INFO) << "Observables dump enabled Log file: " << d_dump_filename.c_str();
|
||||
}
|
||||
catch (const std::ifstream::failure & e)
|
||||
{
|
||||
LOG(WARNING) << "Exception opening observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hybrid_observables_cc::~hybrid_observables_cc()
|
||||
{
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
|
||||
}
|
||||
}
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_pairCompare_gnss_synchro_sample_counter(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||
{
|
||||
return (a.second.Tracking_sample_counter) < (b.second.Tracking_sample_counter);
|
||||
return (a.second.Tracking_sample_counter) < (b.second.Tracking_sample_counter);
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_valueCompare_gnss_synchro_sample_counter(const Gnss_Synchro& a, unsigned long int b)
|
||||
{
|
||||
return (a.Tracking_sample_counter) < (b);
|
||||
return (a.Tracking_sample_counter) < (b);
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_valueCompare_gnss_synchro_receiver_time(const Gnss_Synchro& a, double b)
|
||||
{
|
||||
return (((double)a.Tracking_sample_counter+a.Code_phase_samples)/(double)a.fs) < (b);
|
||||
return (((double)a.Tracking_sample_counter+a.Code_phase_samples)/(double)a.fs) < (b);
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_pairCompare_gnss_synchro_d_TOW(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
|
||||
{
|
||||
return (a.second.TOW_at_current_symbol_s) < (b.second.TOW_at_current_symbol_s);
|
||||
return (a.second.TOW_at_current_symbol_s) < (b.second.TOW_at_current_symbol_s);
|
||||
}
|
||||
|
||||
|
||||
bool Hybrid_valueCompare_gnss_synchro_d_TOW(const Gnss_Synchro& a, double b)
|
||||
{
|
||||
return (a.TOW_at_current_symbol_s) < (b);
|
||||
return (a.TOW_at_current_symbol_s) < (b);
|
||||
}
|
||||
|
||||
|
||||
int hybrid_observables_cc::general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused)),
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; // Get the input pointer
|
||||
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; // Get the output pointer
|
||||
int n_outputs = 0;
|
||||
int n_consume[d_nchannels];
|
||||
double past_history_s = 100e-3;
|
||||
const Gnss_Synchro **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
|
||||
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
|
||||
int n_outputs = 0;
|
||||
int n_consume[d_nchannels];
|
||||
double past_history_s = 100e-3;
|
||||
|
||||
Gnss_Synchro current_gnss_synchro[d_nchannels];
|
||||
Gnss_Synchro current_gnss_synchro[d_nchannels];
|
||||
|
||||
/*
|
||||
* 1. Read the GNSS SYNCHRO objects from available channels.
|
||||
* Multi-rate GNURADIO Block. Read how many input items are avaliable in each channel
|
||||
* Record all synchronization data into queues
|
||||
*/
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
n_consume[i] = ninput_items[i];// full throttle
|
||||
for (int j = 0; j < n_consume[i]; j++)
|
||||
/*
|
||||
* 1. Read the GNSS SYNCHRO objects from available channels.
|
||||
* Multi-rate GNURADIO Block. Read how many input items are avaliable in each channel
|
||||
* Record all synchronization data into queues
|
||||
*/
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
d_gnss_synchro_history_queue[i].push_back(in[i][j]);
|
||||
}
|
||||
//std::cout<<"push["<<i<<"] items "<<n_consume[i]
|
||||
/// <<" latest T_rx: "<<(double)in[i][ninput_items[i]-1].Tracking_sample_counter/(double)in[i][ninput_items[i]-1].fs
|
||||
// <<" [s] q size: "
|
||||
// <<d_gnss_synchro_history_queue[i].size()
|
||||
// <<std::endl;
|
||||
}
|
||||
|
||||
bool channel_history_ok;
|
||||
do
|
||||
{
|
||||
channel_history_ok = true;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
if (d_gnss_synchro_history_queue[i].size() < history_deep)
|
||||
{
|
||||
channel_history_ok = false;
|
||||
}
|
||||
|
||||
}
|
||||
if (channel_history_ok == true)
|
||||
{
|
||||
std::map<int,Gnss_Synchro>::iterator gnss_synchro_map_iter;
|
||||
std::deque<Gnss_Synchro>::iterator gnss_synchro_deque_iter;
|
||||
|
||||
//1. If the RX time is not set, set the Rx time
|
||||
if (T_rx_s == 0)
|
||||
{
|
||||
//0. Read a gnss_synchro snapshot from the queue and store it in a map
|
||||
std::map<int,Gnss_Synchro> gnss_synchro_map;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
n_consume[i] = ninput_items[i];// full throttle
|
||||
for (int j = 0; j < n_consume[i]; j++)
|
||||
{
|
||||
gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].front().Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].front()));
|
||||
d_gnss_synchro_history_queue[i].push_back(in[i][j]);
|
||||
}
|
||||
gnss_synchro_map_iter = min_element(gnss_synchro_map.begin(),
|
||||
gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_sample_counter);
|
||||
T_rx_s = (double)gnss_synchro_map_iter->second.Tracking_sample_counter / (double)gnss_synchro_map_iter->second.fs;
|
||||
T_rx_s = floor(T_rx_s * 1000.0) / 1000.0; // truncate to ms
|
||||
T_rx_s += past_history_s; // increase T_rx to have a minimum past history to interpolate
|
||||
}
|
||||
//std::cout<<"push["<<i<<"] items "<<n_consume[i]
|
||||
/// <<" latest T_rx: "<<(double)in[i][ninput_items[i]-1].Tracking_sample_counter/(double)in[i][ninput_items[i]-1].fs
|
||||
// <<" [s] q size: "
|
||||
// <<d_gnss_synchro_history_queue[i].size()
|
||||
// <<std::endl;
|
||||
}
|
||||
|
||||
//2. Realign RX time in all valid channels
|
||||
std::map<int,Gnss_Synchro> realigned_gnss_synchro_map; //container for the aligned set of observables for the selected T_rx
|
||||
std::map<int,Gnss_Synchro> adjacent_gnss_synchro_map; //container for the previous observable values to interpolate
|
||||
//shift channels history to match the reference TOW
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
gnss_synchro_deque_iter = std::lower_bound(d_gnss_synchro_history_queue[i].begin(),
|
||||
d_gnss_synchro_history_queue[i].end(),
|
||||
T_rx_s,
|
||||
Hybrid_valueCompare_gnss_synchro_receiver_time);
|
||||
if (gnss_synchro_deque_iter != d_gnss_synchro_history_queue[i].end())
|
||||
bool channel_history_ok;
|
||||
do
|
||||
{
|
||||
channel_history_ok = true;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
if (gnss_synchro_deque_iter->Flag_valid_word == true)
|
||||
{
|
||||
double T_rx_channel = (double)gnss_synchro_deque_iter->Tracking_sample_counter / (double)gnss_synchro_deque_iter->fs;
|
||||
double delta_T_rx_s = T_rx_channel - T_rx_s;
|
||||
|
||||
//check that T_rx difference is less than a threshold (the correlation interval)
|
||||
if (delta_T_rx_s * 1000.0 < (double)gnss_synchro_deque_iter->correlation_length_ms)
|
||||
if (d_gnss_synchro_history_queue[i].size() < history_deep)
|
||||
{
|
||||
//record the word structure in a map for pseudorange computation
|
||||
//save the previous observable
|
||||
int distance = std::distance(d_gnss_synchro_history_queue[i].begin(), gnss_synchro_deque_iter);
|
||||
if (distance > 0)
|
||||
{
|
||||
if (d_gnss_synchro_history_queue[i].at(distance-1).Flag_valid_word)
|
||||
channel_history_ok = false;
|
||||
}
|
||||
|
||||
}
|
||||
if (channel_history_ok == true)
|
||||
{
|
||||
std::map<int,Gnss_Synchro>::iterator gnss_synchro_map_iter;
|
||||
std::deque<Gnss_Synchro>::iterator gnss_synchro_deque_iter;
|
||||
|
||||
// 1. If the RX time is not set, set the Rx time
|
||||
if (T_rx_s == 0)
|
||||
{
|
||||
// 0. Read a gnss_synchro snapshot from the queue and store it in a map
|
||||
std::map<int,Gnss_Synchro> gnss_synchro_map;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
double T_rx_channel_prev = (double)d_gnss_synchro_history_queue[i].at(distance - 1).Tracking_sample_counter / (double)gnss_synchro_deque_iter->fs;
|
||||
double delta_T_rx_s_prev = T_rx_channel_prev - T_rx_s;
|
||||
if (fabs(delta_T_rx_s_prev) < fabs(delta_T_rx_s))
|
||||
gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(d_gnss_synchro_history_queue[i].front().Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].front()));
|
||||
}
|
||||
gnss_synchro_map_iter = min_element(gnss_synchro_map.begin(),
|
||||
gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_sample_counter);
|
||||
T_rx_s = static_cast<double>(gnss_synchro_map_iter->second.Tracking_sample_counter) / static_cast<double>(gnss_synchro_map_iter->second.fs);
|
||||
T_rx_s = floor(T_rx_s * 1000.0) / 1000.0; // truncate to ms
|
||||
T_rx_s += past_history_s; // increase T_rx to have a minimum past history to interpolate
|
||||
}
|
||||
|
||||
// 2. Realign RX time in all valid channels
|
||||
std::map<int,Gnss_Synchro> realigned_gnss_synchro_map; // container for the aligned set of observables for the selected T_rx
|
||||
std::map<int,Gnss_Synchro> adjacent_gnss_synchro_map; // container for the previous observable values to interpolate
|
||||
// shift channels history to match the reference TOW
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
gnss_synchro_deque_iter = std::lower_bound(d_gnss_synchro_history_queue[i].begin(),
|
||||
d_gnss_synchro_history_queue[i].end(),
|
||||
T_rx_s,
|
||||
Hybrid_valueCompare_gnss_synchro_receiver_time);
|
||||
if (gnss_synchro_deque_iter != d_gnss_synchro_history_queue[i].end())
|
||||
{
|
||||
if (gnss_synchro_deque_iter->Flag_valid_word == true)
|
||||
{
|
||||
double T_rx_channel = static_cast<double>(gnss_synchro_deque_iter->Tracking_sample_counter) / static_cast<double>(gnss_synchro_deque_iter->fs);
|
||||
double delta_T_rx_s = T_rx_channel - T_rx_s;
|
||||
|
||||
// check that T_rx difference is less than a threshold (the correlation interval)
|
||||
if (delta_T_rx_s * 1000.0 < static_cast<double>(gnss_synchro_deque_iter->correlation_length_ms))
|
||||
{
|
||||
// record the word structure in a map for pseudorange computation
|
||||
// save the previous observable
|
||||
int distance = std::distance(d_gnss_synchro_history_queue[i].begin(), gnss_synchro_deque_iter);
|
||||
if (distance > 0)
|
||||
{
|
||||
if (d_gnss_synchro_history_queue[i].at(distance-1).Flag_valid_word)
|
||||
{
|
||||
double T_rx_channel_prev = static_cast<double>(d_gnss_synchro_history_queue[i].at(distance - 1).Tracking_sample_counter) / static_cast<double>(gnss_synchro_deque_iter->fs);
|
||||
double delta_T_rx_s_prev = T_rx_channel_prev - T_rx_s;
|
||||
if (fabs(delta_T_rx_s_prev) < fabs(delta_T_rx_s))
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(d_gnss_synchro_history_queue[i].at(distance - 1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance - 1)));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
}
|
||||
else
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(d_gnss_synchro_history_queue[i].at(distance - 1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance - 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout<<"ch["<<i<<"] delta_T_rx:"<<delta_T_rx_s*1000.0<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!realigned_gnss_synchro_map.empty())
|
||||
{
|
||||
/*
|
||||
* 2.1 Use CURRENT set of measurements and find the nearest satellite
|
||||
* common RX time algorithm
|
||||
*/
|
||||
// what is the most recent symbol TOW in the current set? -> this will be the reference symbol
|
||||
gnss_synchro_map_iter = max_element(realigned_gnss_synchro_map.begin(),
|
||||
realigned_gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_d_TOW);
|
||||
double ref_fs_hz = static_cast<double>(gnss_synchro_map_iter->second.fs);
|
||||
|
||||
// compute interpolated TOW value at T_rx_s
|
||||
int ref_channel_key = gnss_synchro_map_iter->second.Channel_ID;
|
||||
Gnss_Synchro adj_obs = adjacent_gnss_synchro_map.at(ref_channel_key);
|
||||
double ref_adj_T_rx_s = static_cast<double>(adj_obs.Tracking_sample_counter) / ref_fs_hz + adj_obs.Code_phase_samples / ref_fs_hz;
|
||||
|
||||
double d_TOW_reference = gnss_synchro_map_iter->second.TOW_at_current_symbol_s;
|
||||
double d_ref_T_rx_s = static_cast<double>(gnss_synchro_map_iter->second.Tracking_sample_counter) / ref_fs_hz + gnss_synchro_map_iter->second.Code_phase_samples / ref_fs_hz;
|
||||
|
||||
double selected_T_rx_s = T_rx_s;
|
||||
// two points linear interpolation using adjacent (adj) values: y=y1+(x-x1)*(y2-y1)/(x2-x1)
|
||||
double ref_TOW_at_T_rx_s = adj_obs.TOW_at_current_symbol_s +
|
||||
(selected_T_rx_s - ref_adj_T_rx_s) * (d_TOW_reference - adj_obs.TOW_at_current_symbol_s) / (d_ref_T_rx_s - ref_adj_T_rx_s);
|
||||
|
||||
// Now compute RX time differences due to the PRN alignment in the correlators
|
||||
double traveltime_ms;
|
||||
double pseudorange_m;
|
||||
double channel_T_rx_s;
|
||||
double channel_fs_hz;
|
||||
double channel_TOW_s;
|
||||
for(gnss_synchro_map_iter = realigned_gnss_synchro_map.begin(); gnss_synchro_map_iter != realigned_gnss_synchro_map.end(); gnss_synchro_map_iter++)
|
||||
{
|
||||
channel_fs_hz = static_cast<double>(gnss_synchro_map_iter->second.fs);
|
||||
channel_TOW_s = gnss_synchro_map_iter->second.TOW_at_current_symbol_s;
|
||||
channel_T_rx_s = static_cast<double>(gnss_synchro_map_iter->second.Tracking_sample_counter) / channel_fs_hz + gnss_synchro_map_iter->second.Code_phase_samples / channel_fs_hz;
|
||||
// compute interpolated observation values
|
||||
// two points linear interpolation using adjacent (adj) values: y=y1+(x-x1)*(y2-y1)/(x2-x1)
|
||||
// TOW at the selected receiver time T_rx_s
|
||||
int element_key = gnss_synchro_map_iter->second.Channel_ID;
|
||||
adj_obs = adjacent_gnss_synchro_map.at(element_key);
|
||||
|
||||
double adj_T_rx_s = static_cast<double>(adj_obs.Tracking_sample_counter) / channel_fs_hz + adj_obs.Code_phase_samples / channel_fs_hz;
|
||||
|
||||
double channel_TOW_at_T_rx_s = adj_obs.TOW_at_current_symbol_s + (selected_T_rx_s - adj_T_rx_s) * (channel_TOW_s - adj_obs.TOW_at_current_symbol_s) / (channel_T_rx_s - adj_T_rx_s);
|
||||
|
||||
// Doppler and Accumulated carrier phase
|
||||
double Carrier_phase_lin_rads = adj_obs.Carrier_phase_rads + (selected_T_rx_s - adj_T_rx_s) * (gnss_synchro_map_iter->second.Carrier_phase_rads - adj_obs.Carrier_phase_rads) / (channel_T_rx_s - adj_T_rx_s);
|
||||
double Carrier_Doppler_lin_hz = adj_obs.Carrier_Doppler_hz + (selected_T_rx_s - adj_T_rx_s) * (gnss_synchro_map_iter->second.Carrier_Doppler_hz - adj_obs.Carrier_Doppler_hz) / (channel_T_rx_s - adj_T_rx_s);
|
||||
|
||||
// compute the pseudorange (no rx time offset correction)
|
||||
traveltime_ms = (ref_TOW_at_T_rx_s - channel_TOW_at_T_rx_s) * 1000.0 + GPS_STARTOFFSET_ms;
|
||||
// convert to meters
|
||||
pseudorange_m = traveltime_ms * GPS_C_m_ms; // [m]
|
||||
// update the pseudorange object
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID] = gnss_synchro_map_iter->second;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Pseudorange_m = pseudorange_m;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Flag_valid_pseudorange = true;
|
||||
// Save the estimated RX time (no RX clock offset correction yet!)
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].RX_time = ref_TOW_at_T_rx_s + GPS_STARTOFFSET_ms / 1000.0;
|
||||
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_phase_rads = Carrier_phase_lin_rads;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_Doppler_hz = Carrier_Doppler_lin_hz;
|
||||
}
|
||||
|
||||
if(d_dump == true)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].at(distance-1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance-1)));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
double tmp_double;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
tmp_double = current_gnss_synchro[i].RX_time;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Pseudorange_m;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].PRN;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange;
|
||||
d_dump_file.write(reinterpret_cast<char*>(&tmp_double), sizeof(double));
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
adjacent_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(
|
||||
d_gnss_synchro_history_queue[i].at(distance-1).Channel_ID,
|
||||
d_gnss_synchro_history_queue[i].at(distance-1)));
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
realigned_gnss_synchro_map.insert(std::pair<int, Gnss_Synchro>(gnss_synchro_deque_iter->Channel_ID, *gnss_synchro_deque_iter));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
out[i][n_outputs] = current_gnss_synchro[i];
|
||||
}
|
||||
|
||||
n_outputs++;
|
||||
}
|
||||
else
|
||||
|
||||
// Move RX time
|
||||
T_rx_s = T_rx_s + T_rx_step_s;
|
||||
// pop old elements from queue
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
//std::cout<<"ch["<<i<<"] delta_T_rx:"<<delta_T_rx_s*1000.0<<std::endl;
|
||||
while (static_cast<double>(d_gnss_synchro_history_queue[i].front().Tracking_sample_counter) / static_cast<double>(d_gnss_synchro_history_queue[i].front().fs) < (T_rx_s - past_history_s))
|
||||
{
|
||||
d_gnss_synchro_history_queue[i].pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(channel_history_ok == true && d_max_noutputs > n_outputs);
|
||||
|
||||
if(!realigned_gnss_synchro_map.empty())
|
||||
{
|
||||
/*
|
||||
* 2.1 Use CURRENT set of measurements and find the nearest satellite
|
||||
* common RX time algorithm
|
||||
*/
|
||||
// what is the most recent symbol TOW in the current set? -> this will be the reference symbol
|
||||
gnss_synchro_map_iter = max_element(realigned_gnss_synchro_map.begin(),
|
||||
realigned_gnss_synchro_map.end(),
|
||||
Hybrid_pairCompare_gnss_synchro_d_TOW);
|
||||
double ref_fs_hz = (double)gnss_synchro_map_iter->second.fs;
|
||||
|
||||
// compute interpolated TOW value at T_rx_s
|
||||
int ref_channel_key = gnss_synchro_map_iter->second.Channel_ID;
|
||||
Gnss_Synchro adj_obs = adjacent_gnss_synchro_map.at(ref_channel_key);
|
||||
double ref_adj_T_rx_s = (double)adj_obs.Tracking_sample_counter / ref_fs_hz + adj_obs.Code_phase_samples / ref_fs_hz;
|
||||
|
||||
double d_TOW_reference = gnss_synchro_map_iter->second.TOW_at_current_symbol_s;
|
||||
double d_ref_T_rx_s = (double)gnss_synchro_map_iter->second.Tracking_sample_counter / ref_fs_hz + gnss_synchro_map_iter->second.Code_phase_samples / ref_fs_hz;
|
||||
|
||||
double selected_T_rx_s = T_rx_s;
|
||||
// two points linear interpolation using adjacent (adj) values: y=y1+(x-x1)*(y2-y1)/(x2-x1)
|
||||
double ref_TOW_at_T_rx_s = adj_obs.TOW_at_current_symbol_s + (selected_T_rx_s - ref_adj_T_rx_s)
|
||||
* (d_TOW_reference - adj_obs.TOW_at_current_symbol_s) / (d_ref_T_rx_s - ref_adj_T_rx_s);
|
||||
|
||||
// Now compute RX time differences due to the PRN alignment in the correlators
|
||||
double traveltime_ms;
|
||||
double pseudorange_m;
|
||||
double channel_T_rx_s;
|
||||
double channel_fs_hz;
|
||||
double channel_TOW_s;
|
||||
for(gnss_synchro_map_iter = realigned_gnss_synchro_map.begin(); gnss_synchro_map_iter != realigned_gnss_synchro_map.end(); gnss_synchro_map_iter++)
|
||||
{
|
||||
channel_fs_hz = (double)gnss_synchro_map_iter->second.fs;
|
||||
channel_TOW_s = gnss_synchro_map_iter->second.TOW_at_current_symbol_s;
|
||||
channel_T_rx_s = (double)gnss_synchro_map_iter->second.Tracking_sample_counter / channel_fs_hz + gnss_synchro_map_iter->second.Code_phase_samples / channel_fs_hz;
|
||||
// compute interpolated observation values
|
||||
// two points linear interpolation using adjacent (adj) values: y=y1+(x-x1)*(y2-y1)/(x2-x1)
|
||||
// TOW at the selected receiver time T_rx_s
|
||||
int element_key = gnss_synchro_map_iter->second.Channel_ID;
|
||||
adj_obs = adjacent_gnss_synchro_map.at(element_key);
|
||||
|
||||
double adj_T_rx_s = (double)adj_obs.Tracking_sample_counter / channel_fs_hz + adj_obs.Code_phase_samples / channel_fs_hz;
|
||||
|
||||
double channel_TOW_at_T_rx_s = adj_obs.TOW_at_current_symbol_s + (selected_T_rx_s - adj_T_rx_s) * (channel_TOW_s - adj_obs.TOW_at_current_symbol_s) / (channel_T_rx_s - adj_T_rx_s);
|
||||
|
||||
//Doppler and Accumulated carrier phase
|
||||
double Carrier_phase_lin_rads = adj_obs.Carrier_phase_rads + (selected_T_rx_s - adj_T_rx_s) * (gnss_synchro_map_iter->second.Carrier_phase_rads - adj_obs.Carrier_phase_rads) / (channel_T_rx_s - adj_T_rx_s);
|
||||
double Carrier_Doppler_lin_hz = adj_obs.Carrier_Doppler_hz + (selected_T_rx_s - adj_T_rx_s) * (gnss_synchro_map_iter->second.Carrier_Doppler_hz - adj_obs.Carrier_Doppler_hz) / (channel_T_rx_s - adj_T_rx_s);
|
||||
|
||||
//compute the pseudorange (no rx time offset correction)
|
||||
traveltime_ms = (ref_TOW_at_T_rx_s - channel_TOW_at_T_rx_s) * 1000.0 + GPS_STARTOFFSET_ms;
|
||||
//convert to meters
|
||||
pseudorange_m = traveltime_ms * GPS_C_m_ms; // [m]
|
||||
// update the pseudorange object
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID] = gnss_synchro_map_iter->second;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Pseudorange_m = pseudorange_m;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Flag_valid_pseudorange = true;
|
||||
// Save the estimated RX time (no RX clock offset correction yet!)
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].RX_time = ref_TOW_at_T_rx_s + GPS_STARTOFFSET_ms / 1000.0;
|
||||
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_phase_rads = Carrier_phase_lin_rads;
|
||||
current_gnss_synchro[gnss_synchro_map_iter->second.Channel_ID].Carrier_Doppler_hz = Carrier_Doppler_lin_hz;
|
||||
}
|
||||
|
||||
if(d_dump == true)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
tmp_double = current_gnss_synchro[i].RX_time;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Pseudorange_m;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].PRN;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
}
|
||||
}
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
out[i][n_outputs] = current_gnss_synchro[i];
|
||||
}
|
||||
|
||||
n_outputs++;
|
||||
}
|
||||
|
||||
//Move RX time
|
||||
T_rx_s = T_rx_s + T_rx_step_s;
|
||||
//pop old elements from queue
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
while (d_gnss_synchro_history_queue[i].front().Tracking_sample_counter / (double)d_gnss_synchro_history_queue[i].front().fs < (T_rx_s - past_history_s))
|
||||
{
|
||||
d_gnss_synchro_history_queue[i].pop_front();
|
||||
}
|
||||
}
|
||||
// Multi-rate consume!
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
consume(i, n_consume[i]); // which input, how many items
|
||||
}
|
||||
}while(channel_history_ok == true && d_max_noutputs>n_outputs);
|
||||
|
||||
//Multi-rate consume!
|
||||
for (unsigned int i = 0; i < d_nchannels; i++)
|
||||
{
|
||||
consume(i, n_consume[i]); //which input, how many items
|
||||
}
|
||||
|
||||
return n_outputs;
|
||||
return n_outputs;
|
||||
}
|
||||
|
||||
@@ -52,26 +52,26 @@ hybrid_make_observables_cc(unsigned int n_channels, bool dump, std::string dump_
|
||||
class hybrid_observables_cc : public gr::block
|
||||
{
|
||||
public:
|
||||
~hybrid_observables_cc ();
|
||||
int general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
~hybrid_observables_cc ();
|
||||
int general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
|
||||
private:
|
||||
friend hybrid_observables_cc_sptr
|
||||
hybrid_make_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history);
|
||||
hybrid_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history);
|
||||
friend hybrid_observables_cc_sptr
|
||||
hybrid_make_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history);
|
||||
hybrid_observables_cc(unsigned int nchannels, bool dump, std::string dump_filename, unsigned int deep_history);
|
||||
|
||||
//Tracking observable history
|
||||
std::vector<std::deque<Gnss_Synchro>> d_gnss_synchro_history_queue;
|
||||
//Tracking observable history
|
||||
std::vector<std::deque<Gnss_Synchro>> d_gnss_synchro_history_queue;
|
||||
|
||||
double T_rx_s;
|
||||
double T_rx_step_s;
|
||||
int d_max_noutputs;
|
||||
bool d_dump;
|
||||
unsigned int d_nchannels;
|
||||
unsigned int history_deep;
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
double T_rx_s;
|
||||
double T_rx_step_s;
|
||||
int d_max_noutputs;
|
||||
bool d_dump;
|
||||
unsigned int d_nchannels;
|
||||
unsigned int history_deep;
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,36 @@ list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS)
|
||||
|
||||
# Optional drivers
|
||||
|
||||
if(ENABLE_PLUTOSDR)
|
||||
##############################################
|
||||
# ADALM-PLUTO (Analog Devices Inc.)
|
||||
##############################################
|
||||
find_package(iio REQUIRED)
|
||||
if(NOT IIO_FOUND)
|
||||
message("gnuradio-iio not found, installation is required")
|
||||
message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled")
|
||||
else(NOT IIO_FOUND)
|
||||
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
|
||||
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
|
||||
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc)
|
||||
endif(NOT IIO_FOUND)
|
||||
endif(ENABLE_PLUTOSDR)
|
||||
|
||||
if(ENABLE_FMCOMMS2)
|
||||
###############################################
|
||||
# FMCOMMS2 based SDR Hardware
|
||||
###############################################
|
||||
find_package(iio REQUIRED)
|
||||
if(NOT IIO_FOUND)
|
||||
message("gnuradio-iio not found, installation is required")
|
||||
message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled")
|
||||
else(NOT IIO_FOUND)
|
||||
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES})
|
||||
set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS})
|
||||
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc plutosdr_signal_source.cc)
|
||||
endif(NOT IIO_FOUND)
|
||||
endif(ENABLE_FMCOMMS2)
|
||||
|
||||
if(ENABLE_GN3S)
|
||||
##############################################
|
||||
# GN3S (USB dongle)
|
||||
|
||||
179
src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc
Normal file
179
src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc
Normal file
@@ -0,0 +1,179 @@
|
||||
/*!
|
||||
* \filei fmcomms2_signal_source.cc
|
||||
* \brief signal source for sdr hardware from analog devices based on
|
||||
* fmcomms2 evaluation board.
|
||||
* \author Rodrigo Muñoz, 2017, rmunozl(at)inacap.cl
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "fmcomms2_signal_source.h"
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include "configuration_interface.h"
|
||||
#include "gnss_sdr_valve.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/signal_source.dat";
|
||||
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||
sample_rate_ = configuration->property(role + ".sampling_frequency", 2600000);
|
||||
bandwidth_ = configuration->property(role + ".bandwidth", 2000000);
|
||||
rx1_en_ = configuration->property(role + ".rx1_enable", true);
|
||||
rx2_en_ = configuration->property(role + ".rx2_enable", false);
|
||||
buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000);
|
||||
decimation_ = configuration->property(role + ".decimation", 1);
|
||||
quadrature_ = configuration->property(role + ".quadrature", true);
|
||||
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
||||
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
||||
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
|
||||
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
|
||||
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
|
||||
rf_gain_rx2_ = configuration->property(role + ".gain_rx2", 64.0);
|
||||
rf_port_select_ = configuration->property(role + ".rf_port_select", std::string("A_BALANCED"));
|
||||
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
||||
filter_auto_ = configuration->property(role + ".filter_auto", true);
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
samples_ = configuration->property(role + ".samples", 0);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
||||
|
||||
item_size_ = sizeof(gr_complex);
|
||||
|
||||
std::cout << "device address: " << uri_ << std::endl;
|
||||
std::cout << "LO frequency : " << freq_ << "Hz" << std::endl;
|
||||
std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl;
|
||||
|
||||
if(item_type_.compare("gr_complex")==0)
|
||||
{
|
||||
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
|
||||
uri_.c_str(), freq_, sample_rate_,
|
||||
decimation_, bandwidth_,
|
||||
rx1_en_, rx2_en_,
|
||||
buffer_size_, quadrature_, rf_dc_,
|
||||
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
|
||||
gain_mode_rx2_.c_str(), rf_gain_rx2_,
|
||||
rf_port_select_.c_str(), filter_file_.c_str(),
|
||||
filter_auto_);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(FATAL) << "Exception: item type " << item_type_ << " not suported!";
|
||||
}
|
||||
|
||||
if (samples_ != 0)
|
||||
{
|
||||
DLOG(INFO) << "Send STOP signal after " << samples_ << " samples";
|
||||
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
|
||||
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
|
||||
}
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Fmcomms2SignalSource::~Fmcomms2SignalSource()
|
||||
{}
|
||||
|
||||
|
||||
void Fmcomms2SignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
top_block->connect(fmcomms2_source_f32c_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected fmcomms2 source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
|
||||
top_block->connect(fmcomms2_source_f32c_ , 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected fmcomms2 source to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Fmcomms2SignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
top_block->disconnect(fmcomms2_source_f32c_, 0, valve_, 0);
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(fmcomms2_source_f32c_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr Fmcomms2SignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Trying to get signal source left block.";
|
||||
return gr::basic_block_sptr();
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr Fmcomms2SignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
return valve_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (fmcomms2_source_f32c_);
|
||||
}
|
||||
}
|
||||
116
src/algorithms/signal_source/adapters/fmcomms2_signal_source.h
Normal file
116
src/algorithms/signal_source/adapters/fmcomms2_signal_source.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* \file fmcomms2_signal_source.h
|
||||
* \brief Interface to use SDR hardware based in FMCOMMS2 driver from analog
|
||||
* devices, for example FMCOMMS4 and ADALM-PLUTO (PlutoSdr)
|
||||
* \author Rodrigo Muñoz, 2017. rmunozl(at)inacap.cl
|
||||
*
|
||||
* This class represent a fmcomms2 signal source. It use the gr_iio block
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H_
|
||||
#define GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H_
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <iio/fmcomms2_source.h>
|
||||
#include "gnss_block_interface.h"
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
class Fmcomms2SignalSource: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
Fmcomms2SignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~Fmcomms2SignalSource();
|
||||
|
||||
inline std::string role() override
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns "fmcomms2_Signal_Source"
|
||||
*/
|
||||
inline std::string implementation() override
|
||||
{
|
||||
return "Fmcomms2_Signal_Source";
|
||||
}
|
||||
|
||||
inline size_t item_size() override
|
||||
{
|
||||
return item_size_;
|
||||
}
|
||||
|
||||
void connect(gr::top_block_sptr top_block) override;
|
||||
void disconnect(gr::top_block_sptr top_block) override;
|
||||
gr::basic_block_sptr get_left_block() override;
|
||||
gr::basic_block_sptr get_right_block() override;
|
||||
|
||||
private:
|
||||
std::string role_;
|
||||
|
||||
// Front-end settings
|
||||
std::string uri_;//device direction
|
||||
unsigned long freq_; //frequency of local oscilator
|
||||
unsigned long sample_rate_;
|
||||
unsigned long bandwidth_;
|
||||
unsigned long buffer_size_; //reception buffer
|
||||
unsigned int decimation_;
|
||||
bool rx1_en_;
|
||||
bool rx2_en_;
|
||||
bool quadrature_;
|
||||
bool rf_dc_;
|
||||
bool bb_dc_;
|
||||
std::string gain_mode_rx1_;
|
||||
std::string gain_mode_rx2_;
|
||||
double rf_gain_rx1_;
|
||||
double rf_gain_rx2_;
|
||||
std::string rf_port_select_;
|
||||
std::string filter_file_;
|
||||
bool filter_auto_;
|
||||
|
||||
unsigned int in_stream_;
|
||||
unsigned int out_stream_;
|
||||
|
||||
std::string item_type_;
|
||||
size_t item_size_;
|
||||
long samples_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
|
||||
gr::iio::fmcomms2_source_f32c::sptr fmcomms2_source_f32c_;
|
||||
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
};
|
||||
|
||||
#endif /*GNSS_SDR_FMCOMMS2_SIGNAL_SOURCE_H_*/
|
||||
169
src/algorithms/signal_source/adapters/plutosdr_signal_source.cc
Normal file
169
src/algorithms/signal_source/adapters/plutosdr_signal_source.cc
Normal file
@@ -0,0 +1,169 @@
|
||||
/*!
|
||||
* \file plutosdr_signal_source.cc
|
||||
* \brief Signal source for PlutoSDR
|
||||
* \author Rodrigo Muñoz, 2017, rmunozl(at)inacap.cl
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 "plutosdr_signal_source.h"
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
#include <glog/logging.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include "configuration_interface.h"
|
||||
#include "gnss_sdr_valve.h"
|
||||
#include "GPS_L1_CA.h"
|
||||
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
|
||||
PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream, unsigned int out_stream,
|
||||
boost::shared_ptr<gr::msg_queue> queue) :
|
||||
role_(role), in_stream_(in_stream), out_stream_(out_stream),
|
||||
queue_(queue)
|
||||
{
|
||||
std::string default_item_type = "gr_complex";
|
||||
std::string default_dump_file = "./data/signal_source.dat";
|
||||
uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1"));
|
||||
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
|
||||
sample_rate_ configuration->property(role + ".sampling_frequency", 3000000);
|
||||
bandwidth_ = configuration->property(role + ".bandwidth", 2000000);
|
||||
buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000);
|
||||
decimation_ = configuration->property(role + ".decimation", 1);
|
||||
quadrature_ = configuration->property(role + ".quadrature", true);
|
||||
rf_dc_ = configuration->property(role + ".rf_dc", true);
|
||||
bb_dc_ = configuration->property(role + ".bb_dc", true);
|
||||
gain_mode_ = configuration->property(role + ".gain_mode", std::string("manual"));
|
||||
rf_gain_ = configuration->property(role + ".gain", 50.0);
|
||||
filter_file_ = configuration->property(role + ".filter_file", std::string(""));
|
||||
filter_auto_ = configuration->property(role + ".filter_auto", true);
|
||||
|
||||
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
||||
samples_ = configuration->property(role + ".samples", 0);
|
||||
dump_ = configuration->property(role + ".dump", false);
|
||||
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
||||
|
||||
if(item_type_.compare("gr_complex") != 0)
|
||||
{
|
||||
std::cout << "bad item_type!!" << std::endl;
|
||||
LOG(FATAL) << "Exception: item type must be gr_complex!";
|
||||
}
|
||||
|
||||
item_size_ = sizeof(gr_complex);
|
||||
|
||||
std::cout << "device address: " << uri_ << std::endl;
|
||||
std::cout << "frequency : " << freq_ << "Hz" << std::endl;
|
||||
std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl;
|
||||
std::cout << "gain mode: " << gain_mode_ << std::endl;
|
||||
std::cout << "item type: " << item_type_ << std::endl;
|
||||
|
||||
plutosdr_source_ = gr::iio::pluto_source::make(uri_, freq_, sample_rate_,
|
||||
decimation_, bandwidth_, buffer_size_, quadrature_, rf_dc_, bb_dc_,
|
||||
gain_mode_.c_str(), rf_gain_,filter_file_.c_str(), filter_auto_);
|
||||
|
||||
if (samples_ != 0)
|
||||
{
|
||||
DLOG(INFO) << "Send STOP signal after " << samples_ << " samples";
|
||||
valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_);
|
||||
DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
|
||||
}
|
||||
|
||||
if (dump_)
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
|
||||
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlutosdrSignalSource::~PlutosdrSignalSource()
|
||||
{}
|
||||
|
||||
|
||||
void PlutosdrSignalSource::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
top_block->connect(plutosdr_source_, 0, valve_, 0);
|
||||
DLOG(INFO) << "connected plutosdr source to valve";
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(valve_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected valve to file sink";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->connect(plutosdr_source_, 0, file_sink_, 0);
|
||||
DLOG(INFO) << "connected plutosdr source to file sink";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PlutosdrSignalSource::disconnect(gr::top_block_sptr top_block)
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
top_block->disconnect(plutosdr_source_, 0, valve_, 0);
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(valve_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dump_)
|
||||
{
|
||||
top_block->disconnect(plutosdr_source_, 0, file_sink_, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr PlutosdrSignalSource::get_left_block()
|
||||
{
|
||||
LOG(WARNING) << "Trying to get signal source left block.";
|
||||
return gr::basic_block_sptr();
|
||||
}
|
||||
|
||||
|
||||
gr::basic_block_sptr PlutosdrSignalSource::get_right_block()
|
||||
{
|
||||
if (samples_ != 0)
|
||||
{
|
||||
return valve_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return plutosdr_source_;
|
||||
}
|
||||
}
|
||||
111
src/algorithms/signal_source/adapters/plutosdr_signal_source.h
Normal file
111
src/algorithms/signal_source/adapters/plutosdr_signal_source.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*!
|
||||
* \file plutosdr_signal_source.h
|
||||
* \brief Signal source for PlutoSDR
|
||||
* \author Rodrigo Muñoz, 2017, rmunozl(at)inacap.cl
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2017 (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 GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H_
|
||||
#define GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H_
|
||||
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include <gnuradio/blocks/file_sink.h>
|
||||
#include <iio/pluto_source.h>
|
||||
#include "gnss_block_interface.h"
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
/*!
|
||||
*/
|
||||
class PlutosdrSignalSource: public GNSSBlockInterface
|
||||
{
|
||||
public:
|
||||
PlutosdrSignalSource(ConfigurationInterface* configuration,
|
||||
std::string role, unsigned int in_stream,
|
||||
unsigned int out_stream, boost::shared_ptr<gr::msg_queue> queue);
|
||||
|
||||
virtual ~PlutosdrSignalSource();
|
||||
|
||||
std::string role() override
|
||||
{
|
||||
return role_;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns "Plutosdr_Signal_Source"
|
||||
*/
|
||||
std::string implementation() override
|
||||
{
|
||||
return "Plutosdr_Signal_Source";
|
||||
}
|
||||
size_t item_size() override
|
||||
{
|
||||
return item_size_;
|
||||
}
|
||||
|
||||
void connect(gr::top_block_sptr top_block) override;
|
||||
void disconnect(gr::top_block_sptr top_block) override;
|
||||
gr::basic_block_sptr get_left_block() override;
|
||||
gr::basic_block_sptr get_right_block() override;
|
||||
|
||||
private:
|
||||
std::string role_;
|
||||
|
||||
// Front-end settings
|
||||
std::string uri_; // device direction
|
||||
unsigned long freq_; // frequency of local oscilator
|
||||
unsigned long sample_rate_;
|
||||
unsigned long bandwidth_;
|
||||
unsigned long buffer_size_; // reception buffer
|
||||
unsigned int decimation_;
|
||||
bool quadrature_;
|
||||
bool rf_dc_;
|
||||
bool bb_dc_;
|
||||
std::string gain_mode_;
|
||||
double rf_gain_;
|
||||
std::string filter_file_;
|
||||
bool filter_auto_;
|
||||
|
||||
unsigned int in_stream_;
|
||||
unsigned int out_stream_;
|
||||
|
||||
std::string item_type_;
|
||||
size_t item_size_;
|
||||
long samples_;
|
||||
bool dump_;
|
||||
std::string dump_filename_;
|
||||
|
||||
gr::iio::pluto_source::sptr plutosdr_source_;
|
||||
|
||||
boost::shared_ptr<gr::block> valve_;
|
||||
gr::blocks::file_sink::sptr file_sink_;
|
||||
boost::shared_ptr<gr::msg_queue> queue_;
|
||||
};
|
||||
|
||||
#endif /*GNSS_SDR_PLUTOSDR_SIGNAL_SOURCE_H_*/
|
||||
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
#define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
#define GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
|
||||
#include "rtl_tcp_dongle_info.h"
|
||||
#include <boost/asio.hpp>
|
||||
@@ -67,8 +67,8 @@ public:
|
||||
~rtl_tcp_signal_source_c();
|
||||
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
void set_frequency (int frequency);
|
||||
void set_sample_rate (int sample_rate);
|
||||
@@ -110,13 +110,15 @@ private:
|
||||
void handle_read (const boost::system::error_code &ec,
|
||||
size_t bytes_transferred);
|
||||
|
||||
inline bool not_full ( ) const {
|
||||
inline bool not_full ( ) const
|
||||
{
|
||||
return unread_ < buffer_.capacity( );
|
||||
}
|
||||
|
||||
inline bool not_empty ( ) const {
|
||||
inline bool not_empty ( ) const
|
||||
{
|
||||
return unread_ > 0 || io_service_.stopped ();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
#endif // GNSS_SDR_RTL_TCP_SIGNAL_SOURCE_C_H
|
||||
|
||||
@@ -29,25 +29,21 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "rtl_tcp_commands.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
|
||||
boost::system::error_code
|
||||
rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param, tcp::socket &socket) {
|
||||
boost::system::error_code rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param, boost::asio::ip::tcp::socket &socket)
|
||||
{
|
||||
// Data payload
|
||||
unsigned char data[sizeof (unsigned char) + sizeof (unsigned)];
|
||||
unsigned char data[sizeof(unsigned char) + sizeof(unsigned)];
|
||||
|
||||
data[0] = static_cast<unsigned char> (id);
|
||||
data[0] = static_cast<unsigned char>(id);
|
||||
|
||||
|
||||
unsigned nparam =
|
||||
boost::asio::detail::socket_ops::host_to_network_long (param);
|
||||
::memcpy (&data[1], &nparam, sizeof (nparam));
|
||||
unsigned nparam = boost::asio::detail::socket_ops::host_to_network_long(param);
|
||||
std::memcpy(&data[1], &nparam, sizeof(nparam));
|
||||
|
||||
boost::system::error_code ec;
|
||||
socket.send (boost::asio::buffer (data), 0, ec);
|
||||
socket.send(boost::asio::buffer(data), 0, ec);
|
||||
return ec;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ enum RTL_TCP_COMMAND {
|
||||
/*!
|
||||
* \brief Send a command to rtl_tcp over the given socket.
|
||||
*/
|
||||
boost::system::error_code
|
||||
rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param,
|
||||
boost::asio::ip::tcp::socket &socket);
|
||||
boost::system::error_code rtl_tcp_command (RTL_TCP_COMMAND id, unsigned param,
|
||||
boost::asio::ip::tcp::socket &socket);
|
||||
|
||||
#endif // GNSS_SDR_RTL_TCP_COMMANDS_H
|
||||
|
||||
@@ -30,45 +30,47 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "rtl_tcp_dongle_info.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
rtl_tcp_dongle_info::rtl_tcp_dongle_info ()
|
||||
: tuner_type_ (0), tuner_gain_count_ (0)
|
||||
rtl_tcp_dongle_info::rtl_tcp_dongle_info() : tuner_type_(0), tuner_gain_count_(0)
|
||||
{
|
||||
::memset (magic_, 0, sizeof (magic_));
|
||||
std::memset(magic_, 0, sizeof(magic_));
|
||||
}
|
||||
|
||||
boost::system::error_code rtl_tcp_dongle_info::read (tcp::socket &socket) {
|
||||
|
||||
boost::system::error_code rtl_tcp_dongle_info::read(boost::asio::ip::tcp::socket &socket)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
|
||||
unsigned char data[sizeof (char) * 4 + sizeof (uint32_t) * 2];
|
||||
socket.receive (boost::asio::buffer (data), 0, ec);
|
||||
if (!ec) {
|
||||
::memcpy (magic_, data, 4);
|
||||
unsigned char data[sizeof(char) * 4 + sizeof(uint32_t) * 2];
|
||||
socket.receive(boost::asio::buffer(data), 0, ec);
|
||||
if (!ec)
|
||||
{
|
||||
std::memcpy(magic_, data, 4);
|
||||
|
||||
uint32_t type;
|
||||
::memcpy (&type, &data[4], 4);
|
||||
uint32_t type;
|
||||
std::memcpy(&type, &data[4], 4);
|
||||
|
||||
tuner_type_ =
|
||||
boost::asio::detail::socket_ops::network_to_host_long (type);
|
||||
tuner_type_ = boost::asio::detail::socket_ops::network_to_host_long(type);
|
||||
|
||||
uint32_t count;
|
||||
std ::memcpy(&count, &data[8], 4);
|
||||
|
||||
uint32_t count;
|
||||
::memcpy (&count, &data[8], 4);
|
||||
|
||||
tuner_gain_count_ =
|
||||
boost::asio::detail::socket_ops::network_to_host_long (count);
|
||||
}
|
||||
tuner_gain_count_ = boost::asio::detail::socket_ops::network_to_host_long(count);
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
||||
const char *rtl_tcp_dongle_info::get_type_name () const {
|
||||
switch (get_tuner_type()) {
|
||||
const char *rtl_tcp_dongle_info::get_type_name() const
|
||||
{
|
||||
switch(get_tuner_type())
|
||||
{
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
case TUNER_E4000:
|
||||
@@ -86,29 +88,32 @@ const char *rtl_tcp_dongle_info::get_type_name () const {
|
||||
}
|
||||
}
|
||||
|
||||
double rtl_tcp_dongle_info::clip_gain (int gain) const {
|
||||
|
||||
double rtl_tcp_dongle_info::clip_gain(int gain) const
|
||||
{
|
||||
// the following gain values have been copied from librtlsdr
|
||||
// all gain values are expressed in tenths of a dB
|
||||
|
||||
std::vector<double> gains;
|
||||
switch (get_tuner_type()) {
|
||||
switch (get_tuner_type())
|
||||
{
|
||||
case TUNER_E4000:
|
||||
gains = { -10, 15, 40, 65, 90, 115, 140, 165, 190, 215,
|
||||
240, 290, 340, 420 };
|
||||
240, 290, 340, 420 };
|
||||
break;
|
||||
case TUNER_FC0012:
|
||||
gains = { -99, -40, 71, 179, 192 };
|
||||
break;
|
||||
case TUNER_FC0013:
|
||||
gains = { -99, -73, -65, -63, -60, -58, -54, 58, 61,
|
||||
63, 65, 67, 68, 70, 71, 179, 181, 182,
|
||||
184, 186, 188, 191, 197 };
|
||||
63, 65, 67, 68, 70, 71, 179, 181, 182,
|
||||
184, 186, 188, 191, 197 };
|
||||
break;
|
||||
case TUNER_R820T:
|
||||
gains = { 0, 9, 14, 27, 37, 77, 87, 125, 144, 157,
|
||||
166, 197, 207, 229, 254, 280, 297, 328,
|
||||
338, 364, 372, 386, 402, 421, 434, 439,
|
||||
445, 480, 496 };
|
||||
166, 197, 207, 229, 254, 280, 297, 328,
|
||||
338, 364, 372, 386, 402, 421, 434, 439,
|
||||
445, 480, 496 };
|
||||
break;
|
||||
default:
|
||||
// no gains
|
||||
@@ -116,29 +121,37 @@ double rtl_tcp_dongle_info::clip_gain (int gain) const {
|
||||
}
|
||||
|
||||
// clip
|
||||
if (gains.size() == 0) {
|
||||
// no defined gains to clip to
|
||||
return gain;
|
||||
}
|
||||
else {
|
||||
double last_stop = gains.front ();
|
||||
BOOST_FOREACH (double g, gains) {
|
||||
g /= 10.0;
|
||||
|
||||
if (gain < g) {
|
||||
if (std::abs (gain - g) < std::abs (gain - last_stop)) {
|
||||
return g;
|
||||
}
|
||||
else {
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
last_stop = g;
|
||||
if (gains.size() == 0)
|
||||
{
|
||||
// no defined gains to clip to
|
||||
return gain;
|
||||
}
|
||||
else
|
||||
{
|
||||
double last_stop = gains.front();
|
||||
BOOST_FOREACH (double g, gains)
|
||||
{
|
||||
g /= 10.0;
|
||||
|
||||
if (gain < g)
|
||||
{
|
||||
if (std::abs(gain - g) < std::abs(gain - last_stop))
|
||||
{
|
||||
return g;
|
||||
}
|
||||
else
|
||||
{
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
last_stop = g;
|
||||
}
|
||||
return last_stop;
|
||||
}
|
||||
return last_stop;
|
||||
}
|
||||
}
|
||||
|
||||
bool rtl_tcp_dongle_info::is_valid () const {
|
||||
return ::memcmp (magic_, "RTL0", 4) == 0;
|
||||
|
||||
bool rtl_tcp_dongle_info::is_valid() const
|
||||
{
|
||||
return std::memcmp(magic_, "RTL0", 4) == 0;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef GNSS_SDR_RTL_TCP_DONGLE_INFO_H
|
||||
#define GNSS_SDR_RTL_TCP_DONGLE_INFO_H
|
||||
|
||||
@@ -38,9 +39,16 @@
|
||||
* \brief This class represents the dongle information
|
||||
* which is sent by rtl_tcp.
|
||||
*/
|
||||
class rtl_tcp_dongle_info {
|
||||
public:
|
||||
enum {
|
||||
class rtl_tcp_dongle_info
|
||||
{
|
||||
private:
|
||||
char magic_[4];
|
||||
uint32_t tuner_type_;
|
||||
uint32_t tuner_gain_count_;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
TUNER_UNKNOWN = 0,
|
||||
TUNER_E4000,
|
||||
TUNER_FC0012,
|
||||
@@ -50,28 +58,23 @@ class rtl_tcp_dongle_info {
|
||||
TUNER_R828D
|
||||
};
|
||||
|
||||
private:
|
||||
char magic_[4];
|
||||
uint32_t tuner_type_;
|
||||
uint32_t tuner_gain_count_;
|
||||
rtl_tcp_dongle_info();
|
||||
|
||||
public:
|
||||
rtl_tcp_dongle_info ();
|
||||
boost::system::error_code read(boost::asio::ip::tcp::socket &socket);
|
||||
|
||||
boost::system::error_code read (
|
||||
boost::asio::ip::tcp::socket &socket);
|
||||
bool is_valid() const;
|
||||
|
||||
bool is_valid () const;
|
||||
const char *get_type_name() const;
|
||||
|
||||
const char *get_type_name () const;
|
||||
double clip_gain(int gain) const;
|
||||
|
||||
double clip_gain (int gain) const;
|
||||
|
||||
inline uint32_t get_tuner_type () const {
|
||||
inline uint32_t get_tuner_type() const
|
||||
{
|
||||
return tuner_type_;
|
||||
}
|
||||
|
||||
inline uint32_t get_tuner_gain_count () const {
|
||||
inline uint32_t get_tuner_gain_count() const
|
||||
{
|
||||
return tuner_gain_count_;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,7 +109,7 @@ void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols,int frame_length)
|
||||
void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int frame_length)
|
||||
{
|
||||
double page_symbols_deint[frame_length];
|
||||
// 1. De-interleave
|
||||
@@ -530,7 +530,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite)
|
||||
void galileo_e5a_telemetry_decoder_cc::set_satellite(const Gnss_Satellite & satellite)
|
||||
{
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite;
|
||||
|
||||
@@ -66,8 +66,8 @@ class galileo_e5a_telemetry_decoder_cc : public gr::block
|
||||
{
|
||||
public:
|
||||
~galileo_e5a_telemetry_decoder_cc();
|
||||
void set_satellite(Gnss_Satellite satellite); //!< Set satellite PRN
|
||||
void set_channel(int channel); //!< Set receiver's channel
|
||||
void set_satellite(const Gnss_Satellite & satellite); //!< Set satellite PRN
|
||||
void set_channel(int channel); //!< Set receiver's channel
|
||||
/*!
|
||||
* \brief This is where all signal processing takes place
|
||||
*/
|
||||
@@ -83,13 +83,11 @@ private:
|
||||
|
||||
void deinterleaver(int rows, int cols, double *in, double *out);
|
||||
|
||||
void decode_word(double *page_symbols,int frame_length);
|
||||
void decode_word(double *page_symbols, int frame_length);
|
||||
|
||||
int d_preamble_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
// signed int d_page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
double d_page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
|
||||
// signed int *d_preamble_symbols;
|
||||
double d_current_symbol;
|
||||
long unsigned int d_symbol_counter;
|
||||
int d_prompt_counter;
|
||||
|
||||
@@ -237,7 +237,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items __attribute_
|
||||
if (d_stat == 1)
|
||||
{
|
||||
preamble_diff_ms = round(((static_cast<double>(d_symbol_history.at(0).Tracking_sample_counter) - static_cast<double>(d_preamble_time_samples)) / static_cast<double>(d_symbol_history.at(0).fs)) * 1000.0);
|
||||
if (preamble_diff_ms > GPS_SUBFRAME_MS+1)
|
||||
if (preamble_diff_ms > GPS_SUBFRAME_MS + 1)
|
||||
{
|
||||
DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff_ms;
|
||||
d_stat = 0; //lost of frame sync
|
||||
@@ -344,16 +344,16 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items __attribute_
|
||||
}
|
||||
|
||||
//2. Add the telemetry decoder information
|
||||
if (this->d_flag_preamble == true and d_flag_new_tow_available==true)
|
||||
if (this->d_flag_preamble == true and d_flag_new_tow_available == true)
|
||||
{
|
||||
//double decoder_latency_ms=(double)(current_symbol.Tracking_sample_counter-d_symbol_history.at(0).Tracking_sample_counter)
|
||||
// /(double)current_symbol.fs;
|
||||
// update TOW at the preamble instant (account with decoder latency)
|
||||
d_TOW_at_Preamble = d_GPS_FSM.d_nav.d_TOW + 2*GPS_L1_CA_CODE_PERIOD + GPS_CA_PREAMBLE_DURATION_S;
|
||||
d_TOW_at_Preamble = d_GPS_FSM.d_nav.d_TOW + 2 * GPS_L1_CA_CODE_PERIOD + GPS_CA_PREAMBLE_DURATION_S;
|
||||
|
||||
d_TOW_at_current_symbol = floor(d_TOW_at_Preamble*1000.0)/1000.0;
|
||||
d_TOW_at_current_symbol = floor(d_TOW_at_Preamble * 1000.0) / 1000.0;
|
||||
flag_TOW_set = true;
|
||||
d_flag_new_tow_available=false;
|
||||
d_flag_new_tow_available = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user