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