DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

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