Search in Pointcloud

img_kd

pointcloud 상에서 기준 point(query point)를 기준으로 search 하는 법은 크게

  • Radius search
  • k-nearest Neighbor search

가 있습니다. 먼저, Radius search는 pointcloud 상 주어진 query point의 거리 r 안에 있는 모든 point들의 index를 리턴해주는 함수입니다. 활용처는 크게 두가지가 있는데,

  • 여기처럼 모바일 플랫폼의 sensor frame 주변의 noise의 index를 추출해서 제거할 때 (하지만, 엄밀히 따지면 연산적으로 비효율적임)
  • 전체 map 상에서 global한 좌표를 기점으로 인근의 submap을 추출할 때 (예시는 여기)

등입니다.


How to use

아래는 두 query points query1query2에 대해 8m 이내로 인접해 있는 pointcloud를 추출하는 예제입니다.(52번 째 줄 부터)

img

위의 그림처럼, input cloud(빨강)가 주어졌을 때

  • query1의 위치인 (0, 0, 0) 이내의 8m 영역(초록색)
  • query2의 위치인 (20, 0, 0) 이내의 8m 영역(파란색)

을 추출해낼 수 있습니다.

주의하실 점은 KdTree는 setInputCloud()할 때 내부적으로 input pointcloud를 트리화하여 저장하기 때문에, time cost가 다소 존재한다는 것입니다. 하지만 한번 등록해두면 radiusSearch()를 통해 찾을 때는 단순히 for문을 돌리는 것보다는 훨씬 빠릅니다.

따라서 자신이 적용할 task가 KdTree를 사용하기 전에 inputcloud를 한 번 등록해두고 계속 search를 해야할 task인가를 검토하는 것이 중요합니다.


Point Cloud Library Tutorial 시리즈입니다.

모든 코드는 이 레포지토리에 있고, ros package로 구성되어 있어 build하여 직접 돌려보실 수 있습니다

  1. ROS Point Cloud Library (PCL) - 0. Tutorial 및 기본 사용법
  2. ROS Point Cloud Library (PCL) - 1. Ptr, ConstPtr의 완벽 이해 (1) shared_ptr
  3. ROS Point Cloud Library (PCL) - 1. Ptr, ConstPtr의 완벽 이해 (2) Ptr in PCL
  4. ROS Point Cloud Library (PCL) - 1. Ptr, ConstPtr의 완벽 이해 (3) Ptr in 클래스 멤버변수
  5. ROS Point Cloud Library (PCL) - 2. 형변환 - toROSMsg, fromROSMsg
  6. ROS Point Cloud Library (PCL) - 3. Transformation
  7. ROS Point Cloud Library (PCL) - 4. Viewer로 visualization하는 법
  8. ROS Point Cloud Library (PCL) - 5. Voxelization
  9. ROS Point Cloud Library (PCL) - 6. PassThrough
  10. ROS Point Cloud Library (PCL) - 7. Statistical Outlier Removal
  11. ROS Point Cloud Library (PCL) - 8. KdTree를 활용한 Radius Search
  12. ROS Point Cloud Library (PCL) - 9. KdTree를 활용한 K-nearest Neighbor Search (KNN)
  13. ROS Point Cloud Library (PCL) - 10. Normal Estimation
  14. ROS Point Cloud Library (PCL) - 11. Iterative Closest Point (ICP)
  15. ROS Point Cloud Library (PCL) - 12. Generalized Iterative Closest Point (G-ICP)