From 3a8ac3d4c669a03c92b91b7c8004d97afd95f0ac Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sun, 5 Jan 2025 16:54:22 +0100 Subject: [PATCH] try to compute a channel even if it is as large as the number of pilots --- CMakeLists.txt | 4 +++- derivation.nix | 2 ++ src/iq_stream_decoder.cpp | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d65fcbf..432894f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,14 +61,16 @@ find_package(fmt REQUIRED) find_package(nlohmann_json REQUIRED) find_package(prometheus-cpp CONFIG REQUIRED) find_package(cpr REQUIRED) +find_package(Armadillo REQUIRED) +include_directories(${ARMADILLO_INCLUDE_DIRS}) include_directories(${CMAKE_SOURCE_DIR}/include) if (NOT NIX_BUILD) target_link_libraries(tetra-decoder-library cxxopts::cxxopts) endif() -target_link_libraries(tetra-decoder-library ZLIB::ZLIB fmt::fmt nlohmann_json::nlohmann_json viterbi prometheus-cpp::pull cpr::cpr) +target_link_libraries(tetra-decoder-library ZLIB::ZLIB fmt::fmt nlohmann_json::nlohmann_json viterbi prometheus-cpp::pull cpr::cpr ${ARMADILLO_LIBRARIES}) target_link_libraries(tetra-decoder tetra-decoder-library) target_link_libraries(tetra-viterbi viterbi) diff --git a/derivation.nix b/derivation.nix index e33acd3..7bac3d4 100644 --- a/derivation.nix +++ b/derivation.nix @@ -8,6 +8,7 @@ , prometheus-cpp , curlFull , libcpr +, armadillo }: clangStdenv.mkDerivation { name = "tetra-decoder"; @@ -23,6 +24,7 @@ clangStdenv.mkDerivation { curlFull prometheus-cpp libcpr + armadillo ]; cmakeFlags = [ "-DNIX_BUILD=ON" ]; diff --git a/src/iq_stream_decoder.cpp b/src/iq_stream_decoder.cpp index 0e644ea..cb875f1 100644 --- a/src/iq_stream_decoder.cpp +++ b/src/iq_stream_decoder.cpp @@ -9,6 +9,7 @@ #include "iq_stream_decoder.hpp" #include "l2/lower_mac.hpp" +#include #include IQStreamDecoder::IQStreamDecoder( @@ -94,6 +95,19 @@ std::vector> IQStreamDecoder::channel_estimation(std::vector return stream; } +static auto solve_channel(const std::vector>& pilots, + const FixedQueue, 300>& signal_queue, const std::size_t signal_offset) + -> arma::cx_fvec { + auto arma_pilots = arma::cx_fvec(pilots); + auto arma_signal = arma::cx_fvec(pilots.size()); + for (auto i = 0; i < arma_signal.size(); i++) { + arma_signal[i] = signal_queue[signal_offset + i]; + } + auto arma_conj_pilots = arma::conj(arma_pilots); + auto h_vec = arma::solve(arma_conj_pilots * arma_pilots, arma_conj_pilots * arma::conj(arma_signal)); + return h_vec; +} + void IQStreamDecoder::process_complex(std::complex symbol) noexcept { if (is_uplink_) { float detectedN; @@ -123,6 +137,9 @@ void IQStreamDecoder::process_complex(std::complex symbol) noexcept { if (detectedX >= SEQUENCE_DETECTION_THRESHOLD) { // std::cout << "Potential CUB found" << std::endl; + auto channel = solve_channel(training_seq_x_, symbol_buffer_hard_decision_, 44); + std::cout << channel << std::endl; + auto len = 103; std::vector bits(len * 2);