FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
radar::FileTarget Class Referencefinal

File-based radar target. More...

#include "target.h"

+ Inheritance diagram for radar::FileTarget:
+ Collaboration diagram for radar::FileTarget:

Public Member Functions

 FileTarget (Platform *platform, std::string name, const std::string &filename, unsigned seed, const SimId id=0)
 Constructs a file-based radar target.
 
RealType getRcs (math::SVec3 &inAngle, math::SVec3 &outAngle, RealType time) const override
 Gets the RCS value from file-based data for a specific bistatic geometry and time.
 
const std::string & getFilename () const noexcept
 Gets the filename associated with this target's RCS data.
 
std::mt19937 & getRngEngine () noexcept
 Gets the target's internal random number generator engine.
 
SimId getId () const noexcept
 Gets the unique ID of the target.
 
void setFluctuationModel (std::unique_ptr< RcsModel > in)
 Sets the RCS fluctuation model.
 
const RcsModelgetFluctuationModel () const
 Gets the RCS fluctuation model.
 
unsigned getSeed () const noexcept
 Gets the initial seed used for the target's RNG.
 
math::Vec3 getPosition (const RealType time) const
 Retrieves the position of the object.
 
math::SVec3 getRotation (const RealType time) const
 Retrieves the rotation of the object.
 
PlatformgetPlatform () const noexcept
 Retrieves the associated platform of the object.
 
const std::string & getName () const noexcept
 Retrieves the name of the object.
 
void setName (std::string name) noexcept
 Sets the name of the object.
 

Protected Attributes

std::unique_ptr< RcsModel_model {nullptr}
 The RCS fluctuation model for the target.
 
std::mt19937 _rng
 Per-object random number generator for statistical independence.
 
unsigned _seed
 The initial seed for the RNG.
 

Detailed Description

File-based radar target.

Definition at line 225 of file target.h.

Constructor & Destructor Documentation

◆ FileTarget()

radar::FileTarget::FileTarget ( Platform platform,
std::string  name,
const std::string &  filename,
unsigned  seed,
const SimId  id = 0 
)

Constructs a file-based radar 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.
Exceptions
std::runtime_errorIf the file cannot be loaded or parsed.

Definition at line 59 of file target.cpp.

60 :
61 Target(platform, std::move(name), seed, id), _azi_samples(std::make_unique_for_overwrite<interp::InterpSet>()),
62 _elev_samples(std::make_unique_for_overwrite<interp::InterpSet>()), _filename(filename)
63 {
64 XmlDocument doc;
65 if (!doc.loadFile(filename))
66 {
67 throw std::runtime_error("Could not load target description from " + filename);
68 }
69
70 const XmlElement root(doc.getRootElement());
71
72 loadTargetGainAxis(_elev_samples.get(), root.childElement("elevation", 0));
73 loadTargetGainAxis(_azi_samples.get(), root.childElement("azimuth", 0));
74 }
Class for managing XML documents.
XmlElement getRootElement() const
Get the root element of the document.
bool loadFile(std::string_view filename)
Load an XML file into the document.
Class representing a node in an XML document.
Target(Platform *platform, std::string name, const unsigned seed, const SimId id=0)
Constructs a radar target.
Definition target.h:127

References XmlElement::childElement(), XmlDocument::getRootElement(), and XmlDocument::loadFile().

+ Here is the call graph for this function:

Member Function Documentation

◆ getFilename()

const std::string & radar::FileTarget::getFilename ( ) const
noexcept

Gets the filename associated with this target's RCS data.

Returns
The source filename.

Definition at line 265 of file target.h.

265{ return _filename; }

◆ getFluctuationModel()

const RcsModel * radar::Target::getFluctuationModel ( ) const
inherited

Gets the RCS fluctuation model.

Returns
A const pointer to the RcsModel.

Definition at line 167 of file target.h.

