diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d28e77b..70adc205 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,6 @@ project(rslidar_sdk) #======================================= set(POINT_TYPE XYZI) -#======================================= -# Compile setup (ORIGINAL, CATKIN, COLCON) -#======================================= -set(COMPILE_METHOD CATKIN) - option(ENABLE_TRANSFORM "Enable transform functions" OFF) if(${ENABLE_TRANSFORM}) add_definitions("-DENABLE_TRANSFORM") @@ -63,12 +58,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "") add_definitions(-O3) endif() -if($ENV{ROS_DISTRO} STREQUAL "humble") # the ros2 humble requires c++17 add_definitions(-std=c++17) -else() -add_definitions(-std=c++14) -endif() - add_compile_options(-Wall) #======================== @@ -103,21 +93,16 @@ if(roscpp_FOUND) include_directories(${roscpp_INCLUDE_DIRS} ${roslib_INCLUDE_DIRS}) set(ROS_LIBS ${roscpp_LIBRARIES} ${roslib_LIBRARIES}) - #Catkin# - if(${COMPILE_METHOD} STREQUAL "CATKIN") - - add_definitions(-DRUN_IN_ROS_WORKSPACE) - - find_package(catkin REQUIRED COMPONENTS - roscpp - sensor_msgs - roslib) + add_definitions(-DRUN_IN_ROS_WORKSPACE) - catkin_package(CATKIN_DEPENDS - sensor_msgs - roslib) + find_package(catkin REQUIRED COMPONENTS + roscpp + sensor_msgs + roslib) - endif(${COMPILE_METHOD} STREQUAL "CATKIN") + catkin_package(CATKIN_DEPENDS + sensor_msgs + roslib) else(roscpp_FOUND) @@ -130,8 +115,7 @@ endif(roscpp_FOUND) #ROS2# find_package(rclcpp QUIET) -if(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") - +if(rclcpp_FOUND) message(=============================================================) message("-- ROS2 Found. ROS2 Support is turned On.") message(=============================================================) @@ -145,13 +129,11 @@ if(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") find_package(rslidar_msg REQUIRED) find_package(std_msgs REQUIRED) -else(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") - +else(rclcpp_FOUND) message(=============================================================) message("-- ROS2 Not Found. ROS2 Support is turned Off.") message(=============================================================) - -endif(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") +endif(rclcpp_FOUND) #Others# find_package(yaml-cpp REQUIRED) @@ -182,19 +164,15 @@ if(roscpp_FOUND) target_link_libraries(rslidar_sdk_node ${ROS_LIBS}) - if(${COMPILE_METHOD} STREQUAL "CATKIN") - - install(TARGETS rslidar_sdk_node - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) - - endif() + install(TARGETS rslidar_sdk_node + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) endif(roscpp_FOUND) #Ros2# -if(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") +if(rclcpp_FOUND) ament_target_dependencies(rslidar_sdk_node rclcpp @@ -213,5 +191,5 @@ if(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") ament_package() -endif(rclcpp_FOUND AND ${COMPILE_METHOD} STREQUAL "COLCON") +endif(rclcpp_FOUND) diff --git a/README.md b/README.md index 1afbb088..1414cc1c 100644 --- a/README.md +++ b/README.md @@ -145,20 +145,7 @@ cmake .. && make -j4 ### 4.2 Compile with ROS catkin tools -(1) On top of the file *CMakeLists.txt*,set the variable **COMPILE_METHOD** to **CATKIN**. - -```cmake -#======================================= -# Compile setup (ORIGINAL,CATKIN,COLCON) -#======================================= -set(COMPILE_METHOD CATKIN) -``` - -(2) Copy the file *package_ros1.xml* to *package.xml* in the rslidar_sdk . - -(3) Create a new workspace folder, and create a *src* folder in it. Then put the rslidar_sdk project into the *src* folder. - -(4) Go back to the root of workspace, run the following commands to compile and run. (if using zsh, replace the 2nd command with *source devel/setup.zsh*). +(1) Run the following commands to compile and run. (if using zsh, replace the 2nd command with *source devel/setup.zsh*). ```sh catkin_make @@ -168,22 +155,7 @@ roslaunch rslidar_sdk start.launch ### 4.3 Compile with ROS2 colcon -(1) On top of the file *CMakeLists.txt*,set the variable **COMPILE_METHOD** to **COLCON**. - -```cmake -#======================================= -# Compile setup (ORIGINAL,CATKIN,COLCON) -#======================================= -set(COMPILE_METHOD COLCON) -``` - -(2) Copy the file *package_ros2.xml* to *package.xml* in the rslidar_sdk. - -(3) Create a new workspace folder, and create a *src* folder in it. Then put the rslidar_sdk project in the *src* folder. - -(4) Download the packet definition project in ROS2 through [link](https://github.com/RoboSense-LiDAR/rslidar_msg), then put the project rslidar_msg in the *src* folder you just created. - -(5) Go back to the root of workspace, run the following commands to compile and run. (if using zsh, replace the 2nd command with *source install/setup.zsh*). +(1) Run the following commands to compile and run. (if using zsh, replace the 2nd command with *source install/setup.zsh*). ```sh colcon build diff --git a/README_CN.md b/README_CN.md index 3c1146d0..f5912af4 100644 --- a/README_CN.md +++ b/README_CN.md @@ -141,21 +141,7 @@ cmake .. && make -j4 ### 1.4.2 依赖于ROS-catkin编译 -(1) 打开工程内的*CMakeLists.txt*文件,将文件顶部的变量**COMPILE_METHOD**改为**CATKIN**. - - -```cmake -#======================================= -# Compile setup (ORIGINAL,CATKIN,COLCON) -#======================================= -set(COMPILE_METHOD CATKIN) -``` - -(2) 将rslidar_sdk工程目录下的*package_ros1.xml*文件复制到*package.xml*。 - -(3) 新建一个文件夹作为工作空间,然后再新建一个名为*src*的文件夹, 将rslidar_sdk工程放入*src*文件夹内。 - -(4) 返回工作空间目录,执行以下命令即可编译、运行。如果使用.zsh,将第二行替换成 *source devel/setup.zsh*。 +(1) 返回工作空间目录,执行以下命令即可编译&运行(若使用.zsh,将第二句指令替换为 *source devel/setup.zsh*)。 ```sh catkin_make @@ -165,22 +151,7 @@ roslaunch rslidar_sdk start.launch ### 1.4.3 依赖于ROS2-colcon编译 -(1) 打开工程内的*CMakeLists.txt*文件,将文件顶部的变量**COMPILE_METHOD**改为**COLCON**. - -```cmake -#======================================= -# Compile setup (ORIGINAL,CATKIN,COLCON) -#======================================= -set(COMPILE_METHOD COLCON) -``` - -(2) 将rslidar_sdk工程目录下的*package_ros2.xml*文件重命名为*package.xml*。 - -(3) 新建一个文件夹作为工作空间,然后再新建一个名为*src*的文件夹, 将rslidar_sdk工程放入*src*文件夹内。 - -(4) 通过[链接](https://github.com/RoboSense-LiDAR/rslidar_msg),下载ROS2环境下的雷达packet消息定义,将rslidar_msg工程也放在刚刚新建的*src*文件夹内,与rslidar_sdk并列。 - -(5) 返回工作空间目录,执行以下命令即可编译、运行。如果使用.zsh,将第二行替换为*source install/setup.zsh*。 +(1) 返回工作空间目录,执行以下命令即可编译&运行(若使用.zsh,将第二句指令替换为 *source install/setup.zsh*)。 ```sh colcon build diff --git a/package.xml b/package.xml index e6395039..121fa1ac 100644 --- a/package.xml +++ b/package.xml @@ -1,17 +1,25 @@ - + rslidar_sdk 1.5.15 The rslidar_sdk package robosense BSD - catkin - roscpp - sensor_msgs - roslib + catkin + ament_cmake - roscpp - sensor_msgs - roslib + libpcap + pcl_ros + rclcpp + roscpp + roslib + rslidar_msg + sensor_msgs + std_msgs + yaml-cpp + + + ament_cmake + diff --git a/package_ros1.xml b/package_ros1.xml deleted file mode 100644 index e6395039..00000000 --- a/package_ros1.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - rslidar_sdk - 1.5.15 - The rslidar_sdk package - robosense - BSD - catkin - - roscpp - sensor_msgs - roslib - - roscpp - sensor_msgs - roslib - diff --git a/package_ros2.xml b/package_ros2.xml deleted file mode 100644 index afdb56d9..00000000 --- a/package_ros2.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - rslidar_sdk - 1.5.15 - The rslidar_sdk package - robosense - BSD - ament_cmake - - rclcpp - sensor_msgs - std_msgs - rclcpp - sensor_msgs - std_msgs - rslidar_msg - - ament_cmake - - -