Skip to content

Commit

Permalink
try to compute a channel even if it is as large as the number of pilots
Browse files Browse the repository at this point in the history
  • Loading branch information
marenz2569 committed Jan 5, 2025
1 parent 28a7c49 commit 3a8ac3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
, prometheus-cpp
, curlFull
, libcpr
, armadillo
}:
clangStdenv.mkDerivation {
name = "tetra-decoder";
Expand All @@ -23,6 +24,7 @@ clangStdenv.mkDerivation {
curlFull
prometheus-cpp
libcpr
armadillo
];

cmakeFlags = [ "-DNIX_BUILD=ON" ];
Expand Down
17 changes: 17 additions & 0 deletions src/iq_stream_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "iq_stream_decoder.hpp"
#include "l2/lower_mac.hpp"
#include <armadillo>
#include <memory>

IQStreamDecoder::IQStreamDecoder(
Expand Down Expand Up @@ -94,6 +95,19 @@ std::vector<std::complex<float>> IQStreamDecoder::channel_estimation(std::vector
return stream;
}

static auto solve_channel(const std::vector<std::complex<float>>& pilots,
const FixedQueue<std::complex<float>, 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<float> symbol) noexcept {
if (is_uplink_) {
float detectedN;
Expand Down Expand Up @@ -123,6 +137,9 @@ void IQStreamDecoder::process_complex(std::complex<float> 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<uint8_t> bits(len * 2);
Expand Down

0 comments on commit 3a8ac3d

Please sign in to comment.