ros-visualization/rviz — pull request #761 by Eruditass (2014-05-02 19:13:30+00:00)
Title: correctly display selected point's rgb information when registered as a float 

When the rgb information is registered as a float, it should still be interpreted as packed uint8s in a uint32, but the existing code static_casts it into a float when reading it out, manipulating the raw data.
When the rgb(a) information is registered as a uint32, this is correctly handled. The PCL spec seems to state that rgb is registered as a float, while rgba is registered as a uint32, though rviz does not appear to handle the transparency channel.

http://docs.pointclouds.org/1.7.0/structpcl_1_1_point_x_y_z_r_g_b_normal.html
http://docs.pointclouds.org/1.7.0/structpcl_1_1_point_x_y_z_r_g_b_a.html

Here is where one of the problems occurs:

default_plugin/point_cloud_common.cpp:193
default_plugin/point_cloud_transformers.h:96

As @wjwwood and @hersh correctly assert in #701 , changing them all to reinterpret_casts is clearly not a good idea.

What I suggest is minimal modification, simply requesting the value as a float if it is registered as a float to avoid manipulation during the cast, then doing the casting as expected. That way there is no modification to valueFromCloud or when the registered value is uint32

Additionally, there is a minor error that does not mask out data stored in the upper 8 bits. See the reference and implementation in another rviz file or the PCL documentation:
default_plugin / point_cloud_transformers.cpp :329
http://docs.pointclouds.org/1.7.0/structpcl_1_1_point_x_y_z_r_g_b_a.html