HViktorTsoi / rs_to_velodyne

A ros tool for converting Robosense pointcloud to Velodyne pointcloud format.
177 stars 58 forks source link

Cannot compile on ROS Noetic (Ubuntu 20.04), because of the C++ standard is too low. #13

Open Starrah opened 1 year ago

Starrah commented 1 year ago

The code failed to compile on ROS Noetic (Ubuntu 20.04). The error is about PCL, seems like below:

/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: ‘type’ is not a member of ‘pcl::traits::datatype<VelodynePointXYZIR, pcl::fields::y>::decomposed’ {aka ‘pcl::traits::decomposeArray<float>’}
/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: template argument 1 is invalid
   65 | POINT_CLOUD_REGISTER_POINT_STRUCT (VelodynePointXYZIR,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/home/xxx/ws/src/rs_to_velodyne/src/rs_to_velodyne.cpp:65:1: error: ‘plus’ is not a member of ‘pcl::traits’
   65 | POINT_CLOUD_REGISTER_POINT_STRUCT (VelodynePointXYZIR,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/include/pcl-1.10/pcl/point_types.h: In function ‘const pcl::IntensityGradient& pcl::common::operator-=(pcl::IntensityGradient&, const float&)’:
/usr/include/pcl-1.10/pcl/point_types.h:665:1: error: ‘minusscalar’ is not a member of ‘pcl::traits’
  665 | POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::IntensityGradient,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/usr/include/c++/9/bits/stl_numeric.h:166:22: error: no match for call to ‘(pcl::getFieldsList(const pcl::PCLPointCloud2&)::<lambda(const int&, const int&)>) (std::__cxx11::basic_string<char>&, const pcl::PCLPointField&)’
  166 |  __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~

This is because the C++ standard version specified in CMakeLists.txt is C++11, which is too low to compile on Noetic's g++ compiler. https://github.com/HViktorTsoi/rs_to_velodyne/blob/564dbbbce2a8fd61f5ecc0d51dac8185d2381d94/CMakeLists.txt#L4

Upgrade the C++ standard version to C++14 can solve the problem. Just change the line above into: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3")

In my machine (ROS Noetic, Ubuntu 20.04, amd64), this can resolve the problem. (Note that you should clean the build (rm -rf build/ devel/) between making the change and running catkin_make again.)

However, I don't know whether this change will make the code fail to compile on earlier ROS distributions (Kinetic 16.04, etc). So I'm hesitating raising a PR, instead just raise this issue as a reminder to Noetic users. If we make sure this will not introduce bug on earlier distributions, we may consider merge the change into master.

Besides, I also suggest @HViktorTsoi to add some reminder sentences on the README.md, linking to this issue, to remind other Noetic users.

corporationsd commented 8 months ago

(您好,我看到您是在noetic版本上运行的[rs_to_velodyne],由于我也是在noetic版本上进行的,但我在编译的过程中有些问题(警告),我截取了部分如下:) Hello, I noticed that you are running [rs_to_velodyne] on the noetic version. As I was also running on the noetic version, there were some issues (warnings) during the compilation process. I have taken a screenshot as follows: usr/include/pcl-1.10/pcl/pcl_macros.h:92:9: note: declared here

92 | using uint8_t [[deprecated("use std::uint8_t instead of pcl::uint8_t")]] = std::uint8_t; | ^~~ /opt/ros/noetic/include/ros/console.h:575:35: note: in expansion of macro ‘ROS_LOG_COND’ 575 | #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, VA_ARGS) | ^~~~ /opt/ros/noetic/include/rosconsole/macros_generated.h:214:24: note: in expansion of macro ‘ROS_LOG’ 214 | #define ROS_ERROR(...) ROS_LOG(::ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, VA_ARGS) | ^~~ /home/car/workspace_rslidar/src/rs_to_velodyne-master/src/rs_to_velodyne.cpp:213:13: note: in expansion of macro ‘ROS_ERROR’

(请问有什么方法能解决吗) Is there any way to solve it