167{ return _model.get(); }
std::unique_ptr< RcsModel > _model
The RCS fluctuation model for the target.
Definition target.h:177

References radar::Target::_model.

Referenced by serial::xml_serializer_utils::serializeTarget(), and radar::to_json().

+ Here is the caller graph for this function:

◆ getId()

SimId radar::Target::getId ( ) const
noexceptinherited

Gets the unique ID of the target.

Returns
The target SimId.

Definition at line 153 of file target.h.

153{ return Object::getId(); }
SimId getId() const noexcept
Retrieves the unique ID of the object.
Definition object.h:72

References radar::Object::getId().

Referenced by core::World::replace(), radar::to_json(), and serial::update_target_from_json().

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

◆ getName()

const std::string & radar::Object::getName ( ) const
noexceptinherited

◆ getPlatform()

Platform * radar::Object::getPlatform ( ) const
noexceptinherited

Retrieves the associated platform of the object.

Returns
A pointer to the Platform object associated with this object.

Definition at line 65 of file object.h.

65{ return _platform; }

Referenced by simulation::calculateDirectPathContribution(), simulation::calculateReflectedPathContribution(), simulation::calculateResponse(), and serial::update_target_from_json().

+ Here is the caller graph for this function:

◆ getPosition()

math::Vec3 radar::Object::getPosition ( const RealType  time) const
inherited

Retrieves the position of the object.

Parameters
timeThe time at which to get the position of the object.
Returns
A math::Vec3 representing the position of the object.

Definition at line 50 of file object.h.

50{ return _platform->getPosition(time); }
math::Vec3 getPosition(const RealType time) const
Gets the position of the platform at a specific time.
Definition platform.h:75

References radar::Platform::getPosition().

Referenced by simulation::calculatePreviewLinks(), simulation::solveRe(), and simulation::solveReDirect().

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

◆ getRcs()

RealType radar::FileTarget::getRcs ( math::SVec3 inAngle,
math::SVec3 outAngle,
RealType  time 
) const
overridevirtual

Gets the RCS value from file-based data for a specific bistatic geometry and time.

Parameters
inAngleThe incoming angle of the radar wave in the global frame.
outAngleThe outgoing angle of the reflected radar wave in the global frame.
timeThe simulation time at which the interaction occurs.
Returns
The Radar Cross Section (RCS) value in meters squared (m²).
Exceptions
std::runtime_errorIf RCS data cannot be retrieved.

This function calculates the target's aspect-dependent RCS. The key steps are:

  1. Calculate the bistatic angle bisector in the global simulation coordinate system.
  2. Retrieve the target's own orientation (rotation) at the specified 'time'.
  3. Transform the global bistatic angle into the target's local, body-fixed frame by subtracting the target's rotation. This is critical, as RCS patterns are defined relative to the target itself.
  4. Use this local aspect angle to look up the azimuthal and elevation RCS values from the loaded data.

NOTE: This function returns the raw RCS value (σ), which is linearly proportional to scattered power. The calling physics engine is responsible for converting this to a signal amplitude by taking the square root.

Implements radar::Target.

Definition at line 76 of file target.cpp.

