DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

src/dw/sensors/plugins/radar/docs/radar_fullsensor.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
2 
3 @page sensorplugins_radarsensor Custom Radars (Comprehensive)
4 @tableofcontents
5 
6 @section sensorplugins_radarsensor_comm Introduction
7 
8 The Comprehensive Plugin Framework for Radar sensors allows third parties to interface with
9 custom sensor using a shared object (.so) containing their sensor driver implementation.
10 
11 The Radar may use any available interface to communicate with NVIDIA DRIVE™ AGX as the plugin
12 fully implements the communication channel.
13 
14 @section sensorplugins_radarsensor_impl Plugin Implementation
15 
16 The plugin framework defines a set of function pointer definitions which must be
17 implemented and exported to the SAL. For Radar sensors, the plugin must have implementation
18 for the function pointers defined in:
19 
20 * @ref sensor_plugins_ext_common_group
21 * @ref sensor_plugins_ext_radar_group
22 
23 In addition, the plugin must implement & export the function, `dwSensorRadarPlugin_getFunctionTable()`,
24 which is the only C function that needs to be exposed from the shared object.
25 This allows the developer flexibility to implement internals of their plugin in C++, if necessary.
26 
27 @section sensorplugins_radarsensor_interface Plugin Interfaces
28 
29 This section does not substitute the API specification, but attempts to give a high-level overview
30 of how implemented plugin functions will be exercised by SAL.
31 
32 @subsection sensorplugins_radarsensor_interface_init Initialization
33 
34 For the purpose of creation, DriveWorks sensors are specified by `dwSensorParams`,
35 which contains a protocol and parameter string for the sensor to be created.
36 
37 For custom radars, the protocol and parameter string will be as follows:
38 
39  protocol: radar.custom (for live) OR radar.virtual (playback)
40  params: decoder-path=<path_to_so>[,<custom params>]
41 
42 At initialization, a user's call to `dwSensor_create()` will lead to SAL
43 dynamically loading the plugin library via `dlopen()`.
44 SAL will then make the following calls to your plugin:
45 
46 | # | Function Call | Purpose |
47 | - | ------------- | ------- |
48 | 1 | `dwSensorPlugin_createHandle()` | Initialize a context for this sensor (allocate resources, etc.) |
49 | 2 | `dwSensorRadarPlugin_getDecoderConstants()` | Retrieve necessary constants |
50 
51 After the call to `dwSensorPlugin_createHandle` the plugin should be ready
52 to decode data (see @ref sensorplugins_radarsensor_interface_decoding).
53 
54 @subsection sensorplugins_radarsensor_interface_constants Sensor Creation
55 
56 The plugin framework provides a specific entrypoint to initialize the control-plane /
57 transport layer with the sensor. For this, SAL will make the following calls to your plugin:
58 
59 | # | Function Call | Purpose |
60 | - | ------------- | ------- |
61 | 1 | `dwSensorPlugin_createSensor()` | Initialization of communication & transport plane with the sensor |
62 
63 It is up to the developer to decide what actions need to be taken during this call.
64 The sensor plugin is not expected to serve data until the sensor is started.
65 
66 @note This section only applies for live sensors, and is skipped for virtual sensors
67 
68 @subsection sensorplugins_radarsensor_interface_lifecycle Sensor Lifecycle
69 
70 After sensor creation and initialization, DriveWorks provides a set of
71 @ref sensors_usecase1 user APIs.
72 
73 These have a 1:1 mapping to plugin entrypoints, and their purpose is
74 self-explanatory:
75 
76 | DriveWorks User API | Plugin API |
77 | ------------------- | ---------- |
78 | `dwSensor_start()` | `dwSensorPlugin_start()` |
79 | `dwSensor_stop()` | `dwSensorPlugin_stop()` |
80 | `dwSAL_releaseSensor()` | `dwSensorPlugin_reset()` |
81 
82 Before querying the plugin for raw data, SAL will make a call
83 to start the sensor.
84 
85 @subsection sensorplugins_radarsensor_interface_rawdata Raw Data Gathering
86 
87 From its communication plane, the sensor plugin is responsible for gathering
88 raw data from the device. Once the sensor has been started via a
89 `dwSensorPlugin_start()` call, SAL will make the following calls to your plugin:
90 
91 | # | Function Call | Purpose |
92 | - | ------------- | ------- |
93 | 1 | `dwSensorPlugin_readRawData()` | Provide raw data for a single sensor message as a byte array |
94 | 2 | `dwSensorPlugin_returnRawData()` | Returns raw data previously acquired |
95 
96 We recommend the following format for the data that is returned:
97 
98  --------------------- Header ------------------
99  [Payload Size (uint32_t)][Timestamp (dwTime_t)][Payload]
100 
101 @note There may be multiple calls to `dwSensorPlugin_readRawData()` before a call to
102 `dwSensorPlugin_returnRawData()`. The plugin is resposible for memory management of this
103 raw buffer; an example of a refcounted buffer pool is provided as sample code.
104 
105 @note This section only applies for live sensors, and is skipped for virtual sensors
106 
107 @subsection sensorplugins_radarsensor_interface_decoding Decoding
108 
109 Decoding of data is intentionally split from data gathering on the sensor's communication
110 plane. This is done to uniformly support virtual (file-based) playback of recorded data.
111 
112 In order to decode raw data into DriveWorks-specific data structures, SAL will
113 make the following calls to your plugin:
114 
115 | # | Function Call | Purpose |
116 | - | ------------- | ------- |
117 | 1 | `dwSensorPlugin_pushData()` | Receives raw data from SAL |
118 | 2 | `dwSensorRadarPlugin_parseDataBuffer()` | Decodes available data in the plugin buffer and returns decoded data |
119 | 3 | `dwSensorRadarPlugin_validatePacket()` | Validates the raw data packet and returns raw data scan type |
120 | 4 | `dwSensorRadarPlugin_setVehicleState()` | Sends vehicle dynamics information to the radar sensor |
121 
122 The plugin should not make any assumption on the ordering of these calls, and should return
123 an available decoded packet when available.