RGB color data in ChannelFloat32 of Pointcloud message not working
I have been trying to publish a point cloud message with RGB color data. The data is simple and I am just publishing a few points every frame. At the moment I am testing single point. There aren't many examples online and the documentation for this is not very useful either. From documentation I gather that following should work.
ch_rgb = ChannelFloat32("rgb", [0x00ffffff])
However it doesn't. I have tried this as well.
*pcl_msg = PointCloud()
pcl_msg.header.stamp = rospy.Time.now()
pcl_msg.header.frame_id = 'girona500'
pcl_msg.points.append(Point32(*mean_pnt))
ch_int = ChannelFloat32("intensity", [0x00])
ch_rgb = ChannelFloat32("rgb", [0xff])
r_channel = ChannelFloat32(name="r", values=[0xff])
g_channel = ChannelFloat32(name="g", values=[0xff])
b_channel = ChannelFloat32(name="b", values=[0xff])
pcl_msg.channels = (ch_int, ch_rgb, r_channel, g_channel, b_channel)
pub_pcl.publish(pcl_msg)*
Any ideas?
Asked by bvibhav on 2019-12-17 07:48:32 UTC
Answers
Found the solution. The issue is with conversion of unsigned integer being converted/packed into floating point. http://wiki.ros.org/rviz/DisplayTypes/PointCloud
In python, this could be done with struct.unpack('f', struct.pack('i', 0x00FF00))[0]
Asked by bvibhav on 2019-12-20 11:23:00 UTC
Comments