DriveWorks SDK Reference
5.10.90 Release
For Test and Development only

Accessing Vehicle Properties and Sensors From a Rig File

The following code snippets shows the general structure of a program that uses a rig configuration and enumerate / query sensor properties.
The rig module can be initialized from a rig file:

dwContextParameters contextParams{};
dwInitialize(&contextHandle, DW_VERSION, &contextParams);
dwRig_initializeFromFile(&rigHandle, contextHandle, rigconfigFilename);
#define DW_VERSION
DW_API_PUBLIC dwStatus dwInitialize(dwContextHandle_t *const context, dwVersion const headerVersion, dwContextParameters const *const params)
Creates and initializes an SDK context.
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:83
A set of parameters that is passed to the SDK to create the context.
Definition: Context.h:93
#define DW_NULL_HANDLE
Definition: Types.h:83
struct dwRigObject * dwRigHandle_t
Handle representing the Rig interface.
Definition: Rig.h:70
DW_API_PUBLIC dwStatus dwRig_initializeFromFile(dwRigHandle_t *const obj, dwContextHandle_t const ctx, char8_t const *const configurationFile)
Initializes the Rig Configuration module from a file.

Afterwards we can easily access the vehicle properties:

dwRig_getGenericVehicle(&vehicle, rigHandle);
DW_API_PUBLIC dwStatus dwRig_getGenericVehicle(dwGenericVehicle *const vehicle, dwConstRigHandle_t const obj)
Gets the properties of a generic vehicle (car or truck).
Vehicle description.
Definition: Vehicle.h:263

As well as all sensors contained in the file:

dwRig_getSensorCount(&sensorCount, ...);
for(uint32_t sensorID; sensorID < sensorCount; ++sensorID)
{
dwRig_getSensorProtocol(&sensorProtocol, sensorID, rigHandle);
dwRig_getSensorParameter(&sensorParameter, sensorID, rigHandle);
dwRig_getSensorName(&sensorName, sensorID, rigHandle);
dwRig_getNominalSensorToRigTransformation(&transformation, sensorID, rigHandle);
dwRig_getSensorToRigTransformation(&transformation, sensorID, rigHandle);
}
DW_API_PUBLIC dwStatus dwRig_getSensorName(char8_t const **const sensorName, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the name of a sensor as given in the configuration.
DW_API_PUBLIC dwStatus dwRig_getSensorProtocol(char8_t const **const sensorProtocol, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the protocol string of a sensor.
DW_API_PUBLIC dwStatus dwRig_getNominalSensorToRigTransformation(dwTransformation3f *const transformation, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the nominal sensor to rig transformation for a sensor.
DW_API_PUBLIC dwStatus dwRig_getSensorToRigTransformation(dwTransformation3f *const transformation, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the sensor to rig transformation for a sensor.
DW_API_PUBLIC dwStatus dwRig_getSensorCount(uint32_t *const sensorCount, dwConstRigHandle_t const obj)
Gets the number of all available sensors.
DW_API_PUBLIC dwStatus dwRig_getSensorParameter(char8_t const **const sensorParameter, uint32_t const sensorId, dwConstRigHandle_t const obj)
Gets the parameter string for a sensor.

Finally we can release all handles:

dwRig_release(rigHandle);
dwRelease(contextHandle);
DW_API_PUBLIC dwStatus dwRelease(dwContextHandle_t const context)
Releases the context.
DW_API_PUBLIC dwStatus dwRig_release(dwRigHandle_t const obj)
Releases the Rig Configuration module.

For the full implementation refer to Rig Configuration Sample