Loading [MathJax]/jax/input/TeX/config.js
  • <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>

  • DriveWorks SDK Reference
    5.10.90 Release
    For Test and Development only

    All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    Sensor Manager Workflow

    Workflow

    Before we can instantiate Sensor Manager, we need to declare and instantiate NVIDIA® DriveWorks Context , Sensor Abstration Layer and Rig Configuration :

    dwContextParameters ctxParams = {};
    constexpr size_t POOL_SIZE = 16;
    const dwSensorEvent * event = nullptr;
    dwStatus ret = DW_SUCCESS;
    ret = dwInitialize(&ctx, DW_VERSION, &ctxParams);
    checkError(ret);
    ret = dwSAL_initialize(&sal, ctx);
    checkError(ret);
    ret = dwRig_initializeFromFile(&rc, ctx, "rig.json");
    checkError(ret);
    #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
    dwStatus
    Status definition.
    Definition: Status.h:173
    #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.
    struct dwSensorManagerObject * dwSensorManagerHandle_t
    Handle of sensor manager.
    Definition: SensorManager.h:71
    Structure for returning data upon any sensor event.
    Definition: SensorManager.h:78
    struct dwSALObject * dwSALHandle_t
    Handle representing the Sensor Abstraction Layer interface.
    Definition: Sensors.h:83
    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:

    ret = dwSensorManager_initializeFromRig(&sm, rc, POOL_SIZE, sal);
    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) {
    ret = dwSensorManager_acquireNextEvent(&event, 0, sm);
    checkError(ret);
    switch (event->type) {
    case DW_SENSOR_RADAR: /* Process Event */ break;
    case DW_SENSOR_LIDAR: /* Process Event */ break;
    case DW_SENSOR_CAN: /* Process Event */ break;
    case DW_SENSOR_GPS: /* Process Event */ break;
    case DW_SENSOR_IMU: /* Process Event */ break;
    case DW_SENSOR_CAMERA: /* Process Event */ break;
    }
    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_LIDAR
    Lidar.
    Definition: Sensors.h:193
    @ DW_SENSOR_CAN
    CAN.
    Definition: Sensors.h:199
    @ DW_SENSOR_IMU
    IMU.
    Definition: Sensors.h:197
    @ DW_SENSOR_RADAR
    RADAR.
    Definition: Sensors.h:201
    @ DW_SENSOR_CAMERA
    CAMERA.
    Definition: Sensors.h:191
    @ DW_SENSOR_GPS
    GPS.
    Definition: Sensors.h:195

    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:

    人人超碰97caoporen国产