Fixed segmentation fault in depth_image_octomap_updater#2963
Fixed segmentation fault in depth_image_octomap_updater#2963sjahr merged 10 commits intomoveit:mainfrom
Conversation
There was a problem hiding this comment.
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
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. |
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