FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
channel_model.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 channel_model.h
10 * @brief Header for radar channel propagation and interaction models.
11 *
12 * This file contains the declarations for functions that model the radar channel,
13 * including direct and reflected signal path calculations, and
14 * power scaling according to the radar range equation. These functions form the
15 * core physics engine for determining the properties of a received signal based
16 * on the positions and velocities of transmitters, receivers, and targets.
17 */
18
19#pragma once
20
21#include <chrono>
22#include <exception>
23#include <memory>
24
25#include "core/config.h"
26#include "math/geometry_ops.h"
27
28namespace core
29{
30 class World;
31}
32namespace radar
33{
34 class Receiver;
35
36 class Transmitter;
37
38 class Target;
39}
40
41namespace serial
42{
43 class Response;
44}
45
46namespace fers_signal
47{
48 class RadarSignal;
49}
50
51namespace simulation
52{
53 /**
54 * @struct ReResults
55 * @brief Stores the intermediate results of a radar equation calculation for a single time point.
56 */
57 struct ReResults
58 {
59 RealType power; /**< Power scaling factor (dimensionless, relative to transmitted power). */
60 RealType delay; /**< Signal propagation delay in seconds. */
61 RealType phase; /**< Phase shift in radians due to propagation delay. */
62 };
63
64 /**
65 * @class RangeError
66 * @brief Exception thrown when a range calculation fails, typically due to objects being too close.
67 */
68 class RangeError final : public std::exception
69 {
70 public:
71 /**
72 * @brief Provides the error message for the exception.
73 * @return A C-style string describing the error.
74 */
75 [[nodiscard]] const char* what() const noexcept override
76 {
77 return "Range error in radar equation calculations";
78 }
79 };
80
81 /**
82 * @brief Solves the bistatic radar equation for a reflected path (Tx -> Tgt -> Rx).
83 *
84 * This function calculates the signal properties (power, delay, phase)
85 * for a signal traveling from a transmitter, reflecting off a target, and arriving at a receiver.
86 * It accounts for antenna gains, target RCS, and propagation loss.
87 *
88 * @param trans Pointer to the transmitter.
89 * @param recv Pointer to the receiver.
90 * @param targ Pointer to the target.
91 * @param time The time at which the pulse is transmitted.
92 * @param wave Pointer to the transmitted radar signal.
93 * @param results Output struct to store the calculation results.
94 * @throws RangeError If the target is too close to the transmitter or receiver.
95 */
96 void solveRe(const radar::Transmitter* trans, const radar::Receiver* recv, const radar::Target* targ,
97 const std::chrono::duration<RealType>& time, const fers_signal::RadarSignal* wave, ReResults& results);
98
99 /**
100 * @brief Solves the radar equation for a direct path (Tx -> Rx).
101 *
102 * This function calculates the signal properties for a direct line-of-sight signal
103 * traveling from a transmitter to a receiver.
104 *
105 * @param trans Pointer to the transmitter.
106 * @param recv Pointer to the receiver.
107 * @param time The time at which the pulse is transmitted.
108 * @param wave Pointer to the transmitted radar signal.
109 * @param results Output struct to store the calculation results.
110 * @throws RangeError If the transmitter and receiver are too close.
111 */
112 void solveReDirect(const radar::Transmitter* trans, const radar::Receiver* recv,
113 const std::chrono::duration<RealType>& time, const fers_signal::RadarSignal* wave,
114 ReResults& results);
115
116 /**
117 * @brief Calculates the complex envelope contribution for a direct propagation path (Tx -> Rx) at a specific time.
118 * This function is used for Continuous Wave (CW) simulations.
119 *
120 * @param trans The transmitter.
121 * @param recv The receiver.
122 * @param timeK The current simulation time.
123 * @return The complex I/Q sample contribution for this path.
124 */
126 RealType timeK);
127
128 /**
129 * @brief Calculates the complex envelope contribution for a reflected path (Tx -> Tgt -> Rx) at a specific time.
130 * This function is used for Continuous Wave (CW) simulations.
131 *
132 * @param trans The transmitter.
133 * @param recv The receiver.
134 * @param targ The target.
135 * @param timeK The current simulation time.
136 * @return The complex I/Q sample contribution for this path.
137 */
139 const radar::Target* targ, RealType timeK);
140
141 /**
142 * @brief Creates a Response object by simulating a signal's interaction over its duration.
143 *
144 * This function iterates over the duration of a transmitted pulse, calling the
145 * appropriate channel model function (`solveRe` or `solveReDirect`) at discrete
146 * time steps to generate a series of `InterpPoint`s. These points capture the
147 * time-varying properties of the received signal and are collected into a `Response` object.
148 *
149 * @param trans Pointer to the transmitter.
150 * @param recv Pointer to the receiver.
151 * @param signal Pointer to the transmitted pulse signal.
152 * @param startTime The absolute simulation time when the pulse transmission starts.
153 * @param targ Optional pointer to a target. If null, a direct path is simulated.
154 * @return A unique pointer to the generated Response object.
155 * @throws RangeError If the channel model reports an invalid geometry.
156 * @throws std::runtime_error If the simulation parameters result in zero time steps.
157 */
158 std::unique_ptr<serial::Response> calculateResponse(const radar::Transmitter* trans, const radar::Receiver* recv,
159 const fers_signal::RadarSignal* signal, RealType startTime,
160 const radar::Target* targ = nullptr);
161
162 /**
163 * @enum LinkType
164 * @brief Categorizes the visual link for rendering.
165 */
166 enum class LinkType
167 {
168 Monostatic, ///< Combined Tx/Rx path
169 BistaticTxTgt, ///< Illuminator path
170 BistaticTgtRx, ///< Scattered path
171 DirectTxRx ///< Interference path
172 };
173
174 /**
175 * @enum LinkQuality
176 * @brief Describes the radiometric quality of the link.
177 */
178 enum class LinkQuality
179 {
180 Strong, ///< SNR > 0 dB
181 Weak ///< SNR < 0 dB (Geometric line of sight, but below noise floor)
182 };
183
184 /**
185 * @struct PreviewLink
186 * @brief A calculated link segment for 3D visualization.
187 */
189 {
192 std::string label;
193 std::string source_name; // The start of this specific link segment
194 std::string dest_name; // The end of this specific link segment
195 std::string origin_name; // The original source of energy (Transmitter)
196 };
197
198 /**
199 * @brief Calculates all visual links for the current world state at a specific time.
200 *
201 * This function utilizes the core radar equation helpers to determine visibility,
202 * power levels, and SNR for all Tx/Rx/Target combinations. It is lightweight
203 * and does not update simulation state.
204 *
205 * @param world The simulation world containing radar components.
206 * @param time The time at which to calculate geometry.
207 * @return A vector of renderable links.
208 */
209 std::vector<PreviewLink> calculatePreviewLinks(const core::World& world, RealType time);
210}
The World class manages the simulator environment.
Definition world.h:38
Class representing a radar signal with associated properties.
Manages radar signal reception and response processing.
Definition receiver.h:36
Base class for radar targets.
Definition target.h:117
Represents a radar transmitter system.
Definition transmitter.h:32
Exception thrown when a range calculation fails, typically due to objects being too close.
const char * what() const noexcept override
Provides the error message for the exception.
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
std::complex< RealType > ComplexType
Type for complex numbers.
Definition config.h:35
Classes and operations for 3D geometry.
LinkQuality
Describes the radiometric quality of the link.
@ Weak
SNR < 0 dB (Geometric line of sight, but below noise floor)
ComplexType calculateDirectPathContribution(const Transmitter *trans, const Receiver *recv, const RealType timeK)
Calculates the complex envelope contribution for a direct propagation path (Tx -> Rx) at a specific t...
void solveReDirect(const Transmitter *trans, const Receiver *recv, const std::chrono::duration< RealType > &time, const RadarSignal *wave, ReResults &results)
Solves the radar equation for a direct path (Tx -> Rx).
void solveRe(const Transmitter *trans, const Receiver *recv, const Target *targ, const std::chrono::duration< RealType > &time, const RadarSignal *wave, ReResults &results)
Solves the bistatic radar equation for a reflected path (Tx -> Tgt -> Rx).
std::vector< PreviewLink > calculatePreviewLinks(const core::World &world, const RealType time)
Calculates all visual links for the current world state at a specific time.
std::unique_ptr< serial::Response > calculateResponse(const Transmitter *trans, const Receiver *recv, const RadarSignal *signal, const RealType startTime, const Target *targ)
Creates a Response object by simulating a signal's interaction over its duration.
ComplexType calculateReflectedPathContribution(const Transmitter *trans, const Receiver *recv, const Target *targ, const RealType timeK)
Calculates the complex envelope contribution for a reflected path (Tx -> Tgt -> Rx) at a specific tim...
LinkType
Categorizes the visual link for rendering.
@ DirectTxRx
Interference path.
@ Monostatic
Combined Tx/Rx path.
@ BistaticTgtRx
Scattered path.
@ BistaticTxTgt
Illuminator path.
Stores the intermediate results of a radar equation calculation for a single time point.
RealType delay
Signal propagation delay in seconds.
RealType power
Power scaling factor (dimensionless, relative to transmitted power).
RealType phase
Phase shift in radians due to propagation delay.