forked from HesaiTechnology/HesaiLidar_ROS_2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
280 lines (227 loc) · 8.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0048 NEW)
project(hesai_ros_driver)
#=======================================
# Version information
#=======================================
set(VERSION_MAJOR 2)
set(VERSION_MINOR 0)
set(VERSION_TINY 7)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/Version.h"
)
#=======================================
# Custom Point Type (XYZI, XYZIRT)
#=======================================
set(POINT_TYPE XYZI)
#=======================================
# Compile setup (ORIGINAL, CATKIN, COLCON)
#=======================================
message(=============================================================)
message("-- ROS_VERSION is $ENV{ROS_VERSION}")
message(=============================================================)
#========================
# Project details / setup
#========================
set(PROJECT_NAME hesai_ros_driver)
add_definitions(-DPROJECT_PATH="${PROJECT_SOURCE_DIR}")
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
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++17)
endif()
add_compile_options(-Wall)
#========================
# Dependencies Setup
#========================
#ROS#
#Catkin#
if($ENV{ROS_VERSION} MATCHES "1")
find_package(roscpp 1.12 QUIET)
find_package(roslib QUIET)
find_package(rosbag REQUIRED)
include_directories(${roscpp_INCLUDE_DIRS} ${roslib_INCLUDE_DIRS} ${rosbag_INCLUDE_DIRS})
set(ROS_LIBS ${roscpp_LIBRARIES} ${roslib_LIBRARIES} ${rosbag_LIBRARIES})
add_definitions(-DROS_FOUND)
add_definitions(-DRUN_IN_ROS_WORKSPACE)
find_package(catkin REQUIRED COMPONENTS
roscpp
sensor_msgs
std_msgs
message_generation
roslib
rosbag)
add_message_files(
FILES
"UdpPacket.msg"
"UdpFrame.msg"
"LossPacket.msg"
"Ptp.msg"
"Firetime.msg"
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(CATKIN_DEPENDS
sensor_msgs
roslib)
endif($ENV{ROS_VERSION} MATCHES "1")
#ROS2#
if($ENV{ROS_VERSION} MATCHES "2")
find_package(rclcpp QUIET)
if(rclcpp_FOUND)
message(=============================================================)
message("-- ROS2 Found. ROS2 Support is turned On.")
message(=============================================================)
add_definitions(-DROS2_FOUND)
include_directories(${rclcpp_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 14)
find_package(ament_cmake REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rosidl_typesupport_c REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(std_msgs REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/msg_ros2/UdpPacket.msg"
"msg/msg_ros2/UdpFrame.msg"
"msg/msg_ros2/Firetime.msg"
"msg/msg_ros2/Ptp.msg"
"msg/msg_ros2/LossPacket.msg"
DEPENDENCIES builtin_interfaces std_msgs
)
ament_export_dependencies(rosidl_default_runtime)
else(rclcpp_FOUND)
message(=============================================================)
message("-- ROS2 Not Found. ROS2 Support is turned Off.")
message(=============================================================)
endif(rclcpp_FOUND )
endif($ENV{ROS_VERSION} MATCHES "2")
#Others#
find_package(yaml-cpp REQUIRED)
#Include directory#
include_directories(${PROJECT_SOURCE_DIR}/src)
#Driver core#
add_subdirectory(${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk)
#========================
# Build Setup
#========================
# add_executable(hesai_ros_driver_node
# node/hesai_ros_driver_node.cpp
# src/manager/node_manager.cpp
# )
find_package(Boost REQUIRED COMPONENTS thread)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# if install different cuda version, set the cuda path, like cuda-11.4
# set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-11.4/)
# find_package(CUDA REQUIRED)
# find_package(CUDA )
# if(CUDA_FOUND)
# message(=============================================================)
# message("-- CUDA Found. CUDA Support is turned On.")
# message(=============================================================)
# link_directories($ENV{CUDA_PATH}/lib/x64)
# set(CUDA_NVCC_FLAGS "-arch=sm_75;-O2")#根据具体GPU性能更改算力参数
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -rdc=true")
# list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC)
# CUDA_ADD_EXECUTABLE(hesai_ros_driver_node
# node/hesai_ros_driver_node.cu
# src/manager/node_manager.cu
# ./src/driver/HesaiLidar_SDK_2.0/libhesai/UdpParserGpu/src/buffer.cu
# )
# set(CUDA_LIBS "${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcudart.so")
# target_link_libraries(hesai_ros_driver_node
# ${YAML_CPP_LIBRARIES}
# ${Boost_LIBRARIES}
# source_lib
# container_lib
# ptcClient_lib
# ptcParser_lib
# log_lib
# ${CUDA_LIBS}
# # libhesai
# )
# else(CUDA_FOUND)
message(=============================================================)
message("-- CUDA support disabled by GrandTour team.")
message(=============================================================)
add_executable(hesai_ros_driver_node
node/hesai_ros_driver_node.cc
src/manager/node_manager.cc
)
target_link_libraries(hesai_ros_driver_node
${YAML_CPP_LIBRARIES}
${Boost_LIBRARIES}
source_lib
container_lib
ptcClient_lib
ptcParser_lib
log_lib
# libhesai
)
# endif(CUDA_FOUND)
target_include_directories(hesai_ros_driver_node PRIVATE
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/Lidar
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParser
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParser/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParser/src
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpProtocol
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/Source/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/Container/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/Container/src
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParserGpu
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParserGpu/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/UdpParserGpu/src
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/PtcClient/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/PtcParser/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/PtcParser
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/Logger/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/libhesai/include
${PROJECT_SOURCE_DIR}/src/driver/hesai_lidar_sdk/driver
src/manager
src/msg/ros_msg
src/msg/rs_msg
src/utility
${CMAKE_CURRENT_BINARY_DIR}
)
#Ros#
if($ENV{ROS_VERSION} MATCHES "1")
target_link_libraries(hesai_ros_driver_node ${ROS_LIBS})
install(TARGETS hesai_ros_driver_node
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
endif($ENV{ROS_VERSION} MATCHES "1")
#Ros2#
if($ENV{ROS_VERSION} MATCHES "2")
find_package(ament_index_cpp REQUIRED)
ament_target_dependencies(hesai_ros_driver_node
"ament_index_cpp"
"rcl_interfaces"
"rclcpp"
"rcutils"
"std_msgs"
"sensor_msgs"
# "tf2_geometry_msgs"
)
rosidl_target_interfaces(hesai_ros_driver_node ${PROJECT_NAME} "rosidl_typesupport_cpp")
install(TARGETS
hesai_ros_driver_node
DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY
launch
rviz
DESTINATION share/${PROJECT_NAME})
ament_package()
endif($ENV{ROS_VERSION} MATCHES "2")