Transformation을 하는 이유?

tf

Robotics 분야에서 개발/연구를 하다보면 밥먹듯이 해야하는 것이 transformation입니다. 왜냐하면 그 이유는 robot의 system에서 기술해야 하는 수많은 좌표축(frame)이 존재하기 때문입니다. 위의 그림과 같이 LiDAR sensor가 하나만 달려있는 로봇이어도 최소 3가지 축이 존재합니다.

  • Global Frame: Navigation Frame, Map Frame이라고 불리기도 하며, 맵의 (0,0,0)과 방향을 나타냄
  • Body Frame: Robot이 움직일 때 움직인 정도의 기준이 되는 축. 로봇이 모터 등으로 움직였을 때, 그 움직임을 나타내는 위치를 지칭함
  • Sensor Frame: Sensor의 data가 들어올 때, 센서의 상이 맺히는 부분의 위치와 방향을 나타냄

따라서 sensor를 통해 기술되는 data를 로봇의 움직임을 기술하는 축으로 transform해주어야 하고(Sensor Frame → Body Frame), 최종적으로 전체 pointcloud를 map 기준으로 취합해야 하기 때문에 (Body Frame → Global Frame) transformation이 필요한 것입니다.

위의 video처럼 map을 만들 때 transformation은 필수입니다!


How to use

만약 위의 그림에서 LiDAR 센서가 로봇 Body 기준 x축으로 +0.165m, z축으로 + 0.320m에 놓여져 있다고 하면 어떻게 transformation을 하면 될까요? 코드는 아래와 같습니다.

간혹 0.165와 0.320이 +인지 -인지 부호가 헷갈리는 경우가 있습니다. 그럴때는 저는 (0,0,0,1), (1,0,0,1), (0,1,0,1), (0,0,1,1) 등과 transformation matrix를 곱했을 때의 결과가 Body 기준으로 맞는 위치로 표현되었는지 확인해봅니다.

  • 수학적 표현에 대해서는 저는 개인적으로 Introduction to Robotics의 chapter 2가 많이 도움되었습니다.

  • ROS에서는 pose의 orientation이 quaternion으로 표현이 되는데, 이걸 어떻게 rotation matrix로 표현할 수 있을까요? 정답은 ROS의 tf::Quaternion을 사용하면 쉽게 변환할 수 있습니다. 코드는 여기를 참조하세요 ;)


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)