mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-12-17 22:08:05 +00:00
feat: added SensorDataAggregator & moved everything to algorithms/libs
This commit is contained in:
committed by
Carles Fernandez
parent
4db7f775b5
commit
195886244a
@@ -61,7 +61,7 @@ FileSourceBase::FileSourceBase(ConfigurationInterface const* configuration, std:
|
||||
repeat_(configuration->property(role_ + ".repeat"s, false)),
|
||||
enable_throttle_control_(configuration->property(role_ + ".enable_throttle_control"s, false)),
|
||||
dump_(configuration->property(role_ + ".dump"s, false)),
|
||||
sensor_data_source_configuration_(configuration, configuration->property(role_ + ".sensor_data.enabled"s, false))
|
||||
sensor_data_source_configuration_(configuration)
|
||||
{
|
||||
minimum_tail_s_ = std::max(configuration->property("Acquisition_1C.coherent_integration_time_ms", 0.0) * 0.001 * 2.0, minimum_tail_s_);
|
||||
minimum_tail_s_ = std::max(configuration->property("Acquisition_2S.coherent_integration_time_ms", 0.0) * 0.001 * 2.0, minimum_tail_s_);
|
||||
|
||||
@@ -20,6 +20,11 @@ if(ENABLE_ION)
|
||||
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} ion_gsms.h)
|
||||
endif()
|
||||
|
||||
if (ENABLE_SENSOR_DATA)
|
||||
set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} sensor_data_source.cc)
|
||||
set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} sensor_data_source.h)
|
||||
endif ()
|
||||
|
||||
set(SIGNAL_SOURCE_GR_BLOCKS_SOURCES
|
||||
fifo_reader.cc
|
||||
unpack_byte_2bit_samples.cc
|
||||
@@ -31,7 +36,6 @@ set(SIGNAL_SOURCE_GR_BLOCKS_SOURCES
|
||||
unpack_2bit_samples.cc
|
||||
unpack_spir_gss6450_samples.cc
|
||||
labsat23_source.cc
|
||||
sensor_data_source.cc
|
||||
${OPT_DRIVER_SOURCES}
|
||||
)
|
||||
|
||||
@@ -46,7 +50,6 @@ set(SIGNAL_SOURCE_GR_BLOCKS_HEADERS
|
||||
unpack_2bit_samples.h
|
||||
unpack_spir_gss6450_samples.h
|
||||
labsat23_source.h
|
||||
sensor_data_source.h
|
||||
${OPT_DRIVER_HEADERS}
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "sensor_data_source.h"
|
||||
#include "sensor_data_file.h"
|
||||
#include "sensor_data/sensor_data_file.h"
|
||||
#include <pmt/pmt.h>
|
||||
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
@@ -83,15 +83,16 @@ int SensorDataSource::work(int noutput_items,
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items)
|
||||
{
|
||||
static pmt::pmt_t TAG_KEY = pmt::mp("sensor_data");
|
||||
static pmt::pmt_t CHUNK_COUNT_KEY = pmt::mp("CHUNK_COUNT");
|
||||
static pmt::pmt_t SAMPLE_STAMP_KEY = pmt::mp("SAMPLE_STAMP");
|
||||
|
||||
std::memcpy(output_items[0], input_items[0], noutput_items * item_size_);
|
||||
|
||||
const uint64_t total_items_written = nitems_written(0) + noutput_items;
|
||||
|
||||
std::size_t sample_stamp;
|
||||
std::vector<uint8_t> chunk{};
|
||||
pmt::pmt_t tag_key = pmt::mp("sensor_data");
|
||||
pmt::pmt_t chunk_count_key = pmt::mp("CHUNK_COUNT");
|
||||
pmt::pmt_t sample_stamp_key = pmt::mp("SAMPLE_STAMP");
|
||||
for (auto& file_pair : sensor_data_files_)
|
||||
{
|
||||
const auto& file_id = file_pair.first;
|
||||
@@ -99,13 +100,13 @@ int SensorDataSource::work(int noutput_items,
|
||||
while (data_file->read_until_sample(total_items_written, sample_stamp, chunk))
|
||||
{
|
||||
pmt::pmt_t data_tag = pmt::make_dict();
|
||||
data_tag = pmt::dict_add(data_tag, sample_stamp_key, pmt::from_long(sample_stamp / items_per_sample_));
|
||||
data_tag = pmt::dict_add(data_tag, chunk_count_key, pmt::from_long(data_file->get_chunks_read()));
|
||||
data_tag = pmt::dict_add(data_tag, SAMPLE_STAMP_KEY, pmt::from_uint64(sample_stamp / items_per_sample_));
|
||||
data_tag = pmt::dict_add(data_tag, CHUNK_COUNT_KEY, pmt::from_long(data_file->get_chunks_read()));
|
||||
for (const auto& sensor : sensor_config_map_.at(file_id))
|
||||
{
|
||||
data_tag = pmt::dict_add(data_tag, sensor.tag_key, SensorDataType::make_value(sensor.type, &chunk[sensor.offset]));
|
||||
}
|
||||
add_item_tag(0, sample_stamp, tag_key, data_tag);
|
||||
add_item_tag(0, sample_stamp, TAG_KEY, data_tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef GNSS_SDR_SENSOR_DATA_SOURCE_H
|
||||
#define GNSS_SDR_SENSOR_DATA_SOURCE_H
|
||||
|
||||
#include "sensor_data/sensor_data_file.h"
|
||||
#include "sensor_data/sensor_data_source_configuration.h"
|
||||
#include "gnss_block_interface.h"
|
||||
#include "sensor_data_file.h"
|
||||
#include "sensor_data_source_configuration.h"
|
||||
#include <gnuradio/sync_block.h> // for sync_block
|
||||
#include <gnuradio/types.h> // for gr_vector_const_void_star
|
||||
#include <cstddef> // for size_t
|
||||
@@ -52,57 +52,6 @@ private:
|
||||
std::size_t items_per_sample_;
|
||||
};
|
||||
|
||||
class SensorDataAggregator
|
||||
{
|
||||
public:
|
||||
explicit SensorDataAggregator(std::vector<gr::tag_t> tags)
|
||||
{
|
||||
for (const auto& sensor_tag : tags)
|
||||
{
|
||||
if (sensor_tag.value->is_dict())
|
||||
{
|
||||
append_data(sensor_tag.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto get(SensorIdentifier::value_type sensor_id) const
|
||||
{
|
||||
if (data_.contains(sensor_id))
|
||||
{
|
||||
return data_.at(sensor_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void append_data(const pmt::pmt_t& data)
|
||||
{
|
||||
pmt::pmt_t data_list = pmt::dict_items(data);
|
||||
while (not pmt::is_null(data_list))
|
||||
{
|
||||
pmt::pmt_t pair = pmt::car(data_list);
|
||||
pmt::pmt_t key = pmt::car(pair);
|
||||
pmt::pmt_t val = pmt::cdr(pair);
|
||||
|
||||
std::string key_str = pmt::write_string(key);
|
||||
SensorIdentifier::value_type sensor_id = SensorIdentifier::from_string(key_str);
|
||||
|
||||
if (not data_.contains(sensor_id))
|
||||
{
|
||||
data_[sensor_id] = {};
|
||||
}
|
||||
data_[sensor_id].emplace_back(val);
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<SensorIdentifier::value_type, std::vector<pmt::pmt_t>> data_{};
|
||||
};
|
||||
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_DATA_SOURCE_H
|
||||
|
||||
@@ -56,10 +56,6 @@ set(SIGNAL_SOURCE_LIB_SOURCES
|
||||
rtl_tcp_dongle_info.cc
|
||||
gnss_sdr_valve.cc
|
||||
gnss_sdr_timestamp.cc
|
||||
sensor_data_file.cc
|
||||
sensor_data_source_configuration.cc
|
||||
sensor_data_type.cc
|
||||
sensor_identifier.cc
|
||||
${OPT_SIGNAL_SOURCE_LIB_SOURCES}
|
||||
)
|
||||
|
||||
@@ -67,10 +63,6 @@ set(SIGNAL_SOURCE_LIB_HEADERS
|
||||
rtl_tcp_commands.h
|
||||
rtl_tcp_dongle_info.h
|
||||
gnss_sdr_valve.h
|
||||
sensor_data_file.h
|
||||
sensor_data_source_configuration.h
|
||||
sensor_data_type.h
|
||||
sensor_identifier.h
|
||||
${OPT_SIGNAL_SOURCE_LIB_HEADERS}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_file.cc
|
||||
* \brief Provides a simple abstraction for reading contiguous binary data from a file
|
||||
* \author Victor Castillo, 2024. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "sensor_data_file.h"
|
||||
#include <cstring>
|
||||
|
||||
SensorDataFile::SensorDataFile(
|
||||
const std::string& path,
|
||||
const std::size_t& sample_delay,
|
||||
const std::size_t& sample_period,
|
||||
const std::size_t& offset_in_file,
|
||||
const std::size_t& item_size,
|
||||
const bool& repeat)
|
||||
: path_(path),
|
||||
file_(path_),
|
||||
sample_delay_(sample_delay),
|
||||
sample_period_(sample_period),
|
||||
offset_in_file_(offset_in_file),
|
||||
item_size_(item_size),
|
||||
repeat_(repeat),
|
||||
done_(false),
|
||||
chunks_read_(0),
|
||||
last_sample_stamp_(sample_delay),
|
||||
io_buffer_size_(item_size * IO_BUFFER_CAPACITY),
|
||||
offset_in_io_buffer_(io_buffer_size_) // Set to end of buffer so that first look up will trigger a read.
|
||||
{
|
||||
file_.seekg(offset_in_file_, std::ios_base::beg);
|
||||
|
||||
io_buffer_.resize(io_buffer_size_);
|
||||
}
|
||||
|
||||
void SensorDataFile::reset()
|
||||
{
|
||||
file_.seekg(offset_in_file_, std::ios_base::beg);
|
||||
offset_in_io_buffer_ = io_buffer_size_;
|
||||
done_ = false;
|
||||
}
|
||||
|
||||
bool SensorDataFile::read_item(std::vector<uint8_t>& buffer)
|
||||
{
|
||||
if (offset_in_io_buffer_ >= io_buffer_size_)
|
||||
{
|
||||
if (done_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
read_into_io_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
chunks_read_++;
|
||||
read_into_item_buffer(buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SensorDataFile::read_until_sample(std::size_t end_sample, std::size_t& sample_stamp, std::vector<uint8_t>& buffer)
|
||||
{
|
||||
if (last_sample_stamp_ + sample_period_ < end_sample)
|
||||
{
|
||||
last_sample_stamp_ += sample_period_;
|
||||
sample_stamp = last_sample_stamp_;
|
||||
read_item(buffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::size_t SensorDataFile::get_chunks_read() const
|
||||
{
|
||||
return chunks_read_;
|
||||
}
|
||||
|
||||
void SensorDataFile::read_into_io_buffer()
|
||||
{
|
||||
file_.read(reinterpret_cast<char*>(&io_buffer_[0]), io_buffer_size_);
|
||||
const std::size_t bytes_read = file_.gcount();
|
||||
|
||||
if (bytes_read < io_buffer_size_)
|
||||
{
|
||||
if (repeat_)
|
||||
{
|
||||
reset();
|
||||
file_.read(reinterpret_cast<char*>(&io_buffer_[bytes_read]), io_buffer_size_ - bytes_read);
|
||||
}
|
||||
else
|
||||
{
|
||||
io_buffer_size_ = bytes_read;
|
||||
done_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
offset_in_io_buffer_ = 0;
|
||||
}
|
||||
|
||||
void SensorDataFile::read_into_item_buffer(std::vector<uint8_t>& item_buf)
|
||||
{
|
||||
item_buf.resize(item_size_);
|
||||
std::memcpy(item_buf.data(), &io_buffer_[offset_in_io_buffer_], item_size_);
|
||||
offset_in_io_buffer_ += item_size_;
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_file.h
|
||||
* \brief Provides a simple abstraction for reading contiguous binary data from a file
|
||||
* \author Victor Castillo, 2024. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_SENSOR_DATA_FILE_H
|
||||
#define GNSS_SDR_SENSOR_DATA_FILE_H
|
||||
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/** \addtogroup Signal_Source
|
||||
* \{ */
|
||||
/** \addtogroup Signal_Source_libs
|
||||
* \{ */
|
||||
|
||||
|
||||
class SensorDataFile
|
||||
{
|
||||
static constexpr std::size_t IO_BUFFER_CAPACITY = 1024;
|
||||
|
||||
public:
|
||||
using sptr = std::shared_ptr<SensorDataFile>;
|
||||
using id_type = std::size_t;
|
||||
|
||||
SensorDataFile(
|
||||
const std::string& path,
|
||||
const std::size_t& sample_delay,
|
||||
const std::size_t& sample_period,
|
||||
const std::size_t& offset_in_file,
|
||||
const std::size_t& item_size,
|
||||
const bool& repeat);
|
||||
|
||||
|
||||
void reset();
|
||||
|
||||
bool read_until_sample(std::size_t end_sample, std::size_t& sample_stamp, std::vector<uint8_t>& buffer);
|
||||
|
||||
std::size_t get_chunks_read() const;
|
||||
private:
|
||||
bool read_item(std::vector<uint8_t>& buffer);
|
||||
|
||||
void read_into_io_buffer();
|
||||
|
||||
void read_into_item_buffer(std::vector<uint8_t>& item_buf);
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
std::ifstream file_;
|
||||
std::size_t sample_delay_;
|
||||
std::size_t sample_period_;
|
||||
std::size_t offset_in_file_;
|
||||
std::size_t item_size_;
|
||||
bool repeat_;
|
||||
bool done_;
|
||||
|
||||
std::size_t chunks_read_;
|
||||
std::size_t last_sample_stamp_;
|
||||
std::vector<uint8_t> io_buffer_;
|
||||
std::size_t io_buffer_size_;
|
||||
std::size_t offset_in_io_buffer_;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_DATA_FILE_H
|
||||
@@ -1,152 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_source_configuration.cc
|
||||
* \brief
|
||||
* \author Victor Castillo, 2025. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "sensor_data_source_configuration.h"
|
||||
|
||||
SensorDataSourceConfiguration::SensorDataSourceConfiguration(const ConfigurationInterface* configuration, bool enabled)
|
||||
: enabled_(enabled), items_per_sample_(1)
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
configure_files(configuration);
|
||||
configure_sensors(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
bool SensorDataSourceConfiguration::validate() const
|
||||
{
|
||||
return validate_files() and validate_sensors();
|
||||
}
|
||||
|
||||
bool SensorDataSourceConfiguration::is_enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void SensorDataSourceConfiguration::set_items_per_sample(uint64_t items_per_sample)
|
||||
{
|
||||
items_per_sample_ = items_per_sample;
|
||||
}
|
||||
|
||||
uint64_t SensorDataSourceConfiguration::get_items_per_sample() const
|
||||
{
|
||||
return items_per_sample_;
|
||||
}
|
||||
|
||||
|
||||
const std::unordered_map<uint64_t, SensorDataFileConfiguration>& SensorDataSourceConfiguration::files() const
|
||||
{
|
||||
return files_;
|
||||
}
|
||||
|
||||
const std::vector<SensorDataConfiguration>& SensorDataSourceConfiguration::sensors() const
|
||||
{
|
||||
return sensors_;
|
||||
}
|
||||
|
||||
void SensorDataSourceConfiguration::configure_files(const ConfigurationInterface* configuration)
|
||||
{
|
||||
uint64_t file_count = configuration->property(CONFIGURATION_ROLE + ".file_count"s, 1UL);
|
||||
for (uint64_t id = 0; id < file_count; ++id)
|
||||
{
|
||||
std::string role = CONFIGURATION_ROLE + ".file" + std::to_string(id);
|
||||
files_.emplace(
|
||||
id,
|
||||
SensorDataFileConfiguration{
|
||||
.id = id,
|
||||
.filename = configuration->property(role + ".filename"s, std::string{""}),
|
||||
.repeat = configuration->property(role + ".repeat"s, false),
|
||||
.chunk_size = configuration->property(role + ".chunk_size"s, 0UL),
|
||||
.file_offset = configuration->property(role + ".file_offset"s, 0UL),
|
||||
.sample_offset = configuration->property(role + ".sample_offset"s, 0UL),
|
||||
.sample_period = configuration->property(role + ".sample_period"s, 0UL)});
|
||||
}
|
||||
}
|
||||
|
||||
void SensorDataSourceConfiguration::configure_sensors(const ConfigurationInterface* configuration)
|
||||
{
|
||||
uint64_t sensor_count = configuration->property(CONFIGURATION_ROLE + ".sensor_count"s, 1UL);
|
||||
for (uint64_t id = 0; id < sensor_count; ++id)
|
||||
{
|
||||
std::string role = CONFIGURATION_ROLE + ".sensor" + std::to_string(id);
|
||||
|
||||
// Configure sensor data type, default to same data type as previous sensor
|
||||
SensorDataType::value_type data_type = SensorDataType::FLOAT;
|
||||
if (id > 0 and not configuration->is_present(role + ".type"))
|
||||
{
|
||||
data_type = sensors_[id - 1].type;
|
||||
}
|
||||
else
|
||||
{
|
||||
data_type = SensorDataType::from_string(configuration->property(role + ".type"s, std::string{"UNKNOWN"}));
|
||||
}
|
||||
|
||||
// Configure offset, default to previous sensor offset plus previous sensor size
|
||||
uint64_t offset = 0UL;
|
||||
if (id > 0 and not configuration->is_present(role + ".offset"))
|
||||
{
|
||||
offset = sensors_[id - 1].offset + SensorDataType::get_size(sensors_[id - 1].type);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = configuration->property(role + ".offset"s, 0UL);
|
||||
}
|
||||
|
||||
// Configure file_id, default to previous sensor file_id
|
||||
uint64_t file_id = 0UL;
|
||||
if (id > 0 and not configuration->is_present(role + ".file"))
|
||||
{
|
||||
file_id = sensors_[id - 1].file_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
file_id = configuration->property(role + ".file"s, 0UL);
|
||||
}
|
||||
|
||||
// Find out which sensor this is
|
||||
const std::string sensor_identifier = configuration->property(role + ".data"s, std::string{"UNDEFINED"});
|
||||
|
||||
if (sensor_identifier != "UNDEFINED")
|
||||
{
|
||||
sensors_.emplace_back(SensorDataConfiguration{
|
||||
.id = id,
|
||||
.file_id = file_id,
|
||||
.identifier = SensorIdentifier::from_string(sensor_identifier),
|
||||
.type = data_type,
|
||||
.offset = offset,
|
||||
.tag_key = pmt::mp(sensor_identifier)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SensorDataSourceConfiguration::validate_files() const
|
||||
{
|
||||
for (const auto& file : files_)
|
||||
{
|
||||
// TODO - Implement
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SensorDataSourceConfiguration::validate_sensors() const
|
||||
{
|
||||
for (const auto& sensor : sensors_)
|
||||
{
|
||||
// TODO - Implement
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_source_configuration.h
|
||||
* \brief GNURadio block that adds extra data to the sample stream.
|
||||
* \author Victor Castillo, 2024. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_SENSOR_DATA_SOURCE_CONFIGURATION_H
|
||||
#define GNSS_SDR_SENSOR_DATA_SOURCE_CONFIGURATION_H
|
||||
|
||||
#include "configuration_interface.h"
|
||||
#include "sensor_data_type.h"
|
||||
#include "sensor_identifier.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
/** \addtogroup Signal_Source
|
||||
* \{ */
|
||||
/** \addtogroup Signal_Source_gnuradio_blocks
|
||||
* \{ */
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
static std::string CONFIGURATION_ROLE = "SensorData";
|
||||
|
||||
class ConfigurationInterface;
|
||||
|
||||
struct SensorDataFileConfiguration
|
||||
{
|
||||
uint64_t id;
|
||||
std::string filename;
|
||||
bool repeat;
|
||||
uint64_t chunk_size;
|
||||
uint64_t file_offset;
|
||||
uint64_t sample_offset;
|
||||
uint64_t sample_period;
|
||||
};
|
||||
|
||||
struct SensorDataConfiguration
|
||||
{
|
||||
uint64_t id;
|
||||
uint64_t file_id;
|
||||
SensorIdentifier::value_type identifier;
|
||||
SensorDataType::value_type type;
|
||||
uint64_t offset;
|
||||
|
||||
pmt::pmt_t tag_key;
|
||||
};
|
||||
|
||||
class SensorDataSourceConfiguration
|
||||
{
|
||||
public:
|
||||
explicit SensorDataSourceConfiguration(const ConfigurationInterface* configuration, bool enabled);
|
||||
|
||||
bool validate() const;
|
||||
|
||||
bool is_enabled() const;
|
||||
|
||||
const std::unordered_map<uint64_t, SensorDataFileConfiguration>& files() const;
|
||||
|
||||
const std::vector<SensorDataConfiguration>& sensors() const;
|
||||
|
||||
void set_items_per_sample(uint64_t items_per_sample);
|
||||
|
||||
uint64_t get_items_per_sample() const;
|
||||
|
||||
private:
|
||||
void configure_files(const ConfigurationInterface* configuration);
|
||||
|
||||
void configure_sensors(const ConfigurationInterface* configuration);
|
||||
|
||||
|
||||
bool validate_files() const;
|
||||
|
||||
bool validate_sensors() const;
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
std::unordered_map<uint64_t, SensorDataFileConfiguration> files_;
|
||||
std::vector<SensorDataConfiguration> sensors_;
|
||||
uint64_t items_per_sample_;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_DATA_SOURCE_CONFIGURATION_H
|
||||
@@ -1,63 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_type.cc
|
||||
* \brief
|
||||
* \author Victor Castillo, 2025. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "sensor_data_type.h"
|
||||
#include <cstdint>
|
||||
#include <pmt/pmt.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
SensorDataType::value_type SensorDataType::from_string(const std::string& s)
|
||||
{
|
||||
if (s == "float" or s == "FLOAT")
|
||||
{
|
||||
return SensorDataType::FLOAT;
|
||||
}
|
||||
throw std::runtime_error{"Unknown sensor data type: " + s};
|
||||
}
|
||||
|
||||
std::string SensorDataType::to_string(const SensorDataType::value_type& v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case SensorDataType::FLOAT:
|
||||
return "float";
|
||||
default:
|
||||
return "UNKNOWN SENSOR";
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t SensorDataType::get_size(const SensorDataType::value_type& v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case SensorDataType::FLOAT:
|
||||
return sizeof(float);
|
||||
default:
|
||||
return 0UL;
|
||||
}
|
||||
}
|
||||
|
||||
pmt::pmt_t SensorDataType::make_value(const SensorDataType::value_type& v, void* value)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case SensorDataType::FLOAT:
|
||||
return pmt::from_float(*static_cast<float*>(value));
|
||||
default:
|
||||
throw std::runtime_error{"Unknown sensor data type: " + to_string(v)};
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_data_type.h
|
||||
* \brief
|
||||
* \author Victor Castillo, 2025. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_SENSOR_DATA_TYPE_H
|
||||
#define GNSS_SDR_SENSOR_DATA_TYPE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <pmt/pmt.h>
|
||||
#include <string>
|
||||
|
||||
/** \addtogroup Signal_Source
|
||||
* \{ */
|
||||
/** \addtogroup Signal_Source_libs
|
||||
* \{ */
|
||||
|
||||
struct SensorDataType
|
||||
{
|
||||
SensorDataType() = delete;
|
||||
enum value_type
|
||||
{
|
||||
FLOAT
|
||||
};
|
||||
|
||||
static value_type from_string(const std::string& s);
|
||||
|
||||
static std::string to_string(const value_type& v);
|
||||
|
||||
static uint64_t get_size(const value_type& v);
|
||||
|
||||
static pmt::pmt_t make_value(const value_type& v, void* value);
|
||||
};
|
||||
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_DATA_TYPE_H
|
||||
@@ -1,105 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_identifier.cc
|
||||
* \brief
|
||||
* \author Victor Castillo, 2025. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "sensor_identifier.h"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
SensorIdentifier::value_type SensorIdentifier::from_string(const std::string& s)
|
||||
{
|
||||
if (s == "IMU_VEL_X")
|
||||
{
|
||||
return IMU_VEL_X;
|
||||
}
|
||||
else if (s == "IMU_VEL_Y")
|
||||
{
|
||||
return IMU_VEL_Y;
|
||||
}
|
||||
else if (s == "IMU_VEL_Z")
|
||||
{
|
||||
return IMU_VEL_Z;
|
||||
}
|
||||
else if (s == "IMU_ACC_X")
|
||||
{
|
||||
return IMU_ACC_X;
|
||||
}
|
||||
else if (s == "IMU_ACC_Y")
|
||||
{
|
||||
return IMU_ACC_Y;
|
||||
}
|
||||
else if (s == "IMU_ACC_Z")
|
||||
{
|
||||
return IMU_ACC_Z;
|
||||
}
|
||||
else if (s == "IMU_ANG_VEL_X")
|
||||
{
|
||||
return IMU_ANG_VEL_X;
|
||||
}
|
||||
else if (s == "IMU_ANG_VEL_Y")
|
||||
{
|
||||
return IMU_ANG_VEL_Y;
|
||||
}
|
||||
else if (s == "IMU_ANG_VEL_Z")
|
||||
{
|
||||
return IMU_ANG_VEL_Z;
|
||||
}
|
||||
else if (s == "IMU_ANG_ACC_X")
|
||||
{
|
||||
return IMU_ANG_ACC_X;
|
||||
}
|
||||
else if (s == "IMU_ANG_ACC_Y")
|
||||
{
|
||||
return IMU_ANG_ACC_Y;
|
||||
}
|
||||
else if (s == "IMU_ANG_ACC_Z")
|
||||
{
|
||||
return IMU_ANG_ACC_Z;
|
||||
}
|
||||
throw std::runtime_error{"Unknown sensor identifier: " + s};
|
||||
}
|
||||
|
||||
std::string SensorIdentifier::to_string(const SensorIdentifier::value_type& v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case IMU_VEL_X:
|
||||
return "IMU_VEL_X";
|
||||
case IMU_VEL_Y:
|
||||
return "IMU_VEL_Y";
|
||||
case IMU_VEL_Z:
|
||||
return "IMU_VEL_Z";
|
||||
case IMU_ACC_X:
|
||||
return "IMU_ACC_X";
|
||||
case IMU_ACC_Y:
|
||||
return "IMU_ACC_Y";
|
||||
case IMU_ACC_Z:
|
||||
return "IMU_ACC_Z";
|
||||
case IMU_ANG_VEL_X:
|
||||
return "IMU_ANG_VEL_X";
|
||||
case IMU_ANG_VEL_Y:
|
||||
return "IMU_ANG_VEL_Y";
|
||||
case IMU_ANG_VEL_Z:
|
||||
return "IMU_ANG_VEL_Z";
|
||||
case IMU_ANG_ACC_X:
|
||||
return "IMU_ANG_ACC_X";
|
||||
case IMU_ANG_ACC_Y:
|
||||
return "IMU_ANG_ACC_Y";
|
||||
case IMU_ANG_ACC_Z:
|
||||
return "IMU_ANG_ACC_Z";
|
||||
default:
|
||||
return "UNKNOWN SENSOR";
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*!
|
||||
* \file sensor_identifier.h
|
||||
* \brief
|
||||
* \author Victor Castillo, 2025. victorcastilloaguero(at).gmail.es
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GNSS_SDR_SENSOR_IDENTIFIER_H
|
||||
#define GNSS_SDR_SENSOR_IDENTIFIER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
/** \addtogroup Signal_Source
|
||||
* \{ */
|
||||
/** \addtogroup Signal_Source_libs
|
||||
* \{ */
|
||||
|
||||
struct SensorIdentifier
|
||||
{
|
||||
SensorIdentifier() = delete;
|
||||
enum value_type
|
||||
{
|
||||
IMU_VEL_X,
|
||||
IMU_VEL_Y,
|
||||
IMU_VEL_Z,
|
||||
IMU_ACC_X,
|
||||
IMU_ACC_Y,
|
||||
IMU_ACC_Z,
|
||||
IMU_ANG_VEL_X,
|
||||
IMU_ANG_VEL_Y,
|
||||
IMU_ANG_VEL_Z,
|
||||
IMU_ANG_ACC_X,
|
||||
IMU_ANG_ACC_Y,
|
||||
IMU_ANG_ACC_Z,
|
||||
};
|
||||
|
||||
static value_type from_string(const std::string& s);
|
||||
|
||||
static std::string to_string(const value_type& v);
|
||||
};
|
||||
|
||||
/** \} */
|
||||
/** \} */
|
||||
#endif // GNSS_SDR_SENSOR_IDENTIFIER_H
|
||||
Reference in New Issue
Block a user