Lidar Plugin Sample#
Description#
The lidar plugin sample implements a sensor driver for a UDP/TCP-based lidar using the comprehensive sensor plugin framework. It can be used to replay sample raw data provided with the SDK (see Lidar Replay Sample), visualize and record live data.
It also provides sources for a reference counted BufferPool data structure that may be used as reference for other implementations.
The NV Lidar Plugin#
This lidar plugin compiles into a shared library (*.so) that serves as a reference on how to implement a lidar plugin that is compatible with
the DriveWorks Sensor Abstraction Layer (SAL).
Note
The precompiled decoder library is called libsample_nv_lidar_plugin.so. The provided reference implementation can be used as a
template for other sensor implementations. A step by step code walk-through including a development environment that lets one work with the
reference code and deploy the plugin can be accessed through the DLI course Integrating Sensors with NVIDIA
DRIVE
Live data visualization#
./sample_lidar_replay --protocol=lidar.custom
--params=device=CUSTOMEX,
ip=XXX.XXX.XXX.XXX,
port=XXXXX,
protocol=[udp|tcp],
scan-frequency=[provide Hz value]
decoder-path=<path_to_lidar_plugin.so>
Data replay#
./sample_lidar_replay --protocol=lidar.virtual
--params=file=<path_to_lidar_recording.bin>,
decoder-path=<path_to_lidar_plugin.so>
Data recording#
See also Basic Recording Tool.
./recorder <path_to_rig_file>
Note
A rig file that is setup to use the plugin is already provided with the SDK and is called nv_lidar_plugin_rig.json.
In the following sections, an overview of the implementation details and suggested project structure when developing a plugin for a custom lidar sensor will be provided.
Note
For more details about the plugin interface for lidars see Custom Lidars (Comprehensive).
NV Lidar Plugin Walkthrough#
The NV lidar plugin is a generic lidar sensor simulation that mimics a lidar with the following specifications:
Supported Protocols |
UDP/TCP |
Scan-Frequency |
30 Hz |
Maximum Point Cloud Size |
50000 |
Lidar Plugin Interface Definition#
The plugin framework defines a set of function pointer definitions which must be implemented and exported to the SAL. For lidar sensors, the plugin must have implementations for the function pointers defined in:
Common Interface
Lidar Plugin
In addition, the plugin must implement & export the function, dwSensorLidarPlugin_getFunctionTable(), which is the only C function that
needs to be exposed from the shared object. This allows the developer flexibility to implement internals of their plugin in C++, if necessary.
Project structure#
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.
NVLidar Plugin Project Structure#
The project is split into three components:
Implementation of sensor class with decoding logic:
NVLidar.cppNVLidar.hNVLidar.hpp
Plugin interface definition:
SensorCommonPlugin.hLidarPlugin.h
Mapping of sensor class functions to plugin function calls:
main.cpp
Implementing The NV Lidar Class#
NVLidar.cpp and NVLidar.h contain the sensor specific functionality needed to process the data being provided by the sensor along with
its initialization and life cycle management.
NVLidar_Properties.hpp 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.
The specific implementation details are all accessible in the respective project files for the NV Lidar plugin.
Specifics regarding the API function calls can be found in the Custom Lidars (Comprehensive) section.
Function Mapping#
Based on the interface definition the functions in the NVLidar class are mapped accordingly to their respective common sensor function call and sensor type specific function calls that the plugin API exposes. (see tables below)
Common Functions (see “Common Interface” in the DriveWorks API Reference):
API function |
NVLidar member function |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Lidar Specific Functions (see LidarPlugin.h):
API function |
NVLidar member function |
|---|---|
|
|
|
|
Naming of the sensor class functions does not have to follow the above chosen names as it is merely a suggestion.
Once the sensor class is implemented, one can proceed to map the functions according to the table lined out above. This happens in the project
file main.cpp which is the missing link between the API interface calls and the custom sensor class.
Once the respective functions are populated with their counter part in the custom lidar 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 dwSensorLidarPlugin_getFunctionTable() in
main.cpp).
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 lidar sensor data in a format that is usable within DriveWorks.