FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
signal_processor.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file signal_processor.h
10 * @brief Header for receiver-side signal processing and rendering.
11 *
12 * This file contains declarations for functions that perform digital signal
13 * processing on received radar signals. This includes rendering raw responses
14 * into time-domain I/Q samples, adding thermal noise, and simulating ADC quantization.
15 */
16
17#pragma once
18
19#include <cstdint>
20#include <memory>
21#include <random>
22#include <span>
23#include <vector>
24
25#include "core/config.h"
26
27namespace serial
28{
29 class Response;
30}
31
32namespace pool
33{
34 class ThreadPool;
35}
36
37namespace processing
38{
39 /// One complex Cartesian IQ sample scaled for VITA-style signed 16-bit transport.
41 {
42 std::int16_t i = 0;
43 std::int16_t q = 0;
44 };
45
46 /// Result of fixed-fullscale IQ scaling.
48 {
49 std::vector<FixedFullscaleIqSample> samples;
50 std::uint64_t clipped_sample_count = 0;
51 };
52
53 /**
54 * @brief Renders a time-window of I/Q data from a collection of raw radar responses.
55 *
56 * This function orchestrates the process of converting abstract `Response` objects
57 * into a concrete vector of complex I/Q samples for a specific time window.
58 * It handles the superposition of multiple signals arriving at the receiver
59 * during the window and can use a thread pool for parallel processing.
60 *
61 * @param window The output vector where the rendered I/Q samples will be added.
62 * @param length The duration of the time window in seconds.
63 * @param start The start time of the window in seconds.
64 * @param fracDelay A fractional sample delay to apply for fine-grained timing.
65 * @param responses A span of unique pointers to the `Response` objects to be rendered.
66 */
67 void renderWindow(std::vector<ComplexType>& window, RealType length, RealType start, RealType fracDelay,
68 std::span<const std::unique_ptr<serial::Response>> responses);
69
70 /// Applies circular complex thermal noise using a caller-specified complex-baseband sample rate.
72 std::mt19937& rngEngine, RealType sampleRateHz);
73
74 /**
75 * @brief Simulates ADC quantization and scales a window of complex I/Q samples.
76 *
77 * This function first finds the maximum absolute value in the I/Q data to determine
78 * the full-scale range. It then simulates the quantization process based on the
79 * configured number of ADC bits. If no quantization is specified (adc_bits=0), it
80 * normalizes the data to a maximum amplitude of 1.0.
81 *
82 * @param window The window of complex I/Q samples to quantize and scale.
83 * @return The full-scale value used for quantization/normalization.
84 */
85 RealType quantizeAndScaleWindow(std::span<ComplexType> window);
86
87 /**
88 * @brief Scales complex samples against a fixed full-scale to signed int16 IQ.
89 *
90 * This helper is intended for real-time receiver-output sinks, where scanning a
91 * complete future window to derive full-scale would change hardware-like behavior.
92 *
93 * @param samples Input complex samples in physical units.
94 * @param fullscale Positive fixed full-scale magnitude for both I and Q channels.
95 * @return Scaled int16 IQ samples and a count of complex samples that clipped on either channel.
96 * @throws std::invalid_argument when fullscale is not positive.
97 */
98 [[nodiscard]] FixedFullscaleScalingResult scaleToInt16FixedFullscale(std::span<const ComplexType> samples,
99 RealType fullscale);
100}
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
FixedFullscaleScalingResult scaleToInt16FixedFullscale(const std::span< const ComplexType > samples, const RealType fullscale)
Scales complex samples against a fixed full-scale to signed int16 IQ.
void applyThermalNoiseAtSampleRate(std::span< ComplexType > window, const RealType noiseTemperature, std::mt19937 &rngEngine, const RealType sampleRateHz)
Applies circular complex thermal noise using a caller-specified complex-baseband sample rate.
RealType quantizeAndScaleWindow(std::span< ComplexType > window)
Simulates ADC quantization and scales a window of complex I/Q samples.
void renderWindow(std::vector< ComplexType > &window, const RealType length, const RealType start, const RealType fracDelay, const std::span< const std::unique_ptr< serial::Response > > responses)
Renders a time-window of I/Q data from a collection of raw radar responses.
math::Vec3 max
One complex Cartesian IQ sample scaled for VITA-style signed 16-bit transport.
Result of fixed-fullscale IQ scaling.
std::vector< FixedFullscaleIqSample > samples