VR-Vantage
Loading...
Searching...
No Matches
17 - Sensors

VR-Vantage renders simulated sensor views – night-vision goggles, thermal imagers, and other electro-optical modes – by applying a named, persisted configuration to an observer's channel.

This chapter shows how a toolkit developer creates, reads, and modifies those configurations at runtime, wires them to observer modes, and understands the split between the two sensor rendering backends that ship with the product.

The chapter covers the public API a plugin or application calls. It does not describe the internal rendering pipeline of either backend; that lives in the class documentation for the individual sensor modules.

17.1 - Core Concepts

The subsystem uses a small vocabulary that recurs throughout the API.

  • Sensor. A named collection of typed attributes (bool, int, float, string) plus the name of the sensor module that should render it. A sensor is the persistable, configurable object a user selects from an observer's sensor menu. Represented by DtSensor.
  • Sensor module. The rendering backend that consumes a sensor's attributes and produces the sensor image on a channel. VR-Vantage ships two such modules – CameraFX and SensorFX – and applications may register more. Represented by DtSensorModule.
  • Sensor controller. A separate object used to write sensor attributes. DtSensor exposes read-only accessors; every mutation goes through a DtSensorController (local) or a DtMasterSensorController (distributed). This split lets the controller broadcast changes to remote display engines.
  • Observer mode. A named observer configuration that includes, among other settings, the sensor to activate. Sensor selection per mode is managed by DtObserverModeManager.

17.2 - Class Roles

Five public classes carry the API surface a toolkit developer touches.

DtSensorManager is a per-DtDe singleton that owns every registered sensor and every registered sensor module. Retrieve it with DtSensorManager::instance(de). It exposes lookup (findSensor(), findSensorModule()), enumeration (getSensors(), getSensorModules()), enable/disable of a sensor on a channel, persistence (saveAsDefaults(), loadDefaults(), importSettings(), exportSettings()), and the runtime availability check hasSensorModuleForSensor().

DtSensor represents a single sensor's persisted configuration. It carries four attribute maps (bool, int, float, string) plus the sensor's unique name and the module name that should render it. All accessors are read-only: attributeBool(), attributeInt(), attributeFloat(), attributeString(), and the change signals signal_attributeChangedXxx. To modify a sensor, use a controller.

DtSensorModule is the interface each rendering backend implements. Its name() is the module identifier stored in a DtSensor, and displayName() is the human-readable form shown in the sensor menu. A module registers itself with the sensor manager during plugin initialization and is asked to enableSensor() or disableSensor() on a channel when the observer's active sensor changes.

DtSensorController is the base class used to write sensor attributes on the local display engine. DtMasterSensorController wraps a DtSensorController together with a distribution agent so that setParameterXxx(), setSensorModule(), and rename() apply immediately to the master display engine and are forwarded to remote display engines. Use the master controller from the main thread in any distributed session; use the local controller only when there is no need to broadcast the change.

DtObserverModeManager owns the per-observer-mode configuration, including which sensor is active for a given mode. Its setSensor(modeKey, sensorName) selects the sensor a mode should use, and its return value reports whether the required sensor module is loaded in the current runtime.

17.3 - The Two Sensor Modules: CameraFX vs SensorFX

VR-Vantage ships with two independent sensor modules. A given sensor is bound to exactly one of them by its moduleName.

CameraFX is the built-in module in the base runtime. It is implemented by DtSenSimSensorModule and is registered under the module name "CameraFxSensorModule" (display name "CameraFX"). CameraFX applies fast post-processing effects – noise, blur, gain, level, halos, black hot, motion blur, filter – to the rendered scene. It is always available.

SensorFX is a separately licensed plugin, built on the JRM Technologies SigSim runtime. It is implemented by JrmSensorModule and is registered under the module name "SensorFxSensorModule" (display name "SensorFX"). SensorFX drives a physically based pipeline with sensor-specific radiance modeling, thermal spinup of materials, atmospheric processing, and LWIR-, NVG-, and visual-band sensor modes. It is available only when the SensorFX plugin is loaded.

Because a saved sensor may name a module that is not loaded, always ask the manager whether the current runtime can render it before enabling it:

using namespace makVrv;
if (sensorMgr.hasSensorModuleForSensor("Long-Range LWIR"))
{
// safe to select this sensor on a channel or observer mode
}
Definition DtSensorManager.h:37
virtual bool hasSensorModuleForSensor(const std::string &sensorName) const =0
static DtSensorManager & instance(DtDe &de)
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16

