mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-09-05 20:37:59 +00:00
fix(sensor_data): update sensor data tag timestamp in resampler block
This commit is contained in:

committed by
Carles Fernandez

parent
59f4a4e6a6
commit
878df30050
@@ -74,6 +74,7 @@ set(GNSS_SPLIBS_HEADERS ${GNSS_SPLIBS_HEADERS}
|
||||
sensor_data/sensor_data_source_configuration.h
|
||||
sensor_data/sensor_data_source.h
|
||||
sensor_data/sensor_data_aggregator.h
|
||||
sensor_data/sensor_data_resampler.h
|
||||
)
|
||||
set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES}
|
||||
sensor_data/sensor_data_type.cc
|
||||
@@ -82,6 +83,7 @@ set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES}
|
||||
sensor_data/sensor_data_source_configuration.cc
|
||||
sensor_data/sensor_data_source.cc
|
||||
sensor_data/sensor_data_aggregator.cc
|
||||
sensor_data/sensor_data_resampler.cc
|
||||
)
|
||||
|
||||
if(ENABLE_OPENCL)
|
||||
|
37
src/algorithms/libs/sensor_data/sensor_data_resampler.cc
Normal file
37
src/algorithms/libs/sensor_data/sensor_data_resampler.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
/*!
|
||||
* \file sensor_data_resampler.cc
|
||||
* \brief Updates timestamp within sensor data tags. To be used within resampler blocks.
|
||||
* \author Victor Castillo, 2024. victorcastilloaguero(at)gmail.com
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2025 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "sensor_data_resampler.h"
|
||||
#include "sensor_identifier.h"
|
||||
|
||||
std::vector<gr::tag_t> resample_sensor_data_tags(const std::vector<gr::tag_t>& tags, double freq_in, double freq_out)
|
||||
{
|
||||
static pmt::pmt_t SAMPLE_STAMP_KEY = pmt::mp(SensorIdentifier::to_string(SensorIdentifier::SAMPLE_STAMP));
|
||||
std::vector<gr::tag_t> new_tags{};
|
||||
for (auto& tag : tags)
|
||||
{
|
||||
if (pmt::dict_has_key(tag.value, SAMPLE_STAMP_KEY))
|
||||
{
|
||||
auto& new_tag = new_tags.emplace_back();
|
||||
uint64_t sample_stamp = pmt::to_uint64(pmt::dict_ref(tag.value, SAMPLE_STAMP_KEY, pmt::from_uint64(0)));
|
||||
sample_stamp = sample_stamp * freq_out / freq_in;
|
||||
new_tag.offset = tag.offset * freq_out / freq_in;
|
||||
new_tag.key = tag.key;
|
||||
new_tag.value = pmt::dict_add(tag.value, SAMPLE_STAMP_KEY, pmt::from_uint64(sample_stamp));
|
||||
}
|
||||
}
|
||||
return new_tags;
|
||||
}
|
35
src/algorithms/libs/sensor_data/sensor_data_resampler.h
Normal file
35
src/algorithms/libs/sensor_data/sensor_data_resampler.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*!
|
||||
* \file sensor_data_resampler.h
|
||||
* \brief Updates timestamp within sensor data tags. To be used within resampler blocks.
|
||||
* \author Victor Castillo, 2024. victorcastilloaguero(at)gmail.com
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2025 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_SENSOR_DATA_RESAMPLER_H
|
||||
#define GNSS_SDR_SENSOR_DATA_RESAMPLER_H
|
||||
|
||||
#include <gnuradio/tags.h>
|
||||
#include <vector>
|
||||
|
||||
/** \addtogroup Algorithms_Library
|
||||
* \{ */
|
||||
/** \addtogroup Algorithm_libs algorithms_libs
|
||||
* \{ */
|
||||
|
||||
|
||||
std::vector<gr::tag_t> resample_sensor_data_tags(const std::vector<gr::tag_t>& tags, double freq_in, double freq_out);
|
||||
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_DATA_RESAMPLER_H
|
@@ -661,7 +661,15 @@ void hybrid_observables_gs::set_tag_timestamp_in_sdr_timeframe(const std::vector
|
||||
void hybrid_observables_gs::propagate_sensor_data(const std::vector<Gnss_Synchro> &data)
|
||||
{
|
||||
static pmt::pmt_t SAMPLE_STAMP_KEY = pmt::mp(SensorIdentifier::to_string(SensorIdentifier::SAMPLE_STAMP));
|
||||
uint64_t current_sample = data[0].Tracking_sample_counter * 10;
|
||||
uint64_t current_sample = 0;
|
||||
for (const Gnss_Synchro& item: data)
|
||||
{
|
||||
if (item.Tracking_sample_counter > current_sample)
|
||||
{
|
||||
current_sample = item.Tracking_sample_counter;
|
||||
}
|
||||
}
|
||||
|
||||
if (d_trq_last_sample == 0)
|
||||
{
|
||||
d_trq_last_sample = current_sample;
|
||||
|
@@ -94,7 +94,7 @@ private:
|
||||
std::queue<GnssTime> d_TimeChannelTagTimestamps;
|
||||
|
||||
std::queue<gr::tag_t> d_sensor_data_tags;
|
||||
std::uint64_t d_trq_last_sample;
|
||||
std::uint64_t d_trq_last_sample{0};
|
||||
|
||||
std::vector<bool> d_channel_last_pll_lock;
|
||||
std::vector<double> d_channel_last_pseudorange_smooth;
|
||||
|
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#include "direct_resampler_conditioner_cb.h"
|
||||
#include "../../libs/sensor_data/sensor_data_resampler.h"
|
||||
#include "../../libs/sensor_data/sensor_identifier.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h> // for lv_8sc_t
|
||||
#include <algorithm> // for min
|
||||
@@ -58,6 +60,10 @@ direct_resampler_conditioner_cb::direct_resampler_conditioner_cb(
|
||||
#else
|
||||
this->set_relative_rate(sample_freq_out / sample_freq_in);
|
||||
#endif
|
||||
|
||||
// Do not propagate tags, they carry a sample offset that is not properly updated in
|
||||
// this resampler and thus needs manual handling.
|
||||
this->set_tag_propagation_policy(TPP_DONT);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +117,15 @@ int direct_resampler_conditioner_cb::general_work(int noutput_items,
|
||||
}
|
||||
}
|
||||
|
||||
// Sensor data tag resampling
|
||||
std::vector<gr::tag_t> sensor_tags;
|
||||
this->get_tags_in_window(sensor_tags, 0, 0, std::min(count, ninput_items[0]), pmt::mp("sensor_data"));
|
||||
for (auto &tag : resample_sensor_data_tags(sensor_tags, d_sample_freq_in, d_sample_freq_out))
|
||||
{
|
||||
this->add_item_tag(0, tag);
|
||||
}
|
||||
|
||||
|
||||
consume_each(std::min(count, ninput_items[0]));
|
||||
return lcv;
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#include "direct_resampler_conditioner_cc.h"
|
||||
#include "../../libs/sensor_data/sensor_data_resampler.h"
|
||||
#include "../../libs/sensor_data/sensor_identifier.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h> // for gr_complex
|
||||
#include <algorithm> // for min
|
||||
@@ -57,6 +59,10 @@ direct_resampler_conditioner_cc::direct_resampler_conditioner_cc(
|
||||
#else
|
||||
this->set_relative_rate(sample_freq_out / sample_freq_in);
|
||||
#endif
|
||||
|
||||
// Do not propagate tags, they carry a sample offset that is not properly updated in
|
||||
// this resampler and thus needs manual handling.
|
||||
this->set_tag_propagation_policy(TPP_DONT);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +115,15 @@ int direct_resampler_conditioner_cc::general_work(int noutput_items,
|
||||
}
|
||||
}
|
||||
|
||||
// Sensor data tag resampling
|
||||
std::vector<gr::tag_t> sensor_tags;
|
||||
this->get_tags_in_window(sensor_tags, 0, 0, std::min(count, ninput_items[0]), pmt::mp("sensor_data"));
|
||||
for (auto &tag : resample_sensor_data_tags(sensor_tags, d_sample_freq_in, d_sample_freq_out))
|
||||
{
|
||||
this->add_item_tag(0, tag);
|
||||
}
|
||||
|
||||
|
||||
consume_each(std::min(count, ninput_items[0]));
|
||||
return lcv;
|
||||
}
|
||||
|
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
#include "direct_resampler_conditioner_cs.h"
|
||||
#include "../../libs/sensor_data/sensor_data_resampler.h"
|
||||
#include "../../libs/sensor_data/sensor_identifier.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <volk/volk.h> // for lv_16sc_t
|
||||
#include <algorithm> // for min
|
||||
@@ -59,6 +61,10 @@ direct_resampler_conditioner_cs::direct_resampler_conditioner_cs(
|
||||
#else
|
||||
this->set_relative_rate(sample_freq_out / sample_freq_in);
|
||||
#endif
|
||||
|
||||
// Do not propagate tags, they carry a sample offset that is not properly updated in
|
||||
// this resampler and thus needs manual handling.
|
||||
this->set_tag_propagation_policy(TPP_DONT);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +118,15 @@ int direct_resampler_conditioner_cs::general_work(int noutput_items,
|
||||
}
|
||||
}
|
||||
|
||||
// Sensor data tag resampling
|
||||
std::vector<gr::tag_t> sensor_tags;
|
||||
this->get_tags_in_window(sensor_tags, 0, 0, std::min(count, ninput_items[0]), pmt::mp("sensor_data"));
|
||||
for (auto &tag : resample_sensor_data_tags(sensor_tags, d_sample_freq_in, d_sample_freq_out))
|
||||
{
|
||||
this->add_item_tag(0, tag);
|
||||
}
|
||||
|
||||
|
||||
consume_each(std::min(count, ninput_items[0]));
|
||||
return lcv;
|
||||
}
|
||||
|
Reference in New Issue
Block a user