49 ? std::optional<std::uint64_t>(
static_cast<std::uint64_t
>(*source.
triangle_count))
60 .chirp_direction = source.
fmcw !=
nullptr
65 ? std::optional<std::uint64_t>(
static_cast<std::uint64_t
>(*source.
chirp_count))
89 std::vector<core::FmcwSourceMetadata>::iterator
findFmcwSource(std::vector<core::FmcwSourceMetadata>&
sources,
90 const SimId transmitter_id,
91 const SimId waveform_id)
93 return std::ranges::find_if(
99 std::vector<core::FmcwSourceMetadata>
102 std::vector<core::FmcwSourceMetadata> fmcw_sources;
117 const auto waveform_id =
signal->getId();
123 .waveform_id = waveform_id,
124 .waveform_name =
signal->getName(),
125 .carrier_frequency =
signal->getCarrier(),
128 fmcw_sources.push_back(std::move(source));
152 segment.emitted_triangle_count = emitted;
162 segment.emitted_chirp_count = emitted;
169 using TimeSpan = std::pair<RealType, RealType>;
175 std::vector<TimeSpan>
merged;
195 std::vector<TimeSpan>
spans;
196 if (
receiver->getSchedule().empty())
208 spans.emplace_back(start, end);
216 std::vector<TimeSpan>&
output)
233 :
static_cast<std::size_t
>(
264 std::vector<TimeSpan>
spans;
268 for (
const auto& source :
receiver->getDechirpSources())
281 const auto start_sample =
static_cast<std::uint64_t
>(std::min<RealType>(
282 static_cast<RealType>(total_samples),
284 const auto end_sample =
static_cast<std::uint64_t
>(std::min<RealType>(
285 static_cast<RealType>(total_samples),
290 .end_time = end_time,
376 ?
if_plan->input_sample_rate_hz /
if_plan->actual_output_sample_rate_hz
407 if (!
receiver->getDechirpSources().empty())
417 const std::size_t total_samples,
422 .receiver_name =
receiver->getName(),
427 .total_samples =
static_cast<std::uint64_t
>(total_samples),
429 .sample_end_exclusive =
static_cast<std::uint64_t
>(total_samples)};
535 return &
receiver->getDechirpSources().front();
645 if (source ==
nullptr)
683 .receiver_name =
receiver->getName(),
685 .sample_rate = sample_rate,
686 .bandwidth = sample_rate > 0.0 ? sample_rate / 2.0 : 0.0,
687 .dechirped =
receiver->isDechirpEnabled(),
688 .if_resampled =
receiver->getFmcwIfResamplerPlan().has_value(),
697 descriptor.reference_frequency =
timing->getFrequency();
704 const std::span<const ComplexType> samples,
705 const std::uint64_t sample_start,
706 std::shared_ptr<const core::OutputFileMetadata> file_metadata)
709 std::span<const core::ActiveStreamingSource>{}, std::move(file_metadata));
714 const RealType sample_rate,
const std::span<const ComplexType> samples,
715 const std::uint64_t sample_start,
717 std::shared_ptr<const core::OutputFileMetadata> file_metadata)
721 .first_sample_time = first_sample_time,
724 .sample_start = sample_start,
726 .calibrated_time =
true,
727 .reference_lock =
true,
728 .file_metadata = std::move(file_metadata)};
732 const std::shared_ptr<core::ProgressReporter>&
reporter,
const std::string& output_dir,
733 const std::shared_ptr<core::OutputMetadataCollector>& metadata_collector,
737 (
void)metadata_collector;
740 throw std::invalid_argument(
"runPulsedFinalizer requires a receiver output sink");
755 unsigned chunk_index = 0;
774 const auto window_samples =
static_cast<unsigned>(std::ceil(
job.duration * rate));
817 const auto now = std::chrono::steady_clock::now();
820 reporter->report(std::format(
"Exporting {}: Chunk {}",
receiver->getName(), chunk_index),
821 static_cast<int>(chunk_index), 0);
834 reporter->report(std::format(
"Finished Exporting {}",
receiver->getName()), 100, 100);
const Transmitter & transmitter
const Receiver & receiver
RealType getChirpBandwidth() const noexcept
Gets the chirp bandwidth in hertz.
FmcwChirpDirection getDirection() const noexcept
Gets the FMCW sweep direction.
RealType getChirpBandwidth() const noexcept
Gets the chirp bandwidth in hertz.
Class representing a radar signal with associated properties.
RealType x
The x component of the vector.
RealType z
The z component of the vector.
RealType y
The y component of the vector.
Manages radar signal reception and response processing.
@ Transmitter
Use a named transmitter.
@ Attached
Use the attached transmitter.
@ Custom
Use a named top-level waveform with the receiver schedule.
Represents a radar transmitter system.
double RealType
Type for real numbers.
Declares the functions for the asynchronous receiver finalization pipelines.
Declares focused, testable pipeline steps for receiver finalization.
Header file for the logging system.
std::uint64_t countFmcwTriangleStarts(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Counts FMCW triangles that start inside the absolute interval.
std::uint64_t countFmcwChirpStarts(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Counts FMCW chirps that start inside the absolute interval.
std::optional< RealType > firstFmcwTriangleStart(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Returns the first FMCW triangle start inside the absolute interval, if one exists.
std::optional< RealType > firstFmcwChirpStart(const ActiveStreamingSource &source, const RealType active_start, const RealType active_end)
Returns the first FMCW chirp start inside the absolute interval, if one exists.
std::string_view fmcwChirpDirectionToken(const FmcwChirpDirection direction) noexcept
Converts a chirp direction to the schema token.
@ FATAL
Fatal level for severe error events.
@ INFO
Info level for informational messages.
RealType endTime() noexcept
Get the end time for the simulation.
RealType rate() noexcept
Get the rendering sample rate.
RealType startTime() noexcept
Get the start time for the simulation.
RealType boltzmannK() noexcept
Get the Boltzmann constant.
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
double originLongitude() noexcept
Gets the KML/geospatial export origin longitude.
int utmZone() noexcept
Gets the configured KML UTM zone.
CoordinateFrame
Defines the coordinate systems supported for KML/geospatial export.
@ UTM
Universal Transverse Mercator.
@ ENU
East-North-Up local tangent plane (default)
@ ECEF
Earth-Centered, Earth-Fixed.
unsigned adcBits() noexcept
Get the ADC quantization bits.
CoordinateFrame coordinateFrame() noexcept
Gets the KML/geospatial export coordinate frame.
double originLatitude() noexcept
Gets the KML/geospatial export origin latitude.
bool utmNorthHemisphere() noexcept
Gets the configured KML UTM hemisphere.
double originAltitude() noexcept
Gets the KML/geospatial export origin altitude.
void applyStreamingInterference(std::span< ComplexType > window, const RealType actual_start, const RealType dt, const radar::Receiver *receiver, const std::vector< core::ActiveStreamingSource > &streaming_sources, const std::vector< std::unique_ptr< radar::Target > > *targets, core::ReceiverTrackerCache &tracker_cache, const simulation::CwPhaseNoiseLookup *phase_noise_lookup)
Applies streaming interference to a time window.
void addPhaseNoiseToWindow(std::span< const RealType > noise, std::span< ComplexType > window)
Applies a pre-generated sequence of phase noise samples to an I/Q buffer.
void advanceTimingModel(timing::Timing *timing_model, const radar::Receiver *receiver, const RealType rate)
Advances the receiver's timing model to the start of the next processing window.
std::tuple< RealType, RealType > calculateJitteredStart(const RealType ideal_start, const RealType first_phase_noise, const RealType carrier_freq, const RealType rate)
Calculates the jittered start time and fractional delay from a phase noise sample.
void applyDownsampling(std::vector< ComplexType > &buffer)
Downsamples an IQ buffer to the configured output rate without quantization.
core::ReceiverSampleBlock buildReceiverSampleBlock(const radar::Receiver *receiver, const RealType first_sample_time, const RealType sample_rate, const std::span< const ComplexType > samples, const std::uint64_t sample_start, std::shared_ptr< const core::OutputFileMetadata > file_metadata)
Builds a non-owning output sample block over contiguous processed complex samples.
void runPulsedFinalizer(radar::Receiver *receiver, const std::vector< std::unique_ptr< radar::Target > > *targets, const std::shared_ptr< core::ProgressReporter > &reporter, const std::string &output_dir, const std::shared_ptr< core::OutputMetadataCollector > &metadata_collector, core::ReceiverOutputSink *output_sink)
The main function for a dedicated pulsed-mode receiver finalizer thread.
core::OutputFileMetadata buildStreamingOutputMetadata(const radar::Receiver *receiver, const std::string &output_path, const std::size_t total_samples, const std::vector< core::ActiveStreamingSource > &streaming_sources, const RealType output_sample_rate)
Builds HDF5 file metadata for a streaming receiver result emitted through the output sink.
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.
core::ReceiverStreamDescriptor buildReceiverStreamDescriptor(const radar::Receiver *receiver, const RealType sample_rate, const std::span< const core::ActiveStreamingSource > streaming_sources)
Builds the receiver stream descriptor used by output sinks.
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.
std::string_view dechirpReferenceSourceToken(const Receiver::DechirpReferenceSource source) noexcept
Converts a dechirp reference source to its scenario token.
@ 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.
std::string_view dechirpModeToken(const Receiver::DechirpMode mode) noexcept
Converts a dechirp mode to its scenario token.
Defines the Parameters struct and provides methods for managing simulation parameters.
Classes for handling radar waveforms and signals.
Radar Receiver class for managing signal reception and response handling.
Defines the data packet for asynchronous receiver finalization.
Header for receiver-side signal processing and rendering.
uint64_t SimId
64-bit Unique Simulation ID.
Header file for the main simulation runner.
Cached description of an active streaming transmitter segment.
RealType triangle_period
Cached full triangle period in seconds.
RealType segment_start
Segment start time in seconds.
RealType signed_chirp_rate
Cached signed FMCW chirp rate in hertz per second.
RealType chirp_duration
Cached FMCW chirp duration in seconds.
RealType chirp_period
Cached FMCW chirp period in seconds.
StreamingWaveformKind kind
Cached streaming waveform shape.
const fers_signal::FmcwChirpSignal * fmcw
Stable pointer to the linear FMCW waveform, if any.
bool is_fmcw
Compatibility flag for any FMCW source.
std::optional< std::size_t > chirp_count
Optional finite chirp count for the segment.
std::optional< std::size_t > triangle_count
Optional finite triangle count for the segment.
RealType segment_end
Segment end time in seconds.
const fers_signal::FmcwTriangleSignal * triangle
Stable pointer to the triangle waveform, if any.
RealType chirp_rate
Cached FMCW chirp rate in hertz per second.
RealType start_freq_off
Cached FMCW start frequency offset in hertz.
ReceiverStreamDescriptor stream
RealType carrier_frequency
std::string dechirp_reference_source
std::optional< std::uint64_t > chirp_count
std::optional< std::uint64_t > triangle_count
SimId dechirp_reference_transmitter_id
std::string dechirp_reference_waveform_name
std::string waveform_shape
std::optional< RealType > triangle_period
std::string sweep_direction
RealType chirp_rate_signed
RealType start_frequency_offset
SimId dechirp_reference_waveform_id
std::string dechirp_reference_transmitter_name
std::string waveform_name
RealType carrier_frequency
std::uint64_t window_count
std::uint64_t native_sample_count
RealType native_sample_rate
Per-receiver FMCW tracker state for direct and reflected streaming paths.
A data packet containing all information needed to process one receive window.
Timing source for simulation objects.
Header file for the Transmitter class in the radar namespace.