DriveWorks SDK Reference
5.0.0 Release
For Test and Development only

samples/sensors/plugins/radar/README-NV_radar_plugin.md
Go to the documentation of this file.
1 # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
2 
3 @page dwx_nv_radar_plugin_sample Radar Plugin Sample
4 @tableofcontents
5 
6 @section dwx_nv_radar_plugin_sample_description Description
7 
8 The RADAR Plugin sample implements a sensor driver for a UDP/TCP-based RADAR using the comprehensive sensor plugin framework. It can be used to replay sample raw data provided with the SDK (see @ref dwx_radar_replay_sample), visualize and record live data created by the sensor simulation tool. (see @ref dwx_sensor_simulator_tool)
9 
10 It also provides sources for a refcounted-`BufferPool` data structure that may be used as reference for other implementations.
11 
12 @section dwx_nv_radar_plugin_sample_run Using The NV Radar Plugin
13 
14 This radar plugin compiles into a shared library (.so) that serves as a reference on how to implement a radar plugin that is compatible with the DriveWorks Sensor Abstraction Layer (SAL).
15 <br>
16 
17 @note The precompiled decoder library is called 'libsample_nv_radar_plugin.so'.
18 
19 <br>
20 
21 <b>Live data visualization:</b>
22 
23  ./sample_radar_replay --protocol=radar.custom
24  --params=device=CUSTOM_EX,
25  ip=XXX.XXX.XXX.XXX,
26  port=XXXXX,
27  protocol=[udp|tcp],
28  decoder-path=<path_to_radar_plugin>
29 
30 <b>Data replay:</b>
31 
32  ./sample_radar_replay --protocol=radar.virtual
33  --params=file=<path_to_radar_recording.bin>,
34  decoder-path=<path_to_radar_plugin>
35 
36 <b>Data recording(see @ref dwx_recording_tools):</b>
37 
38  ./recorder <path_to_rig_file>
39 
40 @note A rig file that is setup to use the plugin is already provided with the SDK and is called nv_radar_plugin_rig.json.
41 
42 In the following sections, an overview of the implementation details and suggested project structure when developing a plugin for a custom radar sensor will be provided.
43 <br>
44 
45 @note For more details about the plugin interface for radars see @ref sensorplugins_radarsensor.
46 <br>
47 
48 @section dwx_nv_radar_plugin_sample_walk_through NV Radar Plugin Walkthrough
49 
50 The NV RADAR is a generic radar sensor simulation that mimicks a radar with the following specifications:
51 
52  Supported protocols: UDP/TCP
53  Scan-frequency: 20 Hz
54  Maximum detections: 100
55 
56 See @ref dwx_sensor_simulator_tool for more information on how to start the simulation of this radar.
57 
58 @subsection dwx_nv_radar_plugin_sample_plugin_interface Radar Plugin Interface Definition
59 
60 The plugin framework defines a set of function pointer definitions which must be implemented and exported to the SAL. For Radar sensors, the plugin must have implementations for the function pointers defined in:
61 
62 * @ref sensor_plugins_ext_common_group
63 * @ref sensor_plugins_ext_radar_group
64 
65 In addition, the plugin must implement & export the function, `dwSensorRadarPlugin_getFunctionTable()`, which is the only C function that needs to be exposed from the shared object.
66 This allows the developer flexibility to implement internals of their plugin in C++, if necessary.
67 
68 @subsection dwx_nv_radar_plugin_sample_project_structure Project structure
69 
70 The file setup for the plugin implementation is depicted in the following image. It is not an obligatory project setup, but rather a recommendation which is easy to maintain and which this plugin implementation follows.
71 
72 @note The provided sample implementation can be used as a template for other sensor implementations.
73 
74 ![NV Radar Plugin Project Structure](radar_plugin_file_overview.png)
75 <br>
76 
77 The project is split into three components:
78 
79 * Implementation of sensor class with decoding logic:
80  * NVRadar.cpp
81  * NVRadar.h
82  * NVRadar.hpp
83 * Plugin interface definition:
84  * SensorCommonPlugin.h
85  * RadarPlugin.h
86 * Mapping of sensor class funcitons to plugin function calls:
87  * main.cpp
88 <br>
89 
90 @subsection dwx_nv_radar_plugin_sample_custom_radar_class Implementing The NV Radar Class
91 
92 <b>NVRadar.cpp</b> and <b>NVRadar.h</b> contain the sensor specific functionality needed to process the data being provided by the sensor along with its initialization and life cycle management.
93 
94 <b>NVRadar_Properties.hpp </b>contains characteristics of the data stream which are utilized in the decoding logic as well as information on the layout of the data structures the received raw data is expected to map to.
95 
96 The specific implementation details are all accessible in the respective project files for the NV Radar plugin.
97 
98 Specifics regarding the API function calls can be found in the @ref sensorplugins_radarsensor section.
99 
100 @subsection dwx_nv_radar_plugin_sample_function_mapping Function Mapping
101 
102 Based on the interface definition the functions in the NVRadar class are mapped accordingly to their respective common sensor function call and sensor type specific funciton calls that the plugin API exposes. (see tables below)
103 <br>
104 
105 <b> Common Functions </b>(see @ref sensor_plugins_ext_common_group): <br>
106 
107 | API function | NVRadar member function |
108 |:---|:---|
109 | `dwSensorPlugin_createHandle()` | `NVRadar()` |
110 | `dwSensorPlugin_release()` | `CloseFileDescriptor()` |
111 | `dwSensorPlugin_createSensor()` | `CreateSensor()` |
112 | `dwSensorPlugin_start()` | `StartSensor()` |
113 | `dwSensorPlugin_stop()` | `StopSensor()` |
114 | `dwSensorPlugin_reset()` | `ResetSensor()` |
115 | `dwSensorPlugin_readRawData()` | `ReadRawData()` |
116 | `dwSensorPlugin_returnRawData()` | `ReturnRawData()` |
117 | `dwSensorPlugin_pushData()` | `PushRawData()` |
118 
119 <b> Radar Specific Functions </b>(see RadarPlugin.h): <br>
120 
121 | API function | NVRadar member function |
122 |:---|:---|
123 | `dwSensorRadarPlugin_parseDataBuffer()` | `ParseDataBuffer()` |
124 | `dwSensorRadarPlugin_getDecoderConstants()` | `GetDecoderConstants()` |
125 | `dwSensorRadarPlugin_validatePacket()` | `ValidatePacket()` |
126 
127 Naming of the sensor class functions does not have to follow the above chosen names as it is merely a suggestion.
128 
129 Once the sensor class is implemented, one can proceed to map the functions according to the table lined out above.
130 
131 This happens in the project file <b>main.cpp</b> which is the missing link between the API interface calls and the custom sensor class.
132 
133 Once the respective functions are populated with their counter part in the custom radar sensor class in the main.cpp project file, the last step is to map the those functions in the function table that is used by the SAL to access them (see `dwSensorRadarPlugin_getFunctionTable()` in main.cpp).
134 
135 At this point the plugin implementation is complete and the project can be compiled to a shared library, ready to be used with DriveWorks. This enables processing of the custom radar sensor data in a format that is usable within DriveWorks.