Reading Radar PCD Binary Files

Hi,

I would like to read the Radar PCD files and have a question about your supplied files.

Looking at \v1.0 mini\sweeps\RADAR_FRONT\n008-2018-08-01-15-16-36-0400__RADAR_FRONT__1533151603630245.pcd I can read the header.

For this specific file the header is

.PCD v0.7 - Point Cloud Data file format

VERSION 0.7
FIELDS x y z dyn_prop id rcs vx vy vx_comp vy_comp is_quality_valid ambig_state x_rms y_rms invalid_state pdh0 vx_rms vy_rms
SIZE 4 4 4 1 2 4 4 4 4 4 1 1 1 1 1 1 1 1
TYPE F F F I I F F F F F I I I I I I I I
COUNT 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
WIDTH 125
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 125
DATA binary

Following the PCD spec document, I interpret the binary data to comprise of 125 sample points, where each sample point has a total for 43 bytes. I arrive at 43 bytes by the addition of the size values (SIZE 4 4 4 1 2 4 4 4 4 4 1 1 1 1 1 1 1 1).

If I multiply 43 * 125 the total number of binary data bytes should be (43 * 125) = 5375 bytes.

I assume that the binary data begins immediately after the “Data binary” string, in this case the binary data would start at byte 172. Assuming that the data size is 5375 bytes the data would start at byte 172 and finish at byte (172 + 5375) = 5547.

Looking at a binary view of the file, the last non zero byte value is at position 5760. As this is different to my calculated end position it must mean that:

  1. there is some other header between the “DATA binary” string and the start of the binary data, or
  2. there is some footer after the last set of point values, or
  3. my calculation of 43 bytes per sample set is incorrect

I have looked at your source at https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/utils/data_classes.py#L393 and cannot see anything immediately obvious.

Here is the binary view of the file, can you confirm which byte the binary data starts at please.

Hi, I suggest you simply use the provided code to parse it, rather than your own.
The conversion is based on how C structs work: https://docs.python.org/2/library/struct.html
I believe that the integers with size 1 (boolean) and 2 don’t actually take up an entire byte, but only e.g. a bit. Therefore your attempt to count the bytes did not quite work. I cannot guarantee that this is compatible with the pcd standard. I never tried opening these files in any external program.

PCL can convert the binary pcd file to ascii format.
pcl_viewer can also visualize in 3D.

I can confirm. On ubuntu you can install pcl_viewer with the following commands:

sudo apt-get update -y

and

sudo apt-get install -y pcl-tools

Then you can for example visualize a RADAR pointcloud with the following command:

pcl_viewer <PATH_TO_DATA_FOLDER>/data/nuscenes/samples/RADAR_FRONT_RIGHT/n008-2018-08-01-15-16-36-0400__RADAR_FRONT_RIGHT__1533151603512881.pcd

and I get something like this: