Ask Your Question
0

Extract a Volume of points from a PointCloud2 message

asked 2020-04-08 21:24:46 -0500

deepaktalwardt gravatar image

Hi all, I'm trying to achieve something simple, yet I can't seem to find a way to do this. I have a PointCloud2 (as a .pcd file) and a bounding box defined in the same frame as the PointCloud2. I want to extract all the points that lie inside that bounding box and save them as a new .pcd file with the centroid of the box set as the origin of that point cloud.

A sample bounding box looks like this:

"bbox": {
            "position": {
                "position": {
                    "y": -24.204870224, 
                    "x": 23.0722198486, 
                    "z": -2.88637971878
                }, 
                "orientation": {
                    "y": -0.0256392564625, 
                    "x": 0.01510348171, 
                    "z": 0.704603254795, 
                    "w": 0.708977282047
                }
            }, 
            "size": {
                "y": 1.84718394279, 
                "x": 3.94384384155, 
                "z": 1.66313385963
            }
        }

So I have the position (which I want to be the origin of the new PointCloud), the size of the box, and also the orientation as a quaternion.

How can I do this? Any pointers to PCL tutorials would be helpful as well. Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-04-09 03:48:47 -0500

What you want is exactly the box filter http://docs.pointclouds.org/trunk/cla...

All pcl filter derived classes can be inverted with the negative command as well so you get only the points contained inside the box.

edit flag offensive delete link more

Comments

Thanks, Steve! I'm not sure how I didn't stumble upon this before.

deepaktalwardt gravatar image deepaktalwardt  ( 2020-04-09 12:54:24 -0500 )edit

Steve, a follow-up question. Is there a way to visually draw these cropboxes in the original pointcloud so I could debug if I'm extracting the correct points? Or would there be a way to "color" the extracted points. I want to make sure I'm extracting the correct points before using them. Thank you.

deepaktalwardt gravatar image deepaktalwardt  ( 2020-04-22 15:54:50 -0500 )edit
1

All of those things are possible, but its pretty application specific. You could just trivially run this filter, take the inliers and publish to a topic with them and publish to another topic the outliers and display them in rviz with different colors. You could also pretty easily just stow the bounding box in the same way but using visualization_msgs markers. Either would work, just depends on what floats your boat more.

stevemacenski gravatar image stevemacenski  ( 2020-04-22 18:20:22 -0500 )edit

Thanks Steve, those make a ton of sense! I'm actually doing this filtering on a bunch of PCD files (and not from pointclouds streaming from ROS), do you know if I could do something similar without having to publish to RViz? I saw this question and was wondering if you had any clue what they are using here to render those boxes. https://stackoverflow.com/questions/6... And again, I really appreciate your help!

deepaktalwardt gravatar image deepaktalwardt  ( 2020-04-22 20:38:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-04-08 21:24:46 -0500

Seen: 26 times

Last updated: Apr 09