Please provide the following info (check/uncheck the boxes after creating this topic):
Software Version
DRIVE OS Linux 5.2.6
DRIVE OS Linux 5.2.0
DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version
other
Target Operating System
Linux
QNX
other
Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)
other
SDK Manager Version
1.6.1.8175
1.6.0.8170
other
Host Machine Version
native Ubuntu 18.04
other
This is a continuation of the following topic:
I’ve set up all I need and the first header send by CarMaker was received by DriveWorks with a content noting, that CarMaker is connected as a data transmitter. However, the length variable is greater zero (=64 bytes) only in the functions _dwRadarDecoder_validatePacket and _dwRadarDecoder_synchronize, in _dwRadarDecoder_decodePacket length is always zero.
I would like to confirm the received data and process it in _dwRadarDecoder_decodePacket, but I don’t know how it’s developed in the background to forward the buffer and length values from _dwRadarDecoder_validatePacket or _dwRadarDecoder_synchronize to _dwRadarDecoder_decodePacket?
Following code is currently implemented (see comments for details - especially for _dwRadarDecoder_decodePacket):
#include <dw/sensors/plugins/radar/RadarDecoder.h>
#include <dw/sensors/plugins/radar/RadarPlugin.h>
#include <iostream>
dwStatus _dwRadarDecoder_initialize () {
// Indicator, which function gets executed:
std::cout << "1" << std::endl;
return DW_SUCCESS;
}
dwStatus _dwRadarDecoder_release() {
// Indicator, which function gets executed:
std::cout << "2" << std::endl;
return DW_SUCCESS;
}
dwStatus _dwRadarDecoder_decodePacket (
dwRadarScan * output,
const uint8_t * buffer,
const size_t length,
const dwRadarScanType scanType )
{
(void) output;
(void) scanType;
// For unknown reasons "buffer" is always empty declared by "length" equal to zero for every loop?
std::cout << "Buffer: " << *buffer << " - Length: " << length << std::endl;
// Indicator, which function gets executed:
std::cout << "3" << std::endl;
// When length is greater than zero, output the buffer content to screen
// and abort the application before filling out the shell with new lines.
// In this way I want to see if it ever happens that length is greater than
// zero, which indicates that data is existing to be decoded.
if (length > 0)
{
for (size_t i = 0; i < length; i++)
{
std::cout << buffer[i];
}
std::cout << std::endl;
abort();
}
return DW_SUCCESS;
}
// Setting up all constants and properties of the sensor.
// Only detections will be received, hence no other data is required to be set up.
dwStatus _dwRadarDecoder_getConstants(_dwRadarDecoder_constants * constants)
{
constants->properties.supportedScanTypes[DW_RADAR_RETURN_TYPE_DETECTION][DW_RADAR_RANGE_LONG] = 1;
constants->properties.maxReturnsPerScan[DW_RADAR_RETURN_TYPE_DETECTION][DW_RADAR_RANGE_LONG] = 2000;
constants->properties.scansPerSecond=1;
constants->properties.isDecodingOn=1;
constants->properties.numScanTypes=1;
constants->properties.packetsPerScan = 1;
constants->properties.inputPacketsPerSecond = 0;
constants->headerSize = 64;
constants->maxPayloadSize = 2048;
constants->vehicleStateSize = 0;
constants->mountSize = 0;
// Indicator, which function gets executed:
std::cout << "4" << std::endl;
return DW_SUCCESS;
}
dwStatus _dwRadarDecoder_synchronize (
const uint8_t * buffer,
const size_t length,
size_t * remaining)
{
(void) buffer; // Currently not used
// Set remaining data to zero, when first message of 64 bytes is received.
// Is this required to provide the data to the "_dwRadarDecoder_decodePacket(...)" function?
// This will be correctly set when the first message is received from CarMaker
if (length == 64) {
*remaining = 0;
}
// Indicator, which function gets executed:
std::cout << "5" << std::endl;
return DW_SUCCESS;
}
dwStatus _dwRadarDecoder_validatePacket (
const uint8_t* buffer,
const size_t length,
dwRadarScanType* scanType)
{
(void) buffer; // Currently not used
(void) length; // Currently not used
// Required, otherwise segmentation fault.
scanType->range = DW_RADAR_RANGE_LONG;
scanType->returnType = DW_RADAR_RETURN_TYPE_DETECTION;
// Indicator, which function gets executed:
std::cout << "6" << std::endl;
return DW_SUCCESS;
}
bool _dwRadarDecoder_isScanComplete (
dwRadarScanType scanType,
const uint8_t ** buffer,
size_t * length,
size_t numPackets
)
{
(void) scanType; // Currently not used
(void) buffer; // Currently not used
(void) length; // Currently not used
// Tried to set up the numPackets in the hope that
// _dwRadarDecoder_decodePacket(...) will be provided with data.
// Had no effect.
numPackets = 1;
// Indicator, which function gets executed:
std::cout << "7" << std::endl;
return true;
}
dwStatus _dwRadarDecoder_encodeVehicleState (
uint8_t * buffer,
const size_t maxOutputSize,
const dwRadarVehicleState * packet
)
{
(void) buffer; // Currently not used
(void) maxOutputSize; // Currently not used
(void) packet; // Currently not used
// Indicator, which function gets executed:
std::cout << "8" << std::endl;
return DW_SUCCESS;
}
dwStatus _dwRadarDecoder_encodeMountPosition (
uint8_t * buffer,
const size_t maxOutputSize,
const dwRadarMountPosition * packet
)
{
(void) buffer; // Currently not used
(void) maxOutputSize; // Currently not used
(void) packet; // Currently not used
// Indicator, which function gets executed:
std::cout << "9" << std::endl;
return DW_SUCCESS;
}
When exactly will the data located in buffer with the buffer length indicator “length” be forwarded to the _dwRadarDecoder_decodePacket function? What are the requirements?
I’m trying to understand the concept and structure of the decoder step by step, since the documentation doesn’t explain this in detail.