Implement DriveWorks Lidar Plugin for custom lidar

Refer to the gps plugin sample, I try to implement the lidar plugin.
I got an error about BufferPool.

undefined reference to dw::plugins::common::BufferPool<Packet_>::~BufferPool()' undefined reference to dw::plugins::common::BufferPool<Packet_>::get(Packet_*&, int)’
undefined reference to dw::plugins::common::BufferPool<Packet_>::put(Packet_*&, int)' undefined reference to dw::plugins::common::BufferPool<Packet_>::BufferPool()’

I have tried everything I could, but I can’t solve the problem.
Can anyone give any advice? Thanks.

.
2 ├── CMakeLists.txt
3 ├── common
4 │ ├── BufferPool.h
5 │ ├── ByteQueue.h
6 │ ├── PacketInput.h
7 │ ├── Pandar40p.h
8 │ ├── point_types.h
9 │ ├── TcpCommandClient.h
10 │ └── Util.h
11 └── lidar
12 ├── BufferPool.cpp
13 ├── ByteQueue.cpp
14 ├── CMakeLists.txt
15 ├── main.cpp
16 ├── PacketInput.cpp
17 ├── Pandar40p.cpp
18 ├── TcpCommandClient.c
19 └── Util.c

It’s the structure of my files. Hopes it help.

Hello leepeter909,
can you share your code?
Also, have you gone through the webinar “Integrating Custom Sensors Using NVIDIA DriveWorks”?

Thank you very much!
It helps a lot.
The error happened at host compilation, but it did’t happen at cross compilation.
Is that correct that it can’t do host compilation for building plugin .so file?

Hi ShayNV,
I have another question for the webinar.
At 23:40, there is a diagram of live decoding sequence diagram.
I did not see how _dwSenserPlugin_returnRawData() function return the raw data.
I would really like to know the workflow of this diagram.
Thank you very much!

Hi @leepeter909,

please note the all the APIs in the diagram are explained in details later on in the video.
please refer to the webinar at time 30:30.

good luck

Hi @shayNV,
I have another question about DriveWorks lidar plugin.
I got the data and assign to the data parameter of readRawData.
But I got different address of data in pushData function so that I couldn’t parse the data correctly.
It seems to be same data for me to use in pushData.

Here is my code.
dwStatus readRawData(const uint8_t** data, size_t* size, dwTime_t* timestamp)
{

*data = reinterpret_cast<uint8_t>(packet);
std::cout << “data address in readRawData:” << data << std::endl;
}

dwStatus PandarLidar40p::pushData(const uint8_t* data, const size_t size, size_t* lenPushed)
{

std::cout << “data address in pushData:” << &data << std::endl;

}

Is that the problem of my packet Struture?
How can I correct them?

The structure of my packet:
typedef struct Packet {
double stamp;
uint8_t data[ETHERNET_MTU];
uint32_t size;
} Packet;

Thank you very much!

Hi @leepeter909,
please notice that on every one of your functions the data variable is of a different type, the first is a pointer of a memory where the information address is stored, while the second is a pointer to the information directly.

so, first, notice that you are assigning to the address where the variable data points to a value of type uint8_t while the expected assignment is uint8_t* (and also the type of variable packet is unknown, which should be a pointer type, is it?)

second:

  1. in function readRawData: you are printing the pointer address to your information that is passed by value to the function.
    Instead, if you wanted to print the information address you should have printed the content of what data is pointing to = *(data)
  2. in function pushData: you are again printing the pointer address to your information that is the address of a local variable, a local variable is expected to have a different address in different functions and even in the same function with different calls, as the address is in the stack address space and not global/dynamic address space.
    Instead, if you wanted to print the information address you should have printed the content of the local variable = (data)

Hi @shayNV,
Thank you very much. I know that I was wrong.
The thing that I want to do is to check whether the two data content is same or not.

std::cout << “data content in readRawData:” << *data << std::endl; // blank
std::cout << “data content in pushData:” << data << std::endl; // not blank

There is still something strange that I can not get the same data.

Here is what I did.
I followed the original sample but got wrong result.

In readRawData:
Packet *packet;
*packet = getPacket(); // pseudo
*data = reinterpret_cast<uint8_t>(packet);

In pushData:
m_buffer.enqueue(data, size);

In parseData:
const Packet* packet;
if (!m_buffer.peek(reinterpret_cast<const uint8_t**>(&packet)))
{
return DW_FAILURE;
}
std::cout << “packet->size in parseData:” << packet->size << std::endl; // wrong!

How can I get the data and parse it correctly?

Thank you!

Hi @leepeter909,
I still think you have a bug in your code when assigning data for pointers.
please try to see if you have a relevant warning when compiling that might suggest where is your bug.
I think refreshing your practice with pointers would also be useful for your task.

Hi @shayNV,
Thank you very much!
I will try to figure out how to deal with the pointers.

I have another question.
I use DriveWorks sample, sample_lidar_replay to show the custom lidar data with my lidar plugin.
The question is that I can’t get my lidar device name.
I have defined the function _dwSensorLidarPlugin_getDecoderConstants to set the lidar properties, but the sample still showed the UNKNOWN_LIDAR.

dwStatus _dwSensorLidarPlugin_getDecoderConstants(_dwSensorLidarDecoder_constants *constants, dwSensorPluginSensorHandle_t sensor)
{

strcpy(constants->properties.deviceString, std::string(“CustomLidar”).c_str());
}

How can I set the deviceString correctly?

I found that if I set the device string to CUSTOM_EX by doing this:
strcpy(constants->properties.deviceString, std::string(“CUSTOM_EX”).c_str());
that will set the device name correctly.

Then I try to use the way that the sample point_cloud_processing do to concatenate the lidar point clouds, but it failed.
The dwPointCloudAccumulator_initialized don’t suppprt the CUSTOM_EX device.
How can I fix this problem?

Hello @leepeter909,
I noticed you opened a new topic on the new problem you are facing:

closing this topic.

Please use business email for future queries… Thanks.