Debugging의 필수, visualization

오늘은 pcl pointcloud를 visualization하는 방법에 대해 알아보겠습니다.

대부분 ROS의 RViz로 visualization을 하실텐데, 간단히 몇개의 포인트를 볼 때는 저의 개인적인 소견으로는 pcl viewer가 훨씬 간편한 것 같습니다.

방법은 크게 PCLVisualizer를 사용하는 법과 CloudViewer 사용하는 법으로 크게 나뉘어져 있습니다.

실행시키면 다음과 같이 앞으로 5m transformation된 pointcloud와 raw한 데이터가 함께 visualization되는 것을 볼 수 있습니다.

pcl_color

주의점 1

주의하실 점은, 본인이 원하고자 하는 색상으로 visualization을 하고 싶으실 때, pcl::PointXYZGRB type으로 색을 입혀주셔야 원하는 색으로 visualization이 됩니다.

(colorize 함수 참고)

viewer1.addPointCloud<pcl::PointXYZ>(src, "src_red");
viewer1.addPointCloud<pcl::PointXYZ>(tgt, "tgt_green");

만약 이렇게 raw한 PointXYZ를 넣으면 어떻게 될까요?

pcl_raw

칼라가 없기 때문에 둘 다 그냥 흰색으로 visualization이 됩니다.

주의점 2

id에는 꼭 각각 다른 이름을 넣어야 합니다! 만약 id가 똑같으면 visualizer가 다음과 같은 경고를 하면서 가장 먼저 그 id를 할당 받은 pointcloud만 visualization을 해줍니다.

만약 실수로 아래와 같이 썼으면 어떻게 될까요?

viewer1.addPointCloud<pcl::PointXYZRGB>(src_colored, "src_red");
viewer1.addPointCloud<pcl::PointXYZRGB>(tgt_colored, "src_red");

[addPointCloud] The id already exists! Please choose a different id and retry.

라는 warning message가 뜨면서 빨간 src_colored 밖에 viz가 되지 않는 것을 볼 수 있습니다.


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)