-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add get3DPatch to ViewPicker public API #657
Add get3DPatch to ViewPicker public API #657
Conversation
8fdd91c
to
9f25d21
Compare
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.
The changes look okay to me. It would be nicer to keep the bug fix separate from the API change. It'll make it easier to backport the fix independent of the API change, for example. If you don't mind, could you open a separate API with the bug fix?
uint8_t c = data_ptr[4 * pixel + 2]; | ||
uint8_t a = data_ptr[3 * pixel]; | ||
uint8_t b = data_ptr[3 * pixel + 1]; | ||
uint8_t c = data_ptr[3 * pixel + 2]; |
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.
Interesting. I took a look through the code, and I think we expect three values per pixel because of the format set here:
Ogre::PF_R8G8B8, |
It's possible in ROS 1, the format included an alpha channel, hence 4 bytes. It might be a good idea to assert that the pixel box data is three-channel, prior to extracting values. Could you try adding the following before this loop?
assert(Ogre::PF_R8G8B8 == depth_pixel_box_.format);
It might be worth leaving that in there just in case, or at least referencing in a comment where this format is coming from.
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.
I added this assert and an explanatory comment in #661
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.
I was trying to figure out where this actually changed as well, unfortunately without much success so far. The depth_render_texture_
is initialized with the same PF_R8G8B8
enum value in Melodic and Noetic RViz:
depth_render_texture_ = Ogre::TextureManager::getSingleton().createManual(
tex_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
depth_texture_width_, depth_texture_height_, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
9f25d21
to
308f99c
Compare
308f99c
to
08d0ca2
Compare
I moved the bug fix to a new PR at #661. That's definitely a more sensible way to arrange things -- I was only thinking about getting these functions working in order to make my code work! |
ViewPicker::get3DPatch is currently a private member function of the ViewPicker class. It would be very useful to make it public, since this lets us develop plugins that can use the orientations of mesh surfaces and point clouds in the 3D scene. This change moves it from the private API to the public API. Signed-off-by: Joe Schornak <joe.schornak@gmail.com>
08d0ca2
to
6466b2b
Compare
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.
ViewPicker::get3DPatch
is currently a private member function of the ViewPicker class. It would be very useful to make it public, since this lets us develop plugins that can use the orientations of mesh surfaces and point clouds in the 3D scene. This change moves it from the private API to the public API.Additionally, the method in which OGRE packs depth pixel data has changed in the version currently used by RViz2. In ROS Melodic RViz eachuint32
pixel was represented by 4 sequentialuint8
elements in an array, but only the first 3 elements actually contained useful data and the 4th element was discarded. In the current version (I'm testing with Foxy right now) it looks like each depth pixel is now represented by just 3 sequentialuint8
elements, without the 4th "empty" index. This means that the previous method of accessing the data for each pixel by index relative to the start of the array no longer works correctly and returns mangled or misaligned data for all pixels after the first. A change to the data pointer indexing method in theViewPicker::getPatchDepthImage
function was needed to correctly calculate distances from the scene camera when getting patches containing more than one pixel.The data indexing bug did not cause problems previously because it does not affect the depth value for the first pixel in the array.ViewPicker::getPatchDepthImage
is only used byViewPicker::get3DPatch
, which is itself only used byViewPicker::get3DPoint
to get a single-pixel patch. This issue is also somewhat challenging to demonstrate, since I think the current RViz test suite only uses mock versions of these functions.#661 now contains the pixel byte indexing fix described above which was originally part of this PR.
Signed-off-by: Joe Schornak joe.schornak@gmail.com