FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
serial::fmcw_validation Namespace Reference

Typedefs

using Thrower = std::function< void(const std::string &)>
 Callback used by validators to report an error through the caller's mechanism.
 

Functions

void validateWaveform (const fers_signal::RadarSignal &wave, const std::string &owner, const Thrower &throw_error)
 Validates that a waveform is compatible with FMCW streaming constraints.
 
void validateWaveformModeMatch (const fers_signal::RadarSignal &wave, radar::OperationMode mode, const std::string &owner, const Thrower &throw_error)
 Validates that a waveform and radar operation mode are compatible.
 
void validateSchedule (const std::vector< radar::SchedulePeriod > &schedule, const fers_signal::FmcwChirpSignal &fmcw, const std::string &owner, const Thrower &throw_error)
 Validates that an FMCW waveform schedule can emit complete chirps.
 
void validateSchedule (const std::vector< radar::SchedulePeriod > &schedule, const fers_signal::RadarSignal &wave, const std::string &owner, const Thrower &throw_error)
 Validates that an FMCW waveform schedule can emit complete waveform periods.
 

Typedef Documentation

◆ Thrower

using serial::fmcw_validation::Thrower = typedef std::function<void(const std::string&)>

Callback used by validators to report an error through the caller's mechanism.

Definition at line 27 of file fmcw_validation.h.

Function Documentation

◆ validateSchedule() [1/2]

void serial::fmcw_validation::validateSchedule ( const std::vector< radar::SchedulePeriod > &  schedule,
const fers_signal::FmcwChirpSignal fmcw,
const std::string &  owner,
const Thrower throw_error 
)

Validates that an FMCW waveform schedule can emit complete chirps.

Definition at line 130 of file fmcw_validation.cpp.

132 {
133 for (const auto& period : effectiveSchedule(schedule))
134 {
135 const RealType duration = period.end - period.start;
136 if (duration < fmcw.getChirpDuration())
137 {
138 throw_error(std::format(
139 "{} has schedule period [{}, {}] duration {} s shorter than FMCW chirp_duration T_c={} s.", owner,
140 period.start, period.end, duration, fmcw.getChirpDuration()));
141 }
142 if (duration < fmcw.getChirpPeriod())
143 {
144 LOG(logging::Level::WARNING, "{} has a schedule period [{}, {}] shorter than FMCW chirp_period ({}s).",
145 owner, period.start, period.end, fmcw.getChirpPeriod());
146 }
147 }
148 }
RealType getChirpDuration() const noexcept
Gets the chirp duration in seconds.
RealType getChirpPeriod() const noexcept
Gets the chirp period in seconds.
double RealType
Type for real numbers.
Definition config.h:27
#define LOG(level,...)
Definition logging.h:19
@ WARNING
Warning level for potentially harmful situations.
math::Vec3 max

References fers_signal::FmcwChirpSignal::getChirpDuration(), fers_signal::FmcwChirpSignal::getChirpPeriod(), LOG, max, and logging::WARNING.

Referenced by validateSchedule().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateSchedule() [2/2]

void serial::fmcw_validation::validateSchedule ( const std::vector< radar::SchedulePeriod > &  schedule,
const fers_signal::RadarSignal wave,
const std::string &  owner,
const Thrower throw_error 
)

Validates that an FMCW waveform schedule can emit complete waveform periods.

Definition at line 150 of file fmcw_validation.cpp.

152 {
153 if (const auto* fmcw = wave.getFmcwChirpSignal(); fmcw != nullptr)
154 {
156 return;
157 }
158
159 const auto* triangle = wave.getFmcwTriangleSignal();
160 if (triangle == nullptr)
161 {
162 return;
163 }
164
165 const RealType T_tri = triangle->getTrianglePeriod();
166 for (const auto& period : effectiveSchedule(schedule))
167 {
168 const RealType duration = period.end - period.start;
169 if (duration < T_tri)
170 {
171 throw_error(std::format(
172 "{} has schedule period [{}, {}] duration {} s shorter than FMCW triangle_period T_tri={} s.",
173 owner, period.start, period.end, duration, T_tri));
174 }
175 const RealType full_triangles = std::floor(duration / T_tri);
177 const RealType leftover = duration - used;
178 if (leftover > 1.0e-12)
179 {
181 "{} has schedule period [{}, {}] that is not an integer multiple of FMCW triangle_period ({}s); "
182 "{}s will be silent after the last complete triangle.",
183 owner, period.start, period.end, T_tri, leftover);
184 }
185 }
186 }
void validateSchedule(const std::vector< radar::SchedulePeriod > &schedule, const fers_signal::FmcwChirpSignal &fmcw, const std::string &owner, const Thrower &throw_error)
Validates that an FMCW waveform schedule can emit complete chirps.

References LOG, max, validateSchedule(), and logging::WARNING.

+ Here is the call graph for this function:

◆ validateWaveform()

void serial::fmcw_validation::validateWaveform ( const fers_signal::RadarSignal wave,
const std::string &  owner,
const Thrower throw_error 
)

Validates that a waveform is compatible with FMCW streaming constraints.

Definition at line 89 of file fmcw_validation.cpp.

90 {
91 if (const auto* fmcw = wave.getFmcwChirpSignal(); fmcw != nullptr)
92 {
93 if (fmcw->getChirpPeriod() < fmcw->getChirpDuration())
94 {
95 throw_error(owner + " has chirp_period shorter than chirp_duration; FMCW requires T_rep >= T_c.");
96 }
97
98 const RealType sweep_start = fmcw->getStartFrequencyOffset();
99 const RealType sweep_end =
100 sweep_start + (fmcw->isDownChirp() ? -fmcw->getChirpBandwidth() : fmcw->getChirpBandwidth());
101 validateCommonSweep(wave, owner, fmcw->getChirpDuration(), fmcw->getChirpBandwidth(), sweep_start,
104 return;
105 }
106
107 if (const auto* triangle = wave.getFmcwTriangleSignal(); triangle != nullptr)
108 {
109 const RealType sweep_start = triangle->getStartFrequencyOffset();
110 const RealType sweep_end = sweep_start + triangle->getChirpBandwidth();
111 validateCommonSweep(wave, owner, triangle->getChirpDuration(), triangle->getChirpBandwidth(), sweep_start,
114 }
115 }

References max.

◆ validateWaveformModeMatch()

void serial::fmcw_validation::validateWaveformModeMatch ( const fers_signal::RadarSignal wave,
const radar::OperationMode  mode,
const std::string &  owner,
const Thrower throw_error 
)

Validates that a waveform and radar operation mode are compatible.

Definition at line 117 of file fmcw_validation.cpp.

119 {
120 const bool is_pulsed = !wave.isCw() && !wave.isFmcwFamily();
121 const bool matches = (mode == radar::OperationMode::PULSED_MODE && is_pulsed) ||
122 (mode == radar::OperationMode::CW_MODE && wave.isCw()) ||
123 (mode == radar::OperationMode::FMCW_MODE && wave.isFmcwFamily());
124 if (!matches)
125 {
126 throw_error(owner + " mode does not match waveform '" + wave.getName() + "'.");
127 }
128 }
@ PULSED_MODE
The component operates in a pulsed mode.
@ CW_MODE
The component operates in a continuous-wave mode.
@ FMCW_MODE
The component operates in an FMCW streaming mode.

References radar::CW_MODE, radar::FMCW_MODE, max, and radar::PULSED_MODE.