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 28 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 182 of file fmcw_validation.cpp.

184 {
185 for (const auto& period : effectiveSchedule(schedule))
186 {
187 const RealType duration = period.end - period.start;
188 if (duration < fmcw.getChirpDuration())
189 {
190 throw_error(std::format(
191 "{} has schedule period [{}, {}] duration {} s shorter than FMCW chirp_duration T_c={} s.", owner,
192 period.start, period.end, duration, fmcw.getChirpDuration()));
193 }
194 if (duration < fmcw.getChirpPeriod())
195 {
196 LOG(logging::Level::WARNING, "{} has a schedule period [{}, {}] shorter than FMCW chirp_period ({}s).",
197 owner, period.start, period.end, fmcw.getChirpPeriod());
198 }
199 }
200 }
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 202 of file fmcw_validation.cpp.

204 {
205 if (const auto* fmcw = wave.getFmcwChirpSignal(); fmcw != nullptr)
206 {
208 return;
209 }
210
211 if (const auto* sfcw = wave.getSteppedFrequencySignal(); sfcw != nullptr)
212 {
213 for (const auto& period : effectiveSchedule(schedule))
214 {
215 const RealType duration = period.end - period.start;
216 if (duration < sfcw->getDwellTime())
217 {
218 LOG(logging::Level::WARNING, "{} has schedule period [{}, {}] shorter than one SFCW dwell ({}s).",
219 owner, period.start, period.end, sfcw->getDwellTime());
220 }
221 if (duration < sfcw->getSweepPeriod())
222 {
223 LOG(logging::Level::WARNING, "{} has schedule period [{}, {}] shorter than one SFCW sweep ({}s).",
224 owner, period.start, period.end, sfcw->getSweepPeriod());
225 }
226 }
227 return;
228 }
229
230 const auto* triangle = wave.getFmcwTriangleSignal();
231 if (triangle == nullptr)
232 {
233 return;
234 }
235
236 const RealType T_tri = triangle->getTrianglePeriod();
237 for (const auto& period : effectiveSchedule(schedule))
238 {
239 const RealType duration = period.end - period.start;
240 if (duration < T_tri)
241 {
242 throw_error(std::format(
243 "{} has schedule period [{}, {}] duration {} s shorter than FMCW triangle_period T_tri={} s.",
244 owner, period.start, period.end, duration, T_tri));
245 }
246 const RealType full_triangles = std::floor(duration / T_tri);
248 const RealType leftover = duration - used;
249 if (leftover > 1.0e-12)
250 {
252 "{} has schedule period [{}, {}] that is not an integer multiple of FMCW triangle_period ({}s); "
253 "{}s will be silent after the last complete triangle.",
254 owner, period.start, period.end, T_tri, leftover);
255 }
256 }
257 }
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 134 of file fmcw_validation.cpp.

135 {
136 if (const auto* fmcw = wave.getFmcwChirpSignal(); fmcw != nullptr)
137 {
138 if (fmcw->getChirpPeriod() < fmcw->getChirpDuration())
139 {
140 throw_error(owner + " has chirp_period shorter than chirp_duration; FMCW requires T_rep >= T_c.");
141 }
142
143 const RealType sweep_start = fmcw->getStartFrequencyOffset();
144 const RealType sweep_end =
145 sweep_start + (fmcw->isDownChirp() ? -fmcw->getChirpBandwidth() : fmcw->getChirpBandwidth());
146 validateCommonSweep(wave, owner, fmcw->getChirpDuration(), fmcw->getChirpBandwidth(), sweep_start,
148 warnStreamingMemory(owner, "FMCW");
149 return;
150 }
151
152 if (const auto* triangle = wave.getFmcwTriangleSignal(); triangle != nullptr)
153 {
154 const RealType sweep_start = triangle->getStartFrequencyOffset();
155 const RealType sweep_end = sweep_start + triangle->getChirpBandwidth();
156 validateCommonSweep(wave, owner, triangle->getChirpDuration(), triangle->getChirpBandwidth(), sweep_start,
158 warnStreamingMemory(owner, "FMCW");
159 return;
160 }
161
162 if (const auto* sfcw = wave.getSteppedFrequencySignal(); sfcw != nullptr)
163 {
165 }
166 }

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 168 of file fmcw_validation.cpp.

170 {
171 const bool is_pulsed = !wave.isCw() && !wave.isFmcwFamily() && !wave.isSteppedFrequency();
172 const bool matches = (mode == radar::OperationMode::PULSED_MODE && is_pulsed) ||
173 (mode == radar::OperationMode::CW_MODE && wave.isCw()) ||
174 (mode == radar::OperationMode::FMCW_MODE && wave.isFmcwFamily()) ||
175 (mode == radar::OperationMode::SFCW_MODE && wave.isSteppedFrequency());
176 if (!matches)
177 {
178 throw_error(owner + " mode does not match waveform '" + wave.getName() + "'.");
179 }
180 }
@ SFCW_MODE
The component operates in a stepped-frequency CW streaming mode.
@ 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, radar::PULSED_MODE, and radar::SFCW_MODE.