解决ROS中PLUGINLIB_DECLARE_CLASS错误

catkin_make编译ROS中pointcloud_to_laserscan模块报

error: expected constructor, destructor, or type conversion before ‘(’ token
  241 | PLUGINLIB_DECLARE_CLASS(pointcloud_to_laserscan, PointCloudToLaserScanNodelet, pointcloud_to_laserscan::PointCloudToLaserScanNodelet, nodelet::Nodelet);
      |                        ^
make[2]: *** [CMakeFiles/pointcloud_to_laserscan.dir/build.make:63:CMakeFiles/pointcloud_to_laserscan.dir/src/pointcloud_to_laserscan_nodelet.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1677:CMakeFiles/pointcloud_to_laserscan.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2

错误。

解决方法:

将该处代码修改为:

PLUGINLIB_EXPORT_CLASS(pointcloud_to_laserscan::PointCloudToLaserScanNodelet, nodelet::Nodelet);

注意原始代码中的宏是PLUGINLIB_DECLARE_CLASS,而修改后的是PLUGINLIB_EXPORT_CLASS。

posted @ 2021-08-03 17:06  Dsp Tian  阅读(721)  评论(0编辑  收藏  举报