FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
radar Namespace Reference

Classes

class  FileTarget
 File-based radar target. More...
 
class  IsoTarget
 Isotropic radar target. More...
 
class  Object
 Represents a physical object in the radar system. More...
 
class  Platform
 Represents a simulation platform with motion and rotation paths. More...
 
class  Radar
 Represents a radar system on a platform. More...
 
class  RcsChiSquare
 Chi-square distributed RCS model. More...
 
class  RcsConst
 Constant RCS model. More...
 
class  RcsModel
 Base class for RCS fluctuation models. More...
 
class  Receiver
 Manages radar signal reception and response processing. More...
 
struct  SchedulePeriod
 Represents a time period during which the transmitter is active. More...
 
class  Target
 Base class for radar targets. More...
 
class  Transmitter
 Represents a radar transmitter system. More...
 

Enumerations

enum class  OperationMode : std::uint8_t { PULSED_MODE , CW_MODE , FMCW_MODE }
 Defines the operational mode of a radar component. More...
 

Functions

std::string_view dechirpModeToken (Receiver::DechirpMode mode) noexcept
 Converts a dechirp mode to its scenario token.
 
Receiver::DechirpMode parseDechirpModeToken (std::string_view token)
 Parses a dechirp mode scenario token.
 
std::string_view dechirpReferenceSourceToken (Receiver::DechirpReferenceSource source) noexcept
 Converts a dechirp reference source to its scenario token.
 
Receiver::DechirpReferenceSource parseDechirpReferenceSourceToken (std::string_view token)
 Parses a dechirp reference source scenario token.
 
std::vector< SchedulePeriodprocessRawSchedule (const std::vector< SchedulePeriod > &periods, const std::string &ownerName, bool isPulsed, RealType pri)
 Processes a raw list of schedule periods.
 
std::unique_ptr< TargetcreateIsoTarget (Platform *platform, std::string name, RealType rcs, unsigned seed, const SimId id=0)
 Creates an isotropic target.
 
std::unique_ptr< TargetcreateFileTarget (Platform *platform, std::string name, const std::string &filename, unsigned seed, const SimId id=0)
 Creates a file-based target.
 
void to_json (nlohmann::json &j, const SchedulePeriod &p)
 
void from_json (const nlohmann::json &j, SchedulePeriod &p)
 
void to_json (nlohmann::json &j, const Transmitter &t)
 
void to_json (nlohmann::json &j, const Receiver &r)
 
void to_json (nlohmann::json &j, const Target &t)
 
void to_json (nlohmann::json &j, const Platform &p)
 

Enumeration Type Documentation

◆ OperationMode

enum class radar::OperationMode : std::uint8_t
strong

Defines the operational mode of a radar component.

Enumerator
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.

Definition at line 38 of file radar_obj.h.

39 {
40 PULSED_MODE, ///< The component operates in a pulsed mode.
41 CW_MODE, ///< The component operates in a continuous-wave mode.
42 FMCW_MODE ///< The component operates in an FMCW streaming mode.
43 };
@ 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.

Function Documentation

◆ createFileTarget()

std::unique_ptr< Target > radar::createFileTarget ( Platform platform,
std::string  name,
const std::string &  filename,
unsigned  seed,
const SimId  id = 0 
)

Creates a file-based target.

Parameters
platformPointer to the platform associated with the target.
nameThe name of the target.
filenameThe name of the file containing RCS data.
seedThe seed for the target's internal random number generator.
Returns
A unique pointer to the newly created FileTarget.

Definition at line 297 of file target.h.

299 {
300 return std::make_unique<FileTarget>(platform, std::move(name), filename, seed, id);
301 }
math::Vec3 max

References max.

Referenced by serial::xml_parser_utils::createDefaultAssetLoaders(), and serial::update_target_from_json().

+ Here is the caller graph for this function:

◆ createIsoTarget()

std::unique_ptr< Target > radar::createIsoTarget ( Platform platform,
std::string  name,
RealType  rcs,
unsigned  seed,
const SimId  id = 0 
)

Creates an isotropic target.

Parameters
platformPointer to the platform associated with the target.
nameThe name of the target.
rcsThe constant RCS value for the target.
seedThe seed for the target's internal random number generator.
Returns
A unique pointer to the newly created IsoTarget.

Definition at line 282 of file target.h.

284 {
285 return std::make_unique<IsoTarget>(platform, std::move(name), rcs, seed, id);
286 }

References max.

Referenced by serial::xml_parser_utils::parseTarget(), and serial::update_target_from_json().

+ Here is the caller graph for this function:

◆ dechirpModeToken()

