Closed veqcc closed 3 months ago
As described here http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/PointCloud2.html, the point cloud.data
field is the array of 8bits and a specific chunk of the part of array represents float values of XYZ, namely [stride i, stride i + offset_x + offset_y + offset_z] bytes.
I think your example is not correct because the test data is a single uchar.
@soblin Thank you for your quick review!
As described here http://docs.ros.org/en/melodic/api/sensor_msgs/html/msg/PointCloud2.html, the point cloud.data field is the array of 8bits and a specific chunk of the part of array represents float values of XYZ, namely [stride i, stride i + offset_x + offset_y + offset_z] bytes.
I'm sorry I missed the document. I understand your point and it makes sense.
@veqcc I think we should explicitly write something like clang-format off
in that part to suppress error reports from sanitizers tools.
Agreed 👍
Checklist
Description
In
perception/image_projection_based_fusion/src/pointpainting_fusion/node.cpp
, there are several castings fromunsigned char
tofloat
:As the CppCheck warnning shows, this conversion may not be correct. For example, even if
unsigned char c = 10
, the casted value is not10.0f
.Here is my simple test program:
Output:
This is because the casted float value is really small.
10
as unsigned char has0x00001010
bit expression. This is casted to 32 bit flaot value0x 0 00000000 00000000000000000001010
. And it is interpreted as the following:Question
I have one question: is it a expected behavior? I know that sometimes the bit expressions are more important than the actual values.
Expected behavior
See Description.
Actual behavior
See Description.
Steps to reproduce
See Description.
Versions
No response
Possible causes
No response
Additional context
No response