17.4 - Reading and Changing Settings

Reads go through DtSensor directly. Writes go through a controller. This asymmetry is the single most important rule of the sensor API: application code never mutates a DtSensor in place.

using namespace makVrv;
// Find the sensor by name.
DtSensor* sensor = DtSensorManager::instance(de).findSensor("Wide FOV NVG");
if (sensor == nullptr) { return; }
// Read attributes directly.
bool noiseOn = sensor->attributeBool("noiseOn");
float gain = sensor->attributeFloat("GainAdjustment");
// Write attributes through a master controller so remote engines see the
// change too. The controller creates the sensor if the name does not exist.
DtMasterSensorController controller(de);
controller.setTargetSensor(sensor->name());
controller.setParameterBool("noiseOn", !noiseOn);
controller.setParameterFloat("GainAdjustment", gain + 0.05f);
// Optional: persist the change as the runtime default.
DtSensorManager::instance(de).saveAsDefaults();
Definition DtMasterSensorController.h:26
Definition DtSensor.h:31
virtual std::string name() const
Returns "DtSensor".
virtual bool attributeBool(const std::string &attributeName) const
virtual float attributeFloat(const std::string &attributeName) const

A few properties of this pattern are worth calling out.

  • Attribute names are strings. Each sensor module publishes its own set of attribute names ("noiseOn", "GainAdjustment", "agcOn", and so on). Check DtSensor::attributeExists() if the module in use is not fixed.
  • Signals fire on change. DtSensor emits signal_attributeChangedBool, signal_attributeChangedInt, signal_attributeChangedFloat, signal_attributeChangedString, and signal_setFromRecord. Connect these when a widget or driver must react to sensor changes made elsewhere in the process (including changes arriving from a distributed session).
  • Persist deliberately. Changes made through a controller are live immediately but not persisted until you call DtSensorManager::saveAsDefaults(). The manager also supports file-based persistence with exportSettings(filename) and importSettings(filename), which are the recommended way to move a configured sensor set between machines or scenarios.

17.5 - Observer Mode Integration

An observer mode owns a sensor name. Selecting the mode activates the sensor on the observer's channel. To wire a mode to a sensor:

using namespace makVrv;
const int modeKey = modeMgr.lookupObserverModeKey("Pre-Aperture Radiance");
// setSensor returns false when the sensor's module is not loaded in the
// current runtime. Treat that as "sensor not available" rather than an error.
if (!modeMgr.setSensor(modeKey, "LWIR (SensorFX)"))
{
// SensorFX is not loaded in this runtime; leave the mode's sensor unset.
}
DtObserverModeManager is responsible for loading and saving observer modes, and providing a mechanism...
Definition DtObserverModeManager.h:55
bool setSensor(int modeKey, const std::string &sensorName)
int lookupObserverModeKey(const std::string &stringKey) const
static DtObserverModeManager & instance(DtDe &de)
Get an instance used to emit, or to connect.

The manager stores the sensor by name only; the module-availability check is done at set time and again at activation time. This is how a scene authored with SensorFX sensors can still be loaded in a base VR-Vantage runtime without producing broken observer modes – the unavailable sensor simply does not activate. DtSensorManager::hasSensorModuleForSensor() reports the same result and can be used to filter a sensor menu.

17.6 - Complete Example

Three example plug-ins in the toolkit exercise different corners of the sensor API. Each has full source in the Examples section of this documentation.

  • exampleSensorSettings – SensorFX only. Binds keyboard shortcuts to DtMasterSensorController calls that toggle sensor effects, adjust noise, blur, gain, and level, and persist the result with DtSensorManager::saveAsDefaults(). This is the closest match to the pattern shown in 17.4 - Reading and Changing Settings.
  • exampleGimbalPlugin – Uses either backend. Creates a simulated gimbaled camera, attaches an observer to it, and builds a sensor field-of-view overlay on top. Demonstrates the observer-side of the sensor pipeline rather than direct attribute manipulation.
  • examplePreApertureRadiance – SensorFX only. Registers a new observer mode, uses DtObserverModeManager::setSensor() to auto-activate the "LWIR (SensorFX)" sensor when the mode is selected, and consumes the SensorFX pre-aperture radiance texture from a custom post processor.

The SensorFX-only examples require the SensorFX plugin to be loaded; their provided launch scripts (*_sensorFX.bat or *_stealth.bat with the SensorFX plugin enabled) take care of the setup.

17.7 - Related Reference