VR-Engage  2.2
Loading...
Searching...
No Matches
vreSimpleRadarObjectSensor.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreSimpleRadarObjectSensor.h
7//! \ingroup vreVrfmodel
8//! \brief Sensor for radar detection with target tracking capabilities
9//!
10//! This file defines the DtVreSimpleRadarObjectSensor class which extends
11//! DtVreRadarObjectSensor to provide target tracking and designation capabilities
12//! for air targets. It supports both TWS (Track While Scan) and STT (Single Target Track)
13//! modes and manages prioritized target lists.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
20#include <unordered_map>
21
23
24namespace makVre
25{
26
27//! \brief Type identifier for the VRE simple radar object sensor component
28const char DtVreSimpleRadarObjectSensorType[] = "vre-simple-radar-object-sensor";
29
30//! \brief Sensor for radar detection with target tracking and designation capabilities
31//!
32//! DtVreSimpleRadarObjectSensor extends the base radar object sensor to provide
33//! target tracking and designation capabilities specifically for air targets. It
34//! manages the radar antenna state for tracking, supports different radar modes
35//! (TWS - Track While Scan and STT - Single Target Track), and maintains prioritized
36//! lists of designated targets.
37//!
38//! The sensor provides information about detected targets including their position,
39//! velocity, and classification, and supports selecting specific targets for tracking
40//! and weapons guidance.
42{
43private:
44 //! \brief Default constructor (not implemented)
45 //!
46 //! Default constructor is private and not implemented to prevent
47 //! creation of instances without proper initialization.
49
50 //! \brief Copy constructor (not implemented)
51 //!
52 //! Copy constructor is private and not implemented to prevent
53 //! copy construction.
55
56 //! \brief Assignment operator (not implemented)
57 //! \return Reference to this object
58 //!
59 //! Assignment operator is private and not implemented to prevent assignment.
61
62public:
63 // using DtSignatureObjectSensor::tick;
64
65 //! \brief Constructor
66 //! \param name The name of this component
67 //! \param owner The local object that owns this component
68 //! \param simManager The simulation services manager
69 //! \param desc Component descriptor with configuration parameters
70 //! \param parentRegistry Optional parent registry for reader/writer functionality
71 //!
72 //! Creates a new simple radar object sensor component with the specified parameters.
73 DtVreSimpleRadarObjectSensor(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
74 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
75
76 //! \brief Virtual destructor
77 //!
78 //! Cleans up resources used by the simple radar object sensor component.
80
81 //! \brief Initializes the radar sensor component
82 //! \return True if initialization is successful, false otherwise
83 //!
84 //! Performs component initialization, including setting up the radar sensor
85 //! parameters and process state repository. Called during component creation.
86 virtual bool init() override;
87
88 //! \brief Gets the type identifier for this component
89 //! \return String identifying the component type (DtVreSimpleRadarObjectSensorType)
90 //!
91 //! Implements the DtSimComponent::type() method to return the
92 //! type identifier for this component.
93 virtual const char* type() const override;
94
95 //! \brief Updates the radar sensor state each simulation frame
96 //!
97 //! Updates the antenna state for target tracking and calls the base class
98 //! tick method to process standard radar operations. Manages target tracking,
99 //! designation, and updates radar contact information based on current
100 //! sensor mode and detected objects.
101 virtual void tick() override;
102
103 //! \brief Determines if an object should be detected by the radar
104 //! \param object Reference to the object being evaluated for detection
105 //! \param contactInfo Output parameter to receive contact information if detected
106 //! \return True if the object is detected, false otherwise
107 //!
108 //! Evaluates whether the specified object should be detected by the radar sensor
109 //! based on range, radar cross-section, and other factors. If detected, populates
110 //! the contactInfo parameter with information about the contact.
111 virtual bool detectObject(DtSimObjectReference object, DtRwSensorContactInfo* contactInfo) override;
112
113 //! \brief Determines if an already detected object should remain detected
114 //! \param object Reference to the previously detected object
115 //! \param contactInfo Output parameter with contact information to update
116 //! \param contactInfoModified Output parameter indicating if contactInfo was modified
117 //! \return Result indicating if detection should continue, be removed, or remain unchanged
118 //!
119 //! Evaluates whether a previously detected object should continue to be detected
120 //! by the radar sensor. Updates contact information if the object remains detected
121 //! and sets contactInfoModified to true if changes were made.
122 virtual ContinueDetectingResult continueDetectingObject(
123 DtSimObjectReference object, DtRwSensorContactInfo* contactInfo, bool& contactInfoModified) override;
124
125 //! \brief Factory method to create a new instance of this component
126 //! \param name The name for the new component
127 //! \param owner The local object that will own this component
128 //! \param simManager The simulation services manager
129 //! \param desc Optional component descriptor
130 //! \param parentRegistry Optional parent registry for reader/writer functionality
131 //! \return Pointer to the newly created component
132 //!
133 //! Static factory method used by the component creation system to instantiate
134 //! new instances of this component type.
135 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
136 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
137
138protected:
139 // static DtReaderWriter* provideDesignatedTarget(void* c);
140
141 //! \brief Updates the radar antenna position and state
142 //!
143 //! Updates the radar antenna position and state based on the current tracking
144 //! mode and target information. Manages antenna rotation in scanning modes and
145 //! fixed pointing in single-target tracking mode.
147 //! \brief Increments the radar scan bar counter
148 //!
149 //! Increments the counter that tracks the current scan bar position
150 //! in the radar scanning pattern. Used to simulate radar scan patterns
151 //! across elevation bars.
153
154 //! \brief Determines if a tracked target should be detected based on radar modes
155 //! \param trackId The track identifier of the target to check
156 //! \return True if the target should be detected in the current radar mode
157 //!
158 //! Evaluates whether a target with the specified track ID should be detected
159 //! based on the current radar mode (e.g., in STT mode, only the designated
160 //! target should be detected).
161 bool targetShouldBeDetected(int trackId);
162
163 //! \brief Calculates the azimuth angle to a target
164 //! \param target Reference to the target object
165 //! \return Azimuth angle to the target in degrees
166 //!
167 //! Calculates the azimuth angle (horizontal angle) from the radar to the
168 //! specified target object, in degrees. Used for determining if the target
169 //! is within the current radar scan sector.
170 double azimuthToTargetInDegrees(DtSimObjectReference target);
171 //! \brief Calculates the elevation angle to a target
172 //! \param target Reference to the target object
173 //! \return Elevation angle to the target in degrees
174 //!
175 //! Calculates the elevation angle (vertical angle) from the radar to the
176 //! specified target object, in degrees. Used for determining if the target
177 //! is within the current radar scan bar.
178 double elevationToTargetInDegrees(DtSimObjectReference target);
179
180 //! \brief Updates the contact information for a detected target
181 //! \param target Reference to the target object
182 //! \param targetInfo Pointer to the contact information to update
183 //! \return True if the contact information was modified, false otherwise
184 //!
185 //! Updates the radar contact information for a detected target with current
186 //! data such as position, velocity, and track quality. Returns true if any
187 //! information was changed.
188 bool updateContactData(DtSimObjectReference target, DtRwRadarContactInfo* targetInfo);
189
190 //! \brief Provides information about the currently designated target
191 //! \return Reader/writer containing information about the designated target
192 //!
193 //! Implements the base class method to provide information about the currently
194 //! designated target (highest priority target in the designated target list).
195 //! Used by other components to identify which target the radar is currently
196 //! prioritizing for tracking or weapons guidance.
197 virtual DtReaderWriter* processProvideDesignatedTarget() override;
198
199 //! \brief Gets the default process state repository type
200 //! \return String identifying the default PSR type (DtVreSimpleRadarObjectSensorPSRType)
201 //!
202 //! Returns the default process state repository type for this component.
203 //! Overrides the base class method to provide the specialized PSR type for
204 //! the simple radar object sensor.
205 virtual const char* defaultPSRType() const override;
206
207 //! \brief Gets the track ID for a target entity
208 //! \param id UUID of the target entity
209 //! \return Track ID assigned to the entity
210 //!
211 //! Retrieves or assigns a track ID for the entity with the specified UUID.
212 //! Track IDs are unique identifiers used to reference detected targets in
213 //! the radar system.
214 virtual int trackID(const DtUUID& id);
215 //! \brief Gets the entity UUID corresponding to a track ID
216 //! \param trackId The track ID to look up
217 //! \return Reference to the UUID for the specified track ID
218 //!
219 //! Retrieves the entity UUID associated with the specified track ID.
220 //! This performs the reverse lookup of trackID(), converting a radar track
221 //! identifier back to the corresponding entity UUID.
222 virtual const DtUUID& uuidFromTrackId(int trackId);
223
224 //! \brief Determines a display label for an entity based on its type
225 //! \param DtEntityType Entity type to get a label for
226 //! \return String label to display for the entity type
227 //!
228 //! Creates a human-readable label for an entity based on its type code.
229 //! Used to generate display names for radar contacts in the user interface.
230 std::string entityLabelFromType(const DtEntityType&);
231
232 //! \brief Sets the list of designated targets for the radar
233 //! \param trackId Vector of track IDs to designate, in priority order
234 //!
235 //! Sets the designated targets list and updates the emitter system's track targets.
236 //! The order of track IDs in the vector represents their priority, with the first
237 //! element being the highest priority target. Overrides the base class method.
238 virtual void setDesignatedTargets(const std::vector<int>& trackId) override;
239
240 //! \brief Clears all designated targets from the radar
241 //!
242 //! Clears the designated targets list and the emitter system's track targets.
243 //! This removes all current target designations, restoring the radar to a
244 //! standard search/track state. Overrides the base class method.
245 virtual void clearDesignatedTargets() override;
246
247 //! \brief Gets the priority of a designated target
248 //! \param trackId The track ID to check for priority
249 //! \return The target's priority (1-based, with 1 being highest priority) or -1 if not designated
250 //!
251 //! Returns the target's position in the designated targets list, where 1 represents
252 //! the highest priority target. If the specified track ID is not in the designated
253 //! targets list, returns -1 to indicate it is not designated.
254 int targetPriority(int trackId) const;
255
256 //! \brief Checks if a target is in the designated targets list
257 //! \param trackId The track ID to check
258 //! \return True if the target is designated, false otherwise
259 //!
260 //! Determines whether the specified track ID is present in the designated
261 //! targets list. Returns true if the target is designated, false otherwise.
262 bool isTargetDesignated(int trackId) const;
263
264 //! \brief Gets the highest priority designated target's track ID
265 //! \return The Next To Shoot (NTS) target's track ID, or -1 if no targets are designated
266 //!
267 //! Returns the track ID of the first target in the designated targets list,
268 //! which represents the Next To Shoot (NTS) target with highest priority.
269 //! This is effectively the only designated target in STT (Single Target Track) mode.
270 //! Returns -1 if the designated targets list is empty.
271 int nextToShootTarget() const;
272
273 //! \brief Checks if the radar is in Single Track Target mode
274 //! \return True if in STT mode, false otherwise
275 //!
276 //! Determines whether the radar is currently in STT (Single Track Target) mode.
277 //! In this mode, only the designated target (as returned by nextToShootTarget())
278 //! should be tracked. This contrasts with TWS (Track While Scan) mode where
279 //! multiple targets can be tracked simultaneously.
281
282 //! \brief Cache of entity labels by entity type string
283 //!
284 //! Stores previously looked up entity labels indexed by entity type string.
285 //! Used to avoid repeating the entity label lookup for commonly encountered
286 //! entity types.
287 std::unordered_map<std::string, DtRwString> myKnownEntityLabels;
288
289 //! \brief Map of detection states indexed by track ID
290 //!
291 //! Tracks the detection state of each target by its track ID. The boolean value
292 //! indicates whether the target is currently detected (true) or not (false).
293 //! Used to manage continuity of detection between simulation frames.
294 std::unordered_map<int, bool> myTargetDetectionState;
295
296 //! \brief Pointer to the radar sensor's process state repository
297 //!
298 //! Contains the persistent state information for the radar sensor,
299 //! including tracking settings, antenna position, and designated targets.
301};
302
303} // namespace makVre
Extended radar contact information class.
Definition rwRadarContactInfo.h:28
DtVreRadarObjectSensor()
Default constructor (not implemented)
virtual const char * defaultPSRType() const override
Gets the default process state repository type.
void updateAntennaState()
Updates the radar antenna position and state.
const DtVreSimpleRadarObjectSensor & operator=(const DtVreSimpleRadarObjectSensor &orig)
Assignment operator (not implemented)
virtual void setDesignatedTargets(const std::vector< int > &trackId) override
Sets the list of designated targets for the radar.
double elevationToTargetInDegrees(DtSimObjectReference target)
Calculates the elevation angle to a target.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
bool isTargetDesignated(int trackId) const
Checks if a target is in the designated targets list.
std::unordered_map< int, bool > myTargetDetectionState
Map of detection states indexed by track ID.
Definition vreSimpleRadarObjectSensor.h:294
DtVreSimpleRadarObjectSensor(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool init() override
Initializes the radar sensor component.
virtual ContinueDetectingResult continueDetectingObject(DtSimObjectReference object, DtRwSensorContactInfo *contactInfo, bool &contactInfoModified) override
Determines if an already detected object should remain detected.
void incrementBar()
Increments the radar scan bar counter.
DtVreSimpleRadarObjectSensor(const DtVreSimpleRadarObjectSensor &orig)
Copy constructor (not implemented)
virtual void tick() override
Updates the radar sensor state each simulation frame.
int nextToShootTarget() const
Gets the highest priority designated target's track ID.
virtual ~DtVreSimpleRadarObjectSensor() override
Virtual destructor.
virtual DtReaderWriter * processProvideDesignatedTarget() override
Provides information about the currently designated target.
virtual int trackID(const DtUUID &id)
Gets the track ID for a target entity.
std::string entityLabelFromType(const DtEntityType &)
Determines a display label for an entity based on its type.
virtual void clearDesignatedTargets() override
Clears all designated targets from the radar.
DtVreSimpleRadarObjectSensor()
Default constructor (not implemented)
bool singleTrackTargetMode() const
Checks if the radar is in Single Track Target mode.
DtVreSimpleRadarObjectSensorPSR * myVreSimpleRadarObjectSensorPsr
Pointer to the radar sensor's process state repository.
Definition vreSimpleRadarObjectSensor.h:300
virtual const DtUUID & uuidFromTrackId(int trackId)
Gets the entity UUID corresponding to a track ID.
int targetPriority(int trackId) const
Gets the priority of a designated target.
virtual const char * type() const override
Gets the type identifier for this component.
bool updateContactData(DtSimObjectReference target, DtRwRadarContactInfo *targetInfo)
Updates the contact information for a detected target.
virtual bool detectObject(DtSimObjectReference object, DtRwSensorContactInfo *contactInfo) override
Determines if an object should be detected by the radar.
bool targetShouldBeDetected(int trackId)
Determines if a tracked target should be detected based on radar modes.
std::unordered_map< std::string, DtRwString > myKnownEntityLabels
Cache of entity labels by entity type string.
Definition vreSimpleRadarObjectSensor.h:287
double azimuthToTargetInDegrees(DtSimObjectReference target)
Calculates the azimuth angle to a target.
Simplified radar object sensor process state repository for VREngage.
Definition vreSimpleRadarObjectSensorPSR.h:48
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtVreSimpleRadarObjectSensorType[]
Type identifier for the VRE simple radar object sensor component.
Definition vreSimpleRadarObjectSensor.h:28
Radar sensor for detecting objects and publishing emitter systems.
Simple radar object sensor process state repository for VREngage.