Skip to content
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

Fix byte indexing for depth patch pixels in ViewPicker::getPatchDepthImage #661

Merged

Conversation

schornakj
Copy link
Contributor

Originally in #657; split off to separate a bugfix from an API change.

The method in which OGRE packs depth pixel data has changed in the version currently used by RViz2. In ROS Melodic RViz each uint32 pixel was represented by 4 sequential uint8 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 sequential uint8 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 the ViewPicker::getPatchDepthImage function was needed to correctly calculate distances from the scene camera when getting patches containing more than one pixel. A new assert checks that the depth patch uses the expected data format before accessing pixel data.

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 by ViewPicker::get3DPatch, which is itself only used by ViewPicker::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.

Signed-off-by: Joe Schornak joe.schornak@gmail.com

Depth pixel data is now represented by a series of 3-byte sets, rather than a
series of 4-byte sets as it was in ROS1 RViz. This means that the previous method
used to access pixel data by index relative to the start of the depth patch array
does not work correctly, and that each pixel after the first will be composed
incorrectly. This change modifies the pixel indexing method to use sets of 3
bytes instead, and adds an assert to ensure that the depth patch uses the
expected data format before accessing pixel data.

Signed-off-by: Joe Schornak <joe.schornak@gmail.com>
@schornakj schornakj force-pushed the fix/ogre-depth-patch-pixel-indexing branch from 03888fd to f1ed337 Compare March 12, 2021 17:35
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, and for splitting it into a separate PR 🙂

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron merged commit 3bfcebd into ros2:ros2 Mar 16, 2021
jacobperron pushed a commit that referenced this pull request Aug 31, 2021
Depth pixel data is now represented by a series of 3-byte sets, rather than a
series of 4-byte sets as it was in ROS1 RViz. This means that the previous method
used to access pixel data by index relative to the start of the depth patch array
does not work correctly, and that each pixel after the first will be composed
incorrectly. This change modifies the pixel indexing method to use sets of 3
bytes instead, and adds an assert to ensure that the depth patch uses the
expected data format before accessing pixel data.

Signed-off-by: Joe Schornak <joe.schornak@gmail.com>
jacobperron added a commit that referenced this pull request Sep 13, 2021
Depth pixel data is now represented by a series of 3-byte sets, rather than a
series of 4-byte sets as it was in ROS1 RViz. This means that the previous method
used to access pixel data by index relative to the start of the depth patch array
does not work correctly, and that each pixel after the first will be composed
incorrectly. This change modifies the pixel indexing method to use sets of 3
bytes instead, and adds an assert to ensure that the depth patch uses the
expected data format before accessing pixel data.

Signed-off-by: Joe Schornak <joe.schornak@gmail.com>

Co-authored-by: Joseph Schornak <joe.schornak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants