43 void addChildWithText(
const XmlElement& parent,
const std::string& name,
const std::string& text)
49 void addChildWithNumber(
const XmlElement& parent,
const std::string& name, T value)
51 if constexpr (std::is_floating_point_v<T>)
57 std::array<char, 64> buffer{};
58 if (
auto [ptr, ec] = std::to_chars(buffer.data(), buffer.data() + buffer.size(), value); ec == std::errc())
60 addChildWithText(parent, name, std::string(buffer.data(), ptr - buffer.data()));
66 ss << std::setprecision(std::numeric_limits<T>::max_digits10) << value;
67 addChildWithText(parent, name, ss.str());
73 addChildWithText(parent, name, std::to_string(value));
77 void setAttributeFromBool(
const XmlElement& element,
const std::string& name,
const bool value)
84 void serializeSchedule(
const std::vector<radar::SchedulePeriod>& schedule,
const XmlElement& parent)
91 for (
const auto& period : schedule)
94 p_elem.
setAttribute(
"start", std::to_string(period.start));
99 void serializeParameters(
const XmlElement& parent)
107 addChildWithNumber(parent,
"c",
params::c());
115 addChildWithNumber(parent,
"randomseed", *
params::params.random_seed);
152 addChildWithNumber(parent,
"power", waveform.
getPower());
153 addChildWithNumber(parent,
"carrier_frequency", waveform.
getCarrier());
166 pulsed_file.
setAttribute(
"filename", filename.value_or(
""));
173 setAttributeFromBool(parent,
"synconpulse",
timing.getSyncOnPulse());
175 addChildWithNumber(parent,
"frequency",
timing.getFrequency());
176 if (
const auto val =
timing.getFreqOffset())
178 addChildWithNumber(parent,
"freq_offset", *val);
180 if (
const auto val =
timing.getRandomFreqOffsetStdev())
182 addChildWithNumber(parent,
"random_freq_offset_stdev", *val);
184 if (
const auto val =
timing.getPhaseOffset())
186 addChildWithNumber(parent,
"phase_offset", *val);
188 if (
const auto val =
timing.getRandomPhaseOffsetStdev())
190 addChildWithNumber(parent,
"random_phase_offset_stdev", *val);
193 std::vector<RealType> alphas, weights;
194 timing.copyAlphas(alphas, weights);
195 for (
size_t i = 0; i < alphas.size(); ++i)
198 addChildWithNumber(entry,
"alpha", alphas[i]);
199 addChildWithNumber(entry,
"weight", weights[i]);
210 addChildWithNumber(parent,
"alpha", sinc->getAlpha());
211 addChildWithNumber(parent,
"beta", sinc->getBeta());
212 addChildWithNumber(parent,
"gamma", sinc->getGamma());
217 addChildWithNumber(parent,
"azscale", gaussian->getAzimuthScale());
218 addChildWithNumber(parent,
"elscale", gaussian->getElevationScale());
223 addChildWithNumber(parent,
"diameter", sh->getDimension());
228 addChildWithNumber(parent,
"diameter", parabolic->getDiameter());
233 parent.
setAttribute(
"filename", xml_ant->getFilename());
245 if (
antenna.getEfficiencyFactor() != 1.0)
247 addChildWithNumber(parent,
"efficiency",
antenna.getEfficiencyFactor());
266 for (
const auto& [pos, t] : path.getCoords())
269 addChildWithNumber(wp_elem,
"x", pos.x);
270 addChildWithNumber(wp_elem,
"y", pos.y);
271 addChildWithNumber(wp_elem,
"altitude", pos.z);
272 addChildWithNumber(wp_elem,
"time", t);
281 const auto start = rotPath.
getStart();
288 const RealType start_az_deg = std::fmod(90.0 - start.azimuth * 180.0 /
PI + 360.0, 360.0);
289 const RealType start_el_deg = start.elevation * 180.0 /
PI;
293 addChildWithNumber(fixed_elem,
"startazimuth", start_az_deg);
294 addChildWithNumber(fixed_elem,
"startelevation", start_el_deg);
295 addChildWithNumber(fixed_elem,
"azimuthrate", rate_az_deg_s);
296 addChildWithNumber(fixed_elem,
"elevationrate", rate_el_deg_s);
315 for (
const auto& wp : rotPath.getCoords())
320 const RealType az_deg = std::fmod(90.0 - wp.azimuth * 180.0 /
PI + 360.0, 360.0);
321 const RealType el_deg = wp.elevation * 180.0 /
PI;
322 addChildWithNumber(wp_elem,
"azimuth", az_deg);
323 addChildWithNumber(wp_elem,
"elevation", el_deg);
324 addChildWithNumber(wp_elem,
"time", wp.t);
340 addChildWithNumber(mode_elem,
"prf", tx.
getPrf());
362 addChildWithNumber(mode_elem,
"prf", rx.
getWindowPrf());
363 addChildWithNumber(mode_elem,
"window_skip", rx.
getWindowSkip());
392 addChildWithNumber(mode_elem,
"prf", tx.
getPrf());
393 addChildWithNumber(mode_elem,
"window_skip", rx.
getWindowSkip());
398 (void)mono_elem.
addChild(
"cw_mode");
418 addChildWithNumber(rcs_elem,
"value", iso->getConstRcs());
420 else if (
const auto* file_target =
dynamic_cast<const radar::FileTarget*
>(&target))
423 rcs_elem.
setAttribute(
"filename", file_target->getFilename());
433 addChildWithNumber(model_elem,
"k", chi->getK());
448 for (
const auto& tx : world.getTransmitters())
460 serializeTransmitter(*tx, parent);
466 for (
const auto& rx : world.getReceivers())
472 serializeReceiver(*rx, parent);
477 for (
const auto& target : world.getTargets())
481 serializeTarget(*target, parent);
492 xmlNodePtr sim_node = xmlNewNode(
nullptr,
reinterpret_cast<const xmlChar*
>(
"simulation"));
506 serializeParameters(params_elem);
512 for (
const auto& waveform : world.
getWaveforms() | std::views::values)
515 serializeWaveform(*waveform, waveform_elem);
520 serializeTiming(*
timing, timing_elem);
525 serializeAntenna(*
antenna, antenna_elem);
530 serializePlatform(*platform, world, plat_elem);
Header file defining various types of antennas and their gain patterns.
Class for managing XML documents.
void setRootElement(const XmlElement &root) const
Set the root element of the document.
std::string dumpToString() const
Dumps the document to a string.
Class representing a node in an XML document.
XmlElement addChild(const std::string_view name) const noexcept
Add a child element to the current node.
void setAttribute(const std::string_view name, const std::string_view value) const
Set an attribute on the XML element.
void setText(const std::string_view text) const
Set the text content of the XML element.
Abstract base class representing an antenna.
std::string getName() const noexcept
Retrieves the name of the antenna.
Represents a Gaussian-shaped antenna gain pattern.
Represents an antenna whose gain pattern is loaded from a HDF5 file.
Represents a parabolic reflector antenna.
Represents a sinc function-based antenna gain pattern.
Represents a square horn antenna.
Represents an antenna whose gain pattern is defined by an XML file.
The World class manages the simulator environment.
const std::unordered_map< std::string, std::unique_ptr< fers_signal::RadarSignal > > & getWaveforms() const noexcept
Retrieves the map of radar signals (waveforms).
const std::vector< std::unique_ptr< radar::Platform > > & getPlatforms() const noexcept
Retrieves the list of platforms.
const std::unordered_map< std::string, std::unique_ptr< timing::PrototypeTiming > > & getTimings() const noexcept
Retrieves the map of timing prototypes.
const std::unordered_map< std::string, std::unique_ptr< antenna::Antenna > > & getAntennas() const noexcept
Retrieves the map of antennas.
Class representing a radar signal with associated properties.
const std::optional< std::string > & getFilename() const noexcept
Gets the filename associated with this signal.
const std::string & getName() const noexcept
Gets the name of the radar signal.
RealType getCarrier() const noexcept
Gets the carrier frequency of the radar signal.
const Signal * getSignal() const noexcept
Gets the underlying signal object.
RealType getPower() const noexcept
Gets the power of the radar signal.
Represents a path with coordinates and allows for various interpolation methods.
InterpType getType() const noexcept
Retrieves the current interpolation type of the path.
Manages rotational paths with different interpolation techniques.
InterpType getType() const noexcept
Gets the interpolation type of the path.
RotationCoord getRate() const noexcept
Gets the rate of change for the rotation.
RotationCoord getStart() const noexcept
Gets the starting rotation coordinate.
const std::string & getName() const noexcept
Retrieves the name of the object.
Platform * getPlatform() const noexcept
Retrieves the associated platform of the object.
const Radar * getAttached() const noexcept
Retrieves the attached radar object.
const antenna::Antenna * getAntenna() const noexcept
Gets the antenna associated with this radar.
std::shared_ptr< timing::Timing > getTiming() const
Retrieves the timing source for the radar.
Chi-square distributed RCS model.
Manages radar signal reception and response processing.
bool checkFlag(RecvFlag flag) const noexcept
Checks if a specific flag is set.
const std::vector< SchedulePeriod > & getSchedule() const noexcept
Retrieves the list of active reception periods.
RealType getNoiseTemperature() const noexcept
Retrieves the noise temperature of the receiver.
OperationMode getMode() const noexcept
Gets the operational mode of the receiver.
RealType getWindowPrf() const noexcept
Retrieves the pulse repetition frequency (PRF) of the radar window.
RealType getWindowSkip() const noexcept
Retrieves the window skip time.
RealType getWindowLength() const noexcept
Retrieves the radar window length.
Base class for radar targets.
const RcsModel * getFluctuationModel() const
Gets the RCS fluctuation model.
Represents a radar transmitter system.
RealType getPrf() const noexcept
Retrieves the pulse repetition frequency (PRF).
fers_signal::RadarSignal * getSignal() const noexcept
Retrieves the radar signal currently being transmitted.
const std::vector< SchedulePeriod > & getSchedule() const noexcept
Retrieves the list of active transmission periods.
OperationMode getMode() const noexcept
Gets the operational mode of the transmitter.
Manages timing properties such as frequency, offsets, and synchronization.
Global configuration file for the project.
double RealType
Type for real numbers.
constexpr RealType PI
Mathematical constant π (pi).
Coordinate and rotation structure operations.
Wrapper for managing XML documents and elements using libxml2.
RealType simSamplingRate() noexcept
Get the simulation sampling rate.
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.
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
double originLongitude() noexcept
@ 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
double originLatitude() noexcept
bool utmNorthHemisphere() noexcept
RealType c() noexcept
Get the speed of light.
double originAltitude() noexcept
@ PULSED_MODE
The component operates in a pulsed mode.
std::string world_to_xml_string(const core::World &world)
Serializes the entire simulation world into an XML formatted string.
Defines the Parameters struct and provides methods for managing simulation parameters.
Provides the definition and functionality of the Path class for handling coordinate-based paths with ...
Header file for the PrototypeTiming class.
Classes for handling radar waveforms and signals.
Radar Receiver class for managing signal reception and response handling.
Defines the RotationPath class for handling rotational paths with different interpolation types.
static constexpr RealType DEFAULT_C
Speed of light (m/s)
Defines classes for radar targets and their Radar Cross-Section (RCS) models.
Timing source for simulation objects.
Header file for the Transmitter class in the radar namespace.
Header file for the World class in the simulator.
Provides functions to serialize the simulation world back into the FERS XML format.