1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
3 @page sensorplugins_radarsensor Custom Radars (Comprehensive)
6 @section sensorplugins_radarsensor_comm Introduction
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.
11 The Radar may use any available interface to communicate with NVIDIA DRIVE™ AGX as the plugin
12 fully implements the communication channel.
14 @section sensorplugins_radarsensor_impl Plugin Implementation
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:
20 * @ref sensor_plugins_ext_common_group
21 * @ref sensor_plugins_ext_radar_group
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.
27 @section sensorplugins_radarsensor_interface Plugin Interfaces
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.
32 @subsection sensorplugins_radarsensor_interface_init Initialization
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.
37 For custom radars, the protocol and parameter string will be as follows:
39 protocol: radar.custom (for live) OR radar.virtual (playback)
40 params: decoder-path=<path_to_so>[,<custom params>]
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:
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 |
51 After the call to `dwSensorPlugin_createHandle` the plugin should be ready
52 to decode data (see @ref sensorplugins_radarsensor_interface_decoding).
54 @subsection sensorplugins_radarsensor_interface_constants Sensor Creation
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:
59 | # | Function Call | Purpose |
60 | - | ------------- | ------- |
61 | 1 | `dwSensorPlugin_createSensor()` | Initialization of communication & transport plane with the sensor |
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.
66 @note This section only applies for live sensors, and is skipped for virtual sensors
68 @subsection sensorplugins_radarsensor_interface_lifecycle Sensor Lifecycle
70 After sensor creation and initialization, DriveWorks provides a set of
71 @ref sensors_usecase1 user APIs.
73 These have a 1:1 mapping to plugin entrypoints, and their purpose is
76 | DriveWorks User API | Plugin API |
77 | ------------------- | ---------- |
78 | `dwSensor_start()` | `dwSensorPlugin_start()` |
79 | `dwSensor_stop()` | `dwSensorPlugin_stop()` |
80 | `dwSAL_releaseSensor()` | `dwSensorPlugin_reset()` |
82 Before querying the plugin for raw data, SAL will make a call
85 @subsection sensorplugins_radarsensor_interface_rawdata Raw Data Gathering
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:
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 |
96 We recommend the following format for the data that is returned:
98 --------------------- Header ------------------
99 [Payload Size (uint32_t)][Timestamp (dwTime_t)][Payload]
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.
105 @note This section only applies for live sensors, and is skipped for virtual sensors
107 @subsection sensorplugins_radarsensor_interface_decoding Decoding
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.
112 In order to decode raw data into DriveWorks-specific data structures, SAL will
113 make the following calls to your plugin:
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 |
122 The plugin should not make any assumption on the ordering of these calls, and should return
123 an available decoded packet when available.