ros2调用transform时遇到的奇怪错误

当我进行点的坐标系转换时,遇到了下面的奇怪错误:

Starting >>> normal_estimation
--- stderr: normal_estimation                                
In file included from /home/raoshuncai/ros2moveforplanning/src/normal_estimation/include/normal_estimation/normal_estimation_core.h:30,
                 from /home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp:1:
/opt/ros/foxy/include/image_transport/image_transport.h:41:89: note: #pragma message: Warning: This header is deprecated. Use 'image_transport.hpp' instead
   41 | #pragma message ("Warning: This header is deprecated. Use 'image_transport.hpp' instead")
      |                                                                                         ^
/home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp: In member functionvoid Normal_estimation::serial_cb(sensor_msgs::msg::PointCloud2_<std::allocator<void> >::SharedPtr):
/home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp:45:37: warning: unused variable ‘cluster_indices’ [-Wunused-variable]
   45 |     std::vector<pcl::PointIndices>* cluster_indices = nullptr;//多个聚类结果的索引
      |                                     ^~~~~~~~~~~~~~~
/home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp: In member functionvoid Normal_estimation::extract_box(std::vector<pcl::PointIndices>*, pcl::PointCloud<pcl::PointXYZ>::Ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr, std::vector<Normal_estimation::Detected_Obj>&, geometry_msgs::msg::PoseStamped&, pcl::IndicesPtr):
/home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp:129:29: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<pcl::PointIndices>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  129 |         for (int it = 0; it < cluster_indices->size(); it++)
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/home/raoshuncai/ros2moveforplanning/src/normal_estimation/src/normal_estimation_core.cpp:454:44: warning: unused variable ‘z’ [-Wunused-variable]
  454 |                                     double z = point_normal->at(0).normal_z;
      |                                            ^
/usr/bin/ld: CMakeFiles/normal_estimation_node_A.dir/src/normal_estimation_core.cpp.o: in function `geometry_msgs::msg::PoseStamped_<std::allocator<void> >& tf2_ros::BufferInterface::transform<geometry_msgs::msg::PoseStamped_<std::allocator<void> > >(geometry_msgs::msg::PoseStamped_<std::allocator<void> > const&, geometry_msgs::msg::PoseStamped_<std::allocator<void> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::chrono::duration<long, std::ratio<1l, 1000000000l> >) const':
normal_estimation_core.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE]+0x5a): undefined reference to `std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > tf2::getTimestamp<geometry_msgs::msg::PoseStamped_<std::allocator<void> > >(geometry_msgs::msg::PoseStamped_<std::allocator<void> > const&)'
/usr/bin/ld: normal_estimation_core.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE]+0x7a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > tf2::getFrameId<geometry_msgs::msg::PoseStamped_<std::allocator<void> > >(geometry_msgs::msg::PoseStamped_<std::allocator<void> > const&)'
/usr/bin/ld: normal_estimation_core.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs3msg12PoseStamped_ISaIvEEEEERT_RKS7_S8_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE]+0xcf): undefined reference to `void tf2::doTransform<geometry_msgs::msg::PoseStamped_<std::allocator<void> > >(geometry_msgs::msg::PoseStamped_<std::allocator<void> > const&, geometry_msgs::msg::PoseStamped_<std::allocator<void> >&, geometry_msgs::msg::TransformStamped_<std::allocator<void> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/normal_estimation_node_A.dir/build.make:386: normal_estimation_node_A] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: CMakeFiles/normal_estimation_node_A.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< normal_estimation [16.3s, exited with code 2]

Summary: 0 packages finished [16.4s]
  1 package failed: normal_estimation
  1 package had stderr output: normal_estimation

这就感觉很无奈,查来查去,终于在这篇博客中找到了问题的答案:
ROS入门教程-理论与实践(5.1.2 静态坐标变换)
原来必须加入下面的头文件才能调用transform函数:

#include <tf2_geometry_msgs/tf2_geometry_msgs.h> 

这样使用下面的代码就和ros1版本的plistener->transformPoint(“odom”,laser_point,base_point)函数一样了:

geometry_msgs::msg::PoseStamped base_point;
base_point = tf_buffer_->transform(laser_point,"odom");  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值