ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Probably way too late for op, but i willl just put it here for anyone stumble upon here like myself. Instead of unpacking the color yourself, you can simply use ros_numpy to save yourself from the headache
pc=ros_numpy.numpify(data)
pc=ros_numpy.point_cloud2.split_rgb_field(pc)
points=np.zeros((pc.shape[0],3))
points[:,0]=pc['x']
points[:,1]=pc['y']
points[:,2]=pc['z']
rgb=np.zeros((pc.shape[0],3))
rgb[:,0]=pc['r']
rgb[:,1]=pc['g']
rgb[:,2]=pc['b']
I formatted it this way to use it in open3d, but obviously you can reformat it to anything you like with numpy