DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

src/dw/sensors/sensormanager/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
2 
3 @page sensormanager_usecase1 Sensor Manager Workflow
4 
5 ## Workflow
6 
7 Before we can instantiate Sensor Manager, we need to declare and instantiate
8 NVIDIA<sup>&reg;</sup> DriveWorks @ref core_usecase5 , Sensor Abstration Layer and @ref rig_mainsection :
9 
10 ```{.cpp}
11 dwContextHandle_t ctx = DW_NULL_HANDLE;
12 dwSALHandle_t sal = DW_NULL_HANDLE;
13 dwRigHandle_t rc = DW_NULL_HANDLE;
14 dwSensorManagerHandle_t sm = DW_NULL_HANDLE;
15 
16 dwContextParameters ctxParams = {};
17 constexpr size_t poolSize = 16;
18 const dwSensorEvent * event = nullptr;
19 dwStatus ret = DW_SUCCESS;
20 
21 ret = dwInitialize(&ctx, DW_VERSION, &ctxParams);
22 checkError(ret);
23 
24 ret = dwSAL_initialize(&sal, ctx);
25 checkError(ret);
26 
27 ret = dwRig_initializeFromFile(&rc, ctx, "rig.json");
28 checkError(ret);
29 ```
30 
31 Now we can initialize Sensor Manager and start the underlying sensors:
32 
33 ```{.cpp}
34 ret = dwSensorManager_initializeFromRig(&sm, rc, poolSize, sal);
35 checkError(ret);
36 
37 ret = dwSensorManager_start(sm);
38 checkError(ret);
39 ```
40 
41 Once Sensor Manager object initialized and sensors are started, it is possible
42 to read events in a loop:
43 
44 ```{.cpp}
45 while (ret == DW_SUCCESS) {
46  ret = dwSensorManager_acquireNextEvent(&event, 0, sm);
47  checkError(ret);
48 
49  switch (event->type) {
50  case DW_SENSOR_RADAR: /* Process Event */ break;
51  case DW_SENSOR_LIDAR: /* Process Event */ break;
52  case DW_SENSOR_CAN: /* Process Event */ break;
53  case DW_SENSOR_GPS: /* Process Event */ break;
54  case DW_SENSOR_IMU: /* Process Event */ break;
55  case DW_SENSOR_CAMERA: /* Process Event */ break;
56  }
57 
58  ret = dwSensorManager_releaseAcquiredEvent(event, sm);
59  checkError(ret);
60 }
61 ```
62 
63 Clean-up procedure consists of stopping Sensor Manager and releasing the memory:
64 
65 ```{.cpp}
66 ret = dwSensorManager_stop(sm);
67 checkError(ret);
68 
69 ret = dwSensorManager_release(&sm);
70 checkError(ret);
71 ```
72 
73 Similarly, DriveWorks @ref core_usecase5, SAL and @ref rig_mainsection objects must be
74 released at the end.
75 
76 Sensor Manager is used in multiple samples:
77 - @ref dwx_camera_calibration_sample
78 - @ref dwx_imu_calibration_sample
79 - @ref dwx_lidar_calibration_sample
80 - @ref dwx_struct_from_motion_sample