라이다 회사에서 제공하는 ROS패키지에서 만들어내는 메시지 타입은 sensor_msgs::msg::PointCloud2<PointType>인데, 2023년 1월 현재 "sudo apt-get install ros-humble-pcl-conversions"로 받아오는 헤더파일에는 sensor_msgs::msg::PointCloud2를 pcl::PointCloud<PointType>로 바꿔주는 소스가 없다.
이 헤더파일로 컴파일을 하려고 하면 이런 에러메시지가 난다.
note: cannot convert ‘_msg’ (type ‘const PCLMsgType’ {aka ‘const sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) to type ‘const PointCloud2&’ {aka ‘const sensor_msgs::PointCloud2_<std::allocator<void> >&’}
PCLMsgType라는건 내가 using명령어로 적당히 만든 ROS메시지 타입 정의고, 본질은 const sensor_msgs::msg::PointCloud2이다.
"const sensor_msgs::msg::PointCloud2_<std::allocator<void> >" 타입에 "const sensor_msgs::PointCloud2_<std::allocator<void> >&"타입을 대입할수 없다! 라는 뜻이다.
이걸 억지로 오버라이딩 해서 만들어낼려니까 컴파일에러가 엄청나게 일어나니까 순순히 다른 사람이 만든걸 가져와야겠다는 생각을 했다.
다행히도 깃허브에는 이걸 바꿔주는 소스코드가 있었다.
GitHub - ros-perception/perception_pcl: PCL (Point Cloud Library) ROS interface stack
PCL (Point Cloud Library) ROS interface stack. Contribute to ros-perception/perception_pcl development by creating an account on GitHub.
github.com
우선 이 소스코드를 전부 쭉 긁어온다.
그담에 /usr/include/pcl_conversions/pcl_conversions.h를 열고 내용을 바꿔치기 한다. 슈퍼유저 권한이 필요한데 vscode에서는 저장 누르고 슈퍼유저로 재시도 누르니까 가능했다.
문제는 이 헤더파일을 컴파일하려면 두가지 의존성을 또 추가해줘야된다.
프로젝트의 CmakeLists.txt를 열고, ament_target_dependencies명령의 인수에 pcl_msgs랑 message_filters를 추가해줘야된다.
'ROS' 카테고리의 다른 글
[ROS2]tf에 대해서 알아봅시다-1 (0) | 2022.08.26 |
---|---|
From implementation of RobotHW to implementation of PI control (0) | 2022.05.28 |
ros_control API를 이용한 하드웨어 제어프로그램 작성 (0) | 2022.05.21 |
URDF로봇 이동 시뮬레이션 하기 (0) | 2022.05.05 |
간단한 urdf모델 만들고 rviz로 보기 (0) | 2022.05.04 |