PCD File Format Explanation & Modification - tkkim-robot/SLAM_Wiki GitHub Wiki
PCD(Point Cloud Data)
File format used by Point Cloud Library for storing data
The Point Cloud Library (PCL) is a standalone, large scale, open project for 2D/3D image and point cloud processing.
PCD File Structure
PCD File Example
# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 10
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 10
DATA ascii
0.93773 0.33763 0 4.2108e+06
0.90805 0.35641 0 4.2108e+06
0.81915 0.32 0 4.2108e+06
0.97192 0.278 0 4.2108e+06
0.944 0.29474 0 4.2108e+06
0.98111 0.24247 0 4.2108e+06
0.93655 0.26143 0 4.2108e+06
0.91631 0.27442 0 4.2108e+06
0.81921 0.29315 0 4.2108e+06
0.90701 0.24109 0 4.2108e+06
-
VERSION - specifies the PCD file version
-
FIELDS - specifies the name of each dimension/field that a point can have.
FIELDS x y z # XYZ data
FIELDS x y z rgb # XYZ + colors
FIELDS x y z normal_x normal_y normal_z # XYZ + surface normals
FIELDS j1 j2 j3 # moment invariants
- SIZE - specifies the size of each dimension in bytes.
unsigned char/char has 1 byte
unsigned short/short has 2 bytes
unsigned int/int/float has 4 bytes
double has 8 bytes
- TYPE - specifies the type of each dimension as a char.
I - represents signed types int8 (char), int16 (short), and int32 (int)
U - represents unsigned types uint8 (unsigned char), uint16 (unsigned short), uint32 (unsigned int)
F - represents float types
-
COUNT - specifies how many elements does each dimension have. For example, x data usually has 1 element, but a feature descriptor like the VFH has 308. Basically this is a way to introduce n-D histogram descriptors at each point, and treating them as a single contiguous block of memory. By default, if COUNT is not present, all dimensions’ count is set to 1.
-
WIDTH - specifies the width of the point cloud dataset in the number of points.
-
HEIGHT - specifies the height of the point cloud dataset in the number of points.
# it can specify the total number of points in the cloud (equal with POINTS see below) for unorganized datasets.
WIDTH 307200
HEIGHT 1 # unorganized point cloud dataset with 307200 points
# it can specify the width (total number of points in a row) and height (total number of rows) of an organized point cloud dataset.
WIDTH 640 # Image-like organized structure, with 480 rows and 640 columns,
HEIGHT 480 # thus 640*480=307200 points total in the dataset
- VIEWPOINT - specifies an acquisition viewpoint for the points in the dataset. This could potentially be later on used for building transforms between different coordinate systems, or for aiding with features such as surface normals, that need a consistent orientation.
# The viewpoint information is specified as a translation (tx ty tz) + quaternion (qw qx qy qz). The default value is:
VIEWPOINT 0 0 0 1 0 0 0
- POINTS - specifies the total number of points in the cloud. As of version 0.7, its purpose is a bit redundant, so we’re expecting this to be removed in future versions.
POINTS 307200 # the total number of points in the cloud
- DATA - specifies the data type that the point cloud data is stored in. As of version 0.7, two data types are supported: ascii and binary.
DATA ascii # data stored in ascii type
- Data storage types
# in ASCII form, with each point on a new line
p_1
p_2
...
p_n
# in binary form, where the data is a complete memory copy of the pcl::PointCloud.points array/vector.
Split PCD File
There are problems when input over-sized(over 1GB) PCD file to Autoware. Autoware support to modify PCD map file
https://github.com/autowarefoundation/autoware/tree/master/ros/src/util/packages/map_tools
Map Tools A set of utility tools for map data
PCD Grid Divider PCD Grid Divider creates PCDs divided into grids from PCDs that are not divided into grids.
How to launch From a sourced terminal: rosrun map_tools pcd_grid_divider point_type grid_size output_directory input_pcd1 input_pcd2 ... point_type: PointXYZ | PointXYZI | PointXYZRGB
grid_size: integer (1,5,10,100...)
In the directory you specified, you will see PCDs that divided into grids. The naming rule is grid_sizelower bound of xlower bound of y.pcd
PCD Filter PCD Filter downsamples PCDs by voxel grid filter.
How to launch From a sourced termina: rosrun map_tools pcd_filter point_type leaf_size input_pcd1 input_pcd2 ... point_type: PointXYZ | PointXYZI | PointXYZRGB
leaf_size: double (1,5,10,100...)
The downsampled files are saved in the same directory as the input pcd file. The naming rule is leaf_size_original_name