std::string_view radar::dechirpModeToken ( const Receiver::DechirpMode  mode)
noexcept

Converts a dechirp mode to its scenario token.

Definition at line 45 of file receiver.cpp.

46 {
47 switch (mode)
48 {
49 case Receiver::DechirpMode::Physical:
50 return "physical";
51 case Receiver::DechirpMode::Ideal:
52 return "ideal";
53 case Receiver::DechirpMode::None:
54 return "none";
55 }
56 return "none";
57 }

References radar::Receiver::Ideal, radar::Receiver::None, and radar::Receiver::Physical.

Referenced by serial::xml_serializer_utils::serializeReceiverFmcwMode().

+ Here is the caller graph for this function:

◆ dechirpReferenceSourceToken()

std::string_view radar::dechirpReferenceSourceToken ( const Receiver::DechirpReferenceSource  source)
noexcept

Converts a dechirp reference source to its scenario token.

Definition at line 76 of file receiver.cpp.

77 {
78 switch (source)
79 {
80 case Receiver::DechirpReferenceSource::Attached:
81 return "attached";
82 case Receiver::DechirpReferenceSource::Transmitter:
83 return "transmitter";
84 case Receiver::DechirpReferenceSource::Custom:
85 return "custom";
86 case Receiver::DechirpReferenceSource::None:
87 return "none";
88 }
89 return "none";
90 }

References radar::Receiver::Attached, radar::Receiver::Custom, radar::Receiver::None, and radar::Receiver::Transmitter.

Referenced by serial::xml_serializer_utils::serializeReceiverFmcwMode().

+ Here is the caller graph for this function:

◆ from_json()

void radar::from_json ( const nlohmann::json &  j,
SchedulePeriod p 
)

Definition at line 842 of file json_serializer.cpp.

843 {
844 j.at("start").get_to(p.start);
845 j.at("end").get_to(p.end);
846 }

References max.

◆ parseDechirpModeToken()

Receiver::DechirpMode radar::parseDechirpModeToken ( const std::string_view  token)

Parses a dechirp mode scenario token.

Definition at line 59 of file receiver.cpp.

60 {
61 if (token == "none")
62 {
63 return Receiver::DechirpMode::None;
64 }
65 if (token == "physical")
66 {
67 return Receiver::DechirpMode::Physical;
68 }
69 if (token == "ideal")
70 {
71 return Receiver::DechirpMode::Ideal;
72 }
73 throw std::runtime_error("Unsupported FMCW dechirp_mode '" + std::string(token) + "'.");
74 }

References radar::Receiver::Ideal, max, radar::Receiver::None, and radar::Receiver::Physical.

◆ parseDechirpReferenceSourceToken()

Receiver::DechirpReferenceSource radar::parseDechirpReferenceSourceToken ( const std::string_view  token)

Parses a dechirp reference source scenario token.

Definition at line 92 of file receiver.cpp.

93 {
94 if (token == "attached")
95 {
96 return Receiver::DechirpReferenceSource::Attached;
97 }
98 if (token == "transmitter")
99 {
100 return Receiver::DechirpReferenceSource::Transmitter;
101 }
102 if (token == "custom")
103 {
104 return Receiver::DechirpReferenceSource::Custom;
105 }
106 throw std::runtime_error("Unsupported dechirp_reference source '" + std::string(token) + "'.");
107 }

References radar::Receiver::Attached, radar::Receiver::Custom, max, and radar::Receiver::Transmitter.

◆ processRawSchedule()

std::vector< SchedulePeriod > radar::processRawSchedule ( const std::vector< SchedulePeriod > &  periods,
const std::string &  ownerName,
bool  isPulsed,
RealType  pri 
)

Processes a raw list of schedule periods.

This function performs the following operations:

  1. Filters invalid periods (start >= end).
  2. Filters periods completely outside simulation bounds.
  3. Sorts periods by start time.
  4. Merges overlapping or adjacent periods.
  5. Checks against PRI constraints (if pulsed).
Parameters
periodsThe raw vector of periods.
ownerNameThe name of the object owning this schedule (for logging).
isPulsedWhether the object is operating in pulsed mode.
priThe Pulse Repetition Interval (only used if isPulsed is true).
Returns
A sorted, merged, and validated vector of periods.

Definition at line 17 of file schedule_period.cpp.

20 {
21 if (periods.empty())
22 {
23 return {};
24 }
25
26 std::vector<SchedulePeriod> valid_periods;
27 valid_periods.reserve(periods.size());
28
31
32 // 1. Filter invalid and out-of-bounds periods
33 for (const auto& p : periods)
34 {
35 if (p.start >= p.end)
36 {
38 "Object '{}' has a schedule period with start ({}) >= end ({}). Ignoring period.", ownerName,
39 p.start, p.end);
40 continue;
41 }
42
43 if (p.end <= sim_start || p.start >= sim_end)
44 {
46 "Object '{}' has a schedule period [{}, {}] completely outside simulation time. Ignoring.",
47 ownerName, p.start, p.end);
48 continue;
49 }
50 valid_periods.push_back(p);
51 }
52
53 if (valid_periods.empty())
54 {
55 return {};
56 }
57
58 // 2. Sort by start time
59 std::ranges::sort(valid_periods, [](const auto& a, const auto& b) { return a.start < b.start; });
60
61 // 3. Merge overlapping intervals
62 std::vector<SchedulePeriod> merged;
63 merged.reserve(valid_periods.size());
64 merged.push_back(valid_periods.front());
65
66 for (size_t i = 1; i < valid_periods.size(); ++i)
67 {
68 if (valid_periods[i].start <= merged.back().end)
69 {
70 // Overlap or adjacency: extend the previous period
71 merged.back().end = std::max(merged.back().end, valid_periods[i].end);
72 }
73 else
74 {
75 merged.push_back(valid_periods[i]);
76 }
77 }
78
79 // 4. Check PRI constraints
80 if (isPulsed)
81 {
82 for (const auto& period : merged)
83 {
84 if (period.end - period.start < pri)
85 {
86 LOG(logging::Level::WARNING, "Object '{}' has a schedule period [{}, {}] shorter than PRI ({}s).",
87 ownerName, period.start, period.end, pri);
88 }
89 }
90 }
91
92 return merged;
93 }
double RealType
Type for real numbers.
Definition config.h:27
#define LOG(level,...)
Definition logging.h:19
@ WARNING
Warning level for potentially harmful situations.
RealType endTime() noexcept
Get the end time for the simulation.
Definition parameters.h:109
RealType startTime() noexcept
Get the start time for the simulation.
Definition parameters.h:103
RealType b
RealType a

References a, b, params::endTime(), LOG, max, params::startTime(), and logging::WARNING.

Referenced by serial::xml_parser_utils::parseSchedule(), serial::update_monostatic_schedule_from_json(), serial::update_receiver_schedule_from_json(), and serial::update_transmitter_schedule_from_json().

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

◆ to_json() [1/5]

void radar::to_json ( nlohmann::json &  j,
const Platform p 
)

Definition at line 937 of file json_serializer.cpp.

938 {
939 j = {{"id", sim_id_to_json(p.getId())}, {"name", p.getName()}, {"motionpath", *p.getMotionPath()}};
940
941 if (p.getRotationPath()->getType() == math::RotationPath::InterpType::INTERP_CONSTANT)
942 {
943 j["fixedrotation"] = *p.getRotationPath();
944 }
945 else
946 {
947 j["rotationpath"] = *p.getRotationPath();
948 }
949 }
@ INTERP_CONSTANT
Hold the most recent rotation sample.

References math::RotationPath::INTERP_CONSTANT, and max.

◆ to_json() [2/5]

void radar::to_json ( nlohmann::json &  j,
const Receiver r 
)

Definition at line 874 of file json_serializer.cpp.

875 {
876 j = nlohmann::json{{"id", sim_id_to_json(r.getId())},
877 {"name", r.getName()},
878 {"noise_temp", r.getNoiseTemperature()},
879 {"antenna", sim_id_to_json((r.getAntenna() != nullptr) ? r.getAntenna()->getId() : 0)},
880 {"timing", sim_id_to_json(r.getTiming() ? r.getTiming()->getId() : 0)},
881 {"nodirect", r.checkFlag(Receiver::RecvFlag::FLAG_NODIRECT)},
882 {"nopropagationloss", r.checkFlag(Receiver::RecvFlag::FLAG_NOPROPLOSS)}};
883
884 if (r.getMode() == OperationMode::PULSED_MODE)
885 {
886 j["pulsed_mode"] = {
887 {"prf", r.getWindowPrf()}, {"window_skip", r.getWindowSkip()}, {"window_length", r.getWindowLength()}};
888 }
889 else if (r.getMode() == OperationMode::FMCW_MODE)
890 {
891 j["fmcw_mode"] = receiver_fmcw_mode_to_json(r);
892 }
893 else
894 {
895 j["cw_mode"] = nlohmann::json::object();
896 }
897 if (!r.getSchedule().empty())
898 {
899 j["schedule"] = r.getSchedule();
900 }
901 }

