Repository navigation
Lay out organized point clouds as (height, width) - #355
Open
Rahul-cs50 wants to merge 1 commit into
Open
Rahul-cs50 wants to merge 1 commit into
Rahul-cs50 wants to merge 1 commit into
Conversation
PointCloud2 stores an organized cloud row by row, with `width` points per row. read_points(reshape_organized_cloud=True) reshaped the points to (width, height), so element [r, c] was not the point in row r and column c. create_cloud() made the matching mistake in the other direction and took the array's first axis as the width, which also gave a wrong row_step. Reshape to (height, width) and read height and width from an organized array in that order. The organized test fixture had the same transposed layout and is corrected; a new test checks the point position on a non-square cloud. Fixes ros2#236 Signed-off-by: Rahul-cs50 <rahulseervi.dev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #236
Description
An organized
PointCloud2stores its points row by row,widthpoints per row. Withreshape_organized_cloud=True,read_points()reshapes them to(width, height). The shape looks transposed, but the problem is worse than that. The data is never transposed, only re-cut, so element[r, c]is generally not the point in rowrand columnc. For a cloud with height 2 and width 3 holdingx = row, y = column:create_cloud()had the matching mistake. For a 2D array it setwidth = shape[0]andheight = shape[1], so the message also got a wrongrow_step, and any other consumer (C++ iterators, RViz, PCL) read the rows wrongly. The two errors cancelled out in a Python round trip, which is why the existing tests passed.The fix reshapes to
(height, width)and reads an organized array asheight, width = points.shape, the same[row, column]convention that images and numpy use. This changes the shape returned for organized clouds. As @mjcarroll and @jdlangs said in the issue, the old layout was wrong, not just a different convention.Tests
pcd3had the same transposed layout (width=shape[0]), and it is corrected.test_read_points_organized_row_majorbuilds a non-square cloud withcreate_cloud_xyz32. It checksheight,width,row_stepand that each point is at[row, column].In a
ros:rolling-ros-basecontainer,test_point_cloud2.pyhas 19 passed. On the current code, 3 fail: the two organized tests and the new one.