How to make an unordered pointcloud ordered with a given color image?
I have a pcd and png files (namely, a.pcd and a.png). Also, I have a ROS package (namely, MyROS), which receives ROS Image and PointCloud2 (XYZ), supposed to be ordered corresponding to the image.
I used pcd_to_pointcloud to publish a pointcloud. When I used the command like
rosrun pcl_ros pcd_to_pointcloud a.pcd [ interval ]
, I found that the resulting ros topic is a PointCloud2 with fields of X, Y, and Z (no RGB).
Also, the pointcloud is flattened, i.e., its height = 1.
I published ROS Image and PointCloud2 corresponding to the files and republish a pointcloud by changing its property with the published ROS Image, for example,
pcd_msg.height = image_msg.height
pcd_msg.width = image_msg.width
pcd_msg.row_step = image_msg.row_step
pcd_msg.point_step = image_msg.point_step
But it seems not to work with my package. More precisely, I used read_points but no points are read, which surely worked with an ordered pc streamed from my RealSense.
I may misunderstand the properties of PointCloud2. Can anybody help me?