Workflow
Before we can instantiate Sensor Manager, we need to declare and instantiate NVIDIA® DriveWorks Context , Sensor Abstration Layer and Rig Configuration :
constexpr size_t POOL_SIZE = 16;
checkError(ret);
checkError(ret);
checkError(ret);
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.
A set of parameters that is passed to the SDK to create the context.
dwStatus
Status definition.
struct dwRigObject * dwRigHandle_t
Handle representing the Rig interface.
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.
struct dwSensorManagerObject * dwSensorManagerHandle_t
Handle of sensor manager.
Structure for returning data upon any sensor event.
struct dwSALObject * dwSALHandle_t
Handle representing the Sensor Abstraction Layer interface.
DW_API_PUBLIC dwStatus dwSAL_initialize(dwSALHandle_t *const sal, dwContextHandle_t const context)
Creates and initializes a SAL (sensor abstraction layer) module.
Now we can initialize Sensor Manager and start the underlying sensors:
checkError(ret);
checkError(ret);
DW_API_PUBLIC dwStatus dwSensorManager_initializeFromRig(dwSensorManagerHandle_t *sm, dwRigHandle_t rc, size_t poolSize, dwSALHandle_t sal)
Creates and initializes a SensorManager module, adding all sensors in the provided Rig Configuration.
DW_API_PUBLIC dwStatus dwSensorManager_start(dwSensorManagerHandle_t sm)
Starts all sensors.
Once Sensor Manager object initialized and sensors are started, it is possible to read events in a loop:
while (ret == DW_SUCCESS) {
checkError(ret);
switch (event->type) {
}
checkError(ret);
}
DW_API_PUBLIC dwStatus dwSensorManager_acquireNextEvent(const dwSensorEvent **ev, dwTime_t timeoutMicroSeconds, dwSensorManagerHandle_t sm)
Called by the application to consume the next available sensor event ready for consumption.
DW_API_PUBLIC dwStatus dwSensorManager_releaseAcquiredEvent(const dwSensorEvent *ev, dwSensorManagerHandle_t sm)
Releases a previously acquired event back to the pool.
@ DW_SENSOR_CAMERA
CAMERA.
Clean-up procedure consists of stopping Sensor Manager and releasing the memory:
checkError(ret);
checkError(ret);
DW_API_PUBLIC dwStatus dwSensorManager_stop(dwSensorManagerHandle_t sm)
Stops all sensors.
DW_API_PUBLIC dwStatus dwSensorManager_release(dwSensorManagerHandle_t sm)
Releases the SensorManager module by deleting the handle.
Similarly, DriveWorks Context, SAL and Rig Configuration objects must be released at the end.
Sensor Manager is used in multiple samples: