|
VR-Engage
2.2
|
Purpose: This example demonstrates frontend/backend coordination for sensor simulation in VR-Engage. It shows how to implement a radar detection system that identifies incoming threats and communicates detection information from the simulation backend to the player station frontend.
Observable Behavior: When running this example, you will see/experience:
Prerequisites:
Related Examples:
This example demonstrates:
This example is divided into three components that work together to provide radar detection capabilities. The entityDetectionShared component defines the DetectionReportMessage used by both frontend and backend. Lua message definitions are compiled into type-safe C++ message classes at build time, creating a shared library consumed by both other components. This component must be built and deployed first as it represents a dependency for the other two components.
The entityDetectionFrontend component runs in the vrEngage.exe process and implements the DtEntityDetectionControlLogic class. This component subscribes to detection messages, updates the player attribute store with detection information, and displays radar detections in the player UI.
The entityDetectionSim component runs as a VR-Forces entity controller in the simulation process. It implements the DtDetectionReportController class, which performs radar detection simulation, calculates threat vectors and closest munitions, and publishes detection reports to the frontend.
Message Flow: Simulation Sensor Logic → DetectionReportMessage → Message Manager → Frontend Component → Player Attribute Store → UI Display
A key aspect of this example is the modification of the LSV (Light Strike Vehicle) entity configuration to include a radar munition sensor system. The example SMS includes a custom LSV entity definition that adds the radar-munition-sensor.sysdef system.
The radar munition sensor (DtRadarMunitionSensor) is a specialized VR-Forces component designed to detect incoming munitions. It extends the standard radar object sensor with munition-specific detection algorithms and provides real-time threat assessment based on munition trajectory, velocity, and time-to-impact. This sensor serves as the data source for the detection report controller.
When the LSV entity is created, the radar munition sensor component initializes and continuously scans for incoming munitions within its detection parameters. The DtDetectionReportController queries the sensor's detected contacts list, formats the detection information into a DetectionReportMessage, and sends it to the frontend for display.
The modified LSV entity definition is located at data/simulationModelSets/examples/entityDetection/vrfSim/entities/examples/LSV_with_radar.entity and includes the system definition in its configuration:
The radar-munition-sensor system is configured with several key parameters. The Detection Range defines the maximum distance at which munitions can be detected. The Field of View specifies the angular coverage of the sensor, typically 360° for omnidirectional threat detection. The Update Rate controls the frequency at which the sensor updates its contact list. The Signature Sensitivity sets the threshold for munition detection based on radar cross-section.
This architecture demonstrates how VR-Forces system definitions can be composed to add capabilities to existing vehicle models without modifying the base entity definitions.
The detection report message is defined in Lua and generates C++ classes during the build process. The message definition includes structures for individual detection reports with contact information and position data, as well as top-level attributes for routing the message to the correct player station and identifying the closest threat.
The VR-Engage message generation system processes these Lua definitions during the build, generating type-safe C++ message classes with appropriate accessors and serialization methods. The message includes sender identification for routing to the correct player station in multi-player scenarios, along with structured detection report data containing contact information and position.
The frontend component registers its interest in detection messages during initialization. The component inherits from DtPlayerComponent and uses the standard initialization pattern to set up message handlers and player attribute store access.
Message handler registration connects backend simulation events to frontend UI updates. The player attribute store provides the bridge between component logic and UI display, allowing QML interfaces or other display systems to bind directly to detection state. The delegate pattern enables type-safe callback handling while maintaining clean separation between the message system and component logic. Early initialization during the component lifecycle ensures messages are captured from the start of the simulation.
When detection reports arrive from the backend, the frontend component processes them and updates the player attribute store. The message handler first verifies that the message is intended for this player station, then extracts detection information and updates the appropriate attribute store entries, including a list of detected munitions.
Message routing ensures reports reach the correct player station in multi-player scenarios where multiple players may be active simultaneously. Player attribute store updates trigger UI refreshes automatically through the binding system, eliminating the need for manual UI update calls. The structured data extraction from detection reports allows different UI elements to display specific aspects of the threat information, such as total count, boolean threat indicator, closest threat identification, and a list of detected munitions. The return value indicates whether the message was handled by this component, allowing the message manager to track message processing and potentially route unprocessed messages to other handlers.
The simulation component performs radar detection calculations in its tick method, which is called regularly by the VR-Forces simulation loop. This component extends the entity controller pattern to add sensor simulation behavior to the controlled entity.
Simulation logic runs in the backend for physics accuracy and proper network coordination with other simulation participants. The frontend receives processed detection results for immediate UI updates without needing to perform expensive sensor calculations in the player station process. Message-based decoupling allows independent evolution of simulation and display logic—changes to detection algorithms or sensor models don't require modifications to the UI code. The entity controller integrates seamlessly with the VR-Forces simulation loop, receiving regular tick calls and having access to entity state and the broader simulation environment.
The backend component uses a descriptor pattern for configuration, allowing simulation designers to customize sensor behavior without code changes.
The descriptor pattern separates configuration from implementation, allowing parameters like update intervals to be adjusted through simulation model set definitions. The creator function enables factory-based component instantiation, which is essential for VR-Forces to dynamically create controllers as entities are spawned during simulation.
Build the example following the Environment Setup & Build Guide. The three components must be built in dependency order, with the shared message library first:
Install the plugins to the VR-Engage installation directory:
This copies the components to their appropriate locations. The frontend plugin installs to <VR-Engage-Install-Dir>\plugins64\vrEngage\release\exampleEntityDetectionFrontend.dll, the backend plugin to <VR-Engage-Install-Dir>\plugins64\vrForces\release\exampleEntityDetectionSim.dll, and the shared library to <VR-Engage-Install-Dir>\bin64\exampleEntityDetectionShared.dll.
Verify installation by checking for the installed files:
The example includes a pre-configured SMS (entityDetection.sms) that is already installed with VR-Engage at <VR-Engage-Install-Dir>\data\simulationModelSets\examples\entityDetection.sms. This SMS loads the backend detection controller and configures the necessary VR-Forces components for radar simulation. The SMS includes detection controller component descriptor registration, entity controller factory bindings, and simulation model set includes for base VR-Engage functionality.
Pre-Configured Test Entity:
The example provides a modified Light Strike Vehicle MK II (LSV) entity specifically configured with the radar munition sensor system. This entity is located at data/simulationModelSets/examples/entityDetection/vrfSim/entities/examples/vreLight Strike Vehicle MK II (LSV).entity and includes the radar-munition-sensor system definition required for detection functionality. The entity is available in VR-Forces when the entityDetection.sms is loaded.
Role Configuration:
The example includes a specialized driver role file that demonstrates detection component integration. The driverWithDetection.lua role file (located at data/simulationModelSets/examples/entityDetection/roles/driverWithDetection.lua) extends the standard driver role and adds two key components:
The entityDetectionControlLogic component subscribes to detection messages and updates the player attribute store. The warnOverlay component binds detection state attributes to a QML-based HUD that displays incoming threat warnings. This demonstrates the complete integration pattern from backend sensor simulation through message passing to frontend UI display.
The example LSV entity references this role file for its "Driver" role, so when you engage the LSV as a driver, you automatically get the detection functionality and warning overlay.
To use the entity detection component in custom roles, add the entityDetectionControlLogic component group to your role configuration:
Alternatively, create a Lua role file that inherits from a base role and adds the detection components similar to driverWithDetection.lua.
Launch VR-Engage with the entity detection SMS:
Creating a Test Scenario:
driverWithDetection.lua role configuration that includes the entityDetectionControlLogic component for detection processing and a QML-based warning overlay for displaying threat informationExpected Behavior:
You should observe several behaviors indicating the system is working correctly. Detection reports appear in the player UI as threats approach your entity. The warning overlay displays incoming threat indicators with visual cues. The player attribute store reflects real-time detection counts, which you can verify through VR-Engage debug tools. The closest threat information displays with marking text identifying the threat. Detection state updates continuously during threat engagement, showing the dynamic nature of the sensor simulation.
As incoming munitions enter the detection range of the radar sensor, you should see:
numberOfIncoming)incomingMissile set to true)Dependencies: This example requires several VR-Engage framework libraries including vrePlayerStation for player component infrastructure, vreMessageManager for publish/subscribe messaging, VR-Forces simulation libraries (vrfmodel, vrfSimCore) for entity control logic, VR-Link network libraries (vl, vlutil) for DIS/HLA communication, and the Matrix library for coordinate transformations and spatial calculations.
Message Generation: The Lua message definitions are processed by the VR-Engage message generation CMake function during the build process. This generates C++ code with type-safe accessors, serialization methods, and factory registration. Message types are registered with DtVreMessageFactory at plugin load time, allowing the message manager to route messages correctly.
Build System Integration: The example uses a three-component build structure with explicit shared library dependency management. The CMake generateMessages() function processes Lua definitions into C++ source code. Plugin installation targets are configured for both frontend and backend deployment. Debug configurations are provided that launch VR-Engage with appropriate command-line settings for development testing.
File Structure:
Source layout (under the VR-Engage developer tree):
Installed data used by this example (under <VR-Engage-Install-Dir>):