GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
sensor_data_aggregator.h
Go to the documentation of this file.
1/*!
2 * \file sensor_data_aggregator.h
3 * \brief Aggregates sensor samples from gnu radio stream tags into typed lists for easy access
4 * \author Victor Castillo, 2024. victorcastilloaguero(at)gmail.com
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
9 * This file is part of GNSS-SDR.
10 *
11 * Copyright (C) 2024-2025 (see AUTHORS file for a list of contributors)
12 * SPDX-License-Identifier: GPL-3.0-or-later
13 *
14 * -----------------------------------------------------------------------------
15 */
16
17
18#ifndef GNSS_SDR_SENSOR_DATA_AGGREGATOR_H
19#define GNSS_SDR_SENSOR_DATA_AGGREGATOR_H
20
22#include "sensor_identifier.h"
23#include <gnuradio/tags.h>
24#include <cstdint>
26#include <vector>
27
28/** \addtogroup Algorithms_Library
29 * \{ */
30/** \addtogroup Algorithm_libs algorithms_libs
31 * \{ */
32
33
34template <typename DataType>
35struct SensorDataSample
36{
37 uint64_t timestamp;
38 DataType value;
39 constexpr SensorDataSample() = default;
40 constexpr SensorDataSample(uint64_t t, DataType v)
41 : timestamp(t), value(v) {}
42};
43
44
45class SensorDataAggregator
46{
47public:
48 const pmt::pmt_t SENSOR_DATA_TAG = pmt::mp("sensor_data");
49
50 explicit SensorDataAggregator(const SensorDataSourceConfiguration& configuration, const std::vector<SensorIdentifier::value_type>& required_sensors);
51
52 void update(const std::vector<gr::tag_t>& tags);
53
54 const std::vector<SensorDataSample<float>>& get_f32(SensorIdentifier::value_type sensor_id) const;
55 SensorDataSample<float> get_last_f32(SensorIdentifier::value_type sensor_id) const;
56 SensorDataSample<float> get_average_f32(SensorIdentifier::value_type sensor_id) const;
57
58 const std::vector<SensorDataSample<double>>& get_f64(SensorIdentifier::value_type sensor_id) const;
59 SensorDataSample<double> get_last_f64(SensorIdentifier::value_type sensor_id) const;
60 SensorDataSample<double> get_average_f64(SensorIdentifier::value_type sensor_id) const;
61
62 // More getters to be added in the future for different types
63private:
64 void append_data(const pmt::pmt_t& data_dict);
65
66 std::unordered_map<SensorIdentifier::value_type, std::vector<SensorDataSample<float>>> f32_data_{};
67 std::unordered_map<SensorIdentifier::value_type, std::vector<SensorDataSample<double>>> f64_data_{};
68 // More maps to be added in the future for different types
69};
70
71
72/** \} */
73/** \} */
74#endif // GNSS_SDR_SENSOR_DATA_AGGREGATOR_H
This interface represents a GNSS block.