References radar::Receiver::FLAG_NODIRECT, radar::Receiver::FLAG_NOPROPLOSS, FMCW_MODE, max, and PULSED_MODE.

◆ to_json() [3/5]

void radar::to_json ( nlohmann::json &  j,
const SchedulePeriod p 
)

Definition at line 837 of file json_serializer.cpp.

838 {
839 j = {{"start", p.start}, {"end", p.end}};
840 } // NOLINT(*-use-internal-linkage)

References max.

◆ to_json() [4/5]

void radar::to_json ( nlohmann::json &  j,
const Target t 
)

Definition at line 903 of file json_serializer.cpp.

904 {
905 j["id"] = sim_id_to_json(t.getId());
906 j["name"] = t.getName();
907 nlohmann::json rcs_json;
908 if (const auto* iso = dynamic_cast<const IsoTarget*>(&t))
909 {
910 rcs_json["type"] = "isotropic";
911 rcs_json["value"] = iso->getConstRcs();
912 }
913 else if (const auto* file = dynamic_cast<const FileTarget*>(&t))
914 {
915 rcs_json["type"] = "file";
916 rcs_json["filename"] = file->getFilename();
917 }
918 j["rcs"] = rcs_json;
919
920 // Serialize the fluctuation model if it exists.
921 if (const auto* model_base = t.getFluctuationModel())
922 {
923 nlohmann::json model_json;
924 if (const auto* chi_model = dynamic_cast<const RcsChiSquare*>(model_base))
925 {
926 model_json["type"] = "chisquare";
927 model_json["k"] = chi_model->getK();
928 }
929 else // Default to constant if it's not a recognized type (e.g., RcsConst)
930 {
931 model_json["type"] = "constant";
932 }
933 j["model"] = model_json;
934 }
935 }
Isotropic radar target.
Definition target.h:188
const std::string & getName() const noexcept
Retrieves the name of the object.
Definition object.h:79
SimId getId() const noexcept
Gets the unique ID of the target.
Definition target.h:153
const RcsModel * getFluctuationModel() const
Gets the RCS fluctuation model.
Definition target.h:167

References radar::Target::getFluctuationModel(), radar::Target::getId(), radar::Object::getName(), and max.

+ Here is the call graph for this function:

◆ to_json() [5/5]

void radar::to_json ( nlohmann::json &  j,
const Transmitter t 
)

Definition at line 848 of file json_serializer.cpp.

849 {
850 j = nlohmann::json{{"id", sim_id_to_json(t.getId())},
851 {"name", t.getName()},
852 {"waveform", sim_id_to_json((t.getSignal() != nullptr) ? t.getSignal()->getId() : 0)},
853 {"antenna", sim_id_to_json((t.getAntenna() != nullptr) ? t.getAntenna()->getId() : 0)},
854 {"timing", sim_id_to_json(t.getTiming() ? t.getTiming()->getId() : 0)}};
855
856 if (t.getMode() == OperationMode::PULSED_MODE)
857 {
858 j["pulsed_mode"] = {{"prf", t.getPrf()}};
859 }
860 else if (t.getMode() == OperationMode::FMCW_MODE)
861 {
862 j["fmcw_mode"] = nlohmann::json::object();
863 }
864 else
865 {
866 j["cw_mode"] = nlohmann::json::object();
867 }
868 if (!t.getSchedule().empty())
869 {
870 j["schedule"] = t.getSchedule();
871 }
872 }
SimId getId() const noexcept
Retrieves the unique ID of the antenna.
SimId getId() const noexcept
Gets the unique ID of the radar signal.
const antenna::Antenna * getAntenna() const noexcept
Gets the antenna associated with this radar.
Definition radar_obj.h:93
std::shared_ptr< timing::Timing > getTiming() const
Retrieves the timing source for the radar.
Definition radar_obj.cpp:66
SimId getId() const noexcept
Retrieves the unique ID of the transmitter.
Definition transmitter.h:88
RealType getPrf() const noexcept
Retrieves the pulse repetition frequency (PRF).
Definition transmitter.h:65
fers_signal::RadarSignal * getSignal() const noexcept
Retrieves the radar signal currently being transmitted.
Definition transmitter.h:72
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.
Definition transmitter.h:95

References FMCW_MODE, radar::Radar::getAntenna(), antenna::Antenna::getId(), radar::Transmitter::getId(), fers_signal::RadarSignal::getId(), radar::Transmitter::getMode(), radar::Object::getName(), radar::Transmitter::getPrf(), radar::Transmitter::getSchedule(), radar::Transmitter::getSignal(), radar::Radar::getTiming(), max, and PULSED_MODE.

+ Here is the call graph for this function: