-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed segmentation fault in depth_image_octomap_updater #2963
Fixed segmentation fault in depth_image_octomap_updater #2963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always explain your changes!
This looks like a great data type mess: the data array of type uint8
should store floats (TYPE_32FC1
), but is passed as a double
pointer to getModelDepth()
, which might be the root cause of the segfault.
Now, you allocate an additional float
array (which takes extra time and memory), still pass it as a double
pointer (messing up the data) and finally copy the float data as unsigned short into the uint8 slots using some weird transformation. As the uint8
array is to be interpreted as a float array, this is definitely still wrong.
Have a look at the MoveIt1 implementation of that snippet, which seems to use the correct types.
It actually comes from moveit2/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp Lines 468 to 492 in aece55c
Hmm, thanks, i will give a try converting |
The referenced code looks wrong as well. Again, MoveIt1 code seems to be correct. Note the key difference that the referenced code snippet generates a 16bit unsigned int encoding ( |
df06cfc
to
fedd04c
Compare
I've updated based on Moveit1's implementation and it works. moveit2/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp Lines 486 to 490 in aece55c
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks better now. Now idea, why #2343 blindly converted all float args to double.
No. This code explicitly returns an unsigned short array, i.e. converting float meters into int millimeters. |
Thanks for referencing moveit1. The reason for the conversation is: https://github.com/cpp-best-practices/cppbestpractices/blob/master/08-Considering_Performance.md#prefer-double-to-float-but-test-first but apparently we ignore the |
I have surfed through the PR you mentioned and i also discovered that the evil is also here ( #1578 ) It can be necessary to revert some float-to-double conversions |
Description
The relavant issue: #2964
Checklist