77 {
78 // TODO: the handling of arbitrary rcs models needs to be validated and expanded to cover edge cases.
79 // 1. Calculate the bistatic angle bisector in the GLOBAL frame.
80 const SVec3 global_bisector_angle = inAngle + outAngle;
81
82 // 2. Get the target's own rotation at the current time.
83 const SVec3 target_rotation = getRotation(time);
84
85 // 3. Transform the global angle into the target's LOCAL frame for lookup.
86 const SVec3 local_aspect_angle = global_bisector_angle - target_rotation;
87
88 // 4. Use the local aspect angle (bisector is halved) to look up RCS.
89 const auto azi_value = _azi_samples->getValueAt(local_aspect_angle.azimuth / 2.0);
90
91 if (const auto elev_value = _elev_samples->getValueAt(local_aspect_angle.elevation / 2.0);
92 azi_value && elev_value)
93 {
94 // Return the raw RCS value (proportional to power), not its square root.
95 const RealType rcs = *azi_value * *elev_value;
96 return _model ? rcs * _model->sampleModel() : rcs;
97 }
98
99 LOG(logging::Level::FATAL, "Could not get RCS value for target");
100 throw std::runtime_error("Could not get RCS value for target");
101 }
A class representing a vector in spherical coordinates.
RealType elevation
The elevation angle of the vector.
RealType azimuth
The azimuth angle of the vector.
math::SVec3 getRotation(const RealType time) const
Retrieves the rotation of the object.
Definition object.h:58
double RealType
Type for real numbers.
Definition config.h:27
#define LOG(level,...)
Definition logging.h:19
@ FATAL
Fatal level for severe error events.

References radar::Target::_model, math::SVec3::azimuth, math::SVec3::elevation, logging::FATAL, radar::Object::getRotation(), and LOG.

+ Here is the call graph for this function:

◆ getRngEngine()

std::mt19937 & radar::Target::getRngEngine ( )
noexceptinherited

Gets the target's internal random number generator engine.

Returns
A mutable reference to the RNG engine.

Definition at line 146 of file target.h.

146{ return _rng; }
std::mt19937 _rng
Per-object random number generator for statistical independence.
Definition target.h:178

References radar::Target::_rng.

◆ getRotation()

math::SVec3 radar::Object::getRotation ( const RealType  time) const
inherited

Retrieves the rotation of the object.

Parameters
timeThe time at which to get the rotation of the object.
Returns
A math::SVec3 representing the rotation of the object.

Definition at line 58 of file object.h.

58{ return _platform->getRotation(time); }
math::SVec3 getRotation(const RealType time) const
Gets the rotation of the platform at a specific time.
Definition platform.h:83

References radar::Platform::getRotation().

Referenced by getRcs(), and processing::runPulsedFinalizer().

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

◆ getSeed()

unsigned radar::Target::getSeed ( ) const
noexceptinherited

Gets the initial seed used for the target's RNG.

Returns
The initial seed value.

Definition at line 174 of file target.h.

174{ return _seed; }
unsigned _seed
The initial seed for the RNG.
Definition target.h:179

References radar::Target::_seed.

Referenced by serial::update_target_from_json().

+ Here is the caller graph for this function:

◆ setFluctuationModel()

void radar::Target::setFluctuationModel ( std::unique_ptr< RcsModel in)
inherited

Sets the RCS fluctuation model.

Assigns a new RCS fluctuation model to the target.

Parameters
inUnique pointer to the new RCS fluctuation model.

Definition at line 161 of file target.h.

161{ _model = std::move(in); }

References radar::Target::_model.

◆ setName()

void radar::Object::setName ( std::string  name)
noexceptinherited

Sets the name of the object.

Parameters
nameThe new name for the object.

Definition at line 86 of file object.h.

86{ _name = std::move(name); }

Referenced by serial::update_monostatic_from_json(), serial::update_receiver_from_json(), and serial::update_transmitter_from_json().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _model

std::unique_ptr<RcsModel> radar::Target::_model {nullptr}
protectedinherited

The RCS fluctuation model for the target.

Definition at line 177 of file target.h.

177{nullptr}; ///< The RCS fluctuation model for the target.

Referenced by radar::Target::getFluctuationModel(), getRcs(), and radar::Target::setFluctuationModel().

◆ _rng

std::mt19937 radar::Target::_rng
protectedinherited

Per-object random number generator for statistical independence.

Definition at line 178 of file target.h.

Referenced by radar::Target::getRngEngine().

◆ _seed

unsigned radar::Target::_seed
protectedinherited

The initial seed for the RNG.

Definition at line 179 of file target.h.

Referenced by radar::Target::getSeed().


The documentation for this class was generated from the following files: