-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
192 lines (166 loc) · 4.8 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
cmake_minimum_required(VERSION 3.5)
project(ifm3d_ros2)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
set(IFM3D_ROS2_DEPS
builtin_interfaces
diagnostic_msgs
geometry_msgs
lifecycle_msgs
nav_msgs
nav2_msgs
rclcpp
rclcpp_components
rclcpp_lifecycle
rcl_interfaces
rmw
rosidl_default_generators
sensor_msgs
std_msgs
tf2_ros
)
find_package(ifm3d 1.2.6 CONFIG REQUIRED COMPONENTS
device
framegrabber
)
find_package(ament_cmake_auto REQUIRED)
find_package(ament_cmake_ros REQUIRED)
ament_auto_find_build_dependencies(REQUIRED ${IFM3D_ROS2_DEPS})
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Extrinsics.msg"
"msg/Intrinsics.msg"
"msg/InverseIntrinsics.msg"
"msg/RGBInfo.msg"
"msg/TOFInfo.msg"
"msg/Zones.msg"
"srv/Dump.srv"
"srv/Config.srv"
"srv/GetDiag.srv"
"srv/Softoff.srv"
"srv/Softon.srv"
DEPENDENCIES builtin_interfaces std_msgs
)
#############
## Build ##
#############
include_directories(include)
# Target for messages included in this package
rosidl_get_typesupport_target(msgs_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
add_library(ifm3d_ros2_buffer_conversions SHARED
src/lib/buffer_conversions.cpp)
target_link_libraries(ifm3d_ros2_buffer_conversions
"${msgs_typesupport_target}"
ifm3d::framegrabber)
ament_target_dependencies(ifm3d_ros2_buffer_conversions ${IFM3D_ROS2_DEPS})
add_library(ifm3d_ros2_buffer_id_utils SHARED
src/lib/buffer_id_utils.cpp)
target_link_libraries(ifm3d_ros2_buffer_id_utils
"${msgs_typesupport_target}"
ifm3d::framegrabber)
ament_target_dependencies(ifm3d_ros2_buffer_id_utils ${IFM3D_ROS2_DEPS})
# ifm3d camera "component" (.so) state machine ("lifecycle node")
#
add_library(ifm3d_ros2_camera_node SHARED
src/lib/camera_node.cpp
src/lib/diag_module.cpp
src/lib/function_module.cpp
src/lib/rgb_module.cpp
src/lib/camera_tf_publisher.cpp
src/lib/tof_module.cpp
src/lib/services.cpp)
target_link_libraries(ifm3d_ros2_camera_node
"${msgs_typesupport_target}"
ifm3d_ros2_buffer_conversions
ifm3d_ros2_buffer_id_utils
ifm3d::device
ifm3d::framegrabber
)
ament_target_dependencies(ifm3d_ros2_camera_node ${IFM3D_ROS2_DEPS})
rclcpp_components_register_nodes(
ifm3d_ros2_camera_node "ifm3d_ros2::CameraNode"
)
#
# ifm3d ods node
#
add_library(ifm3d_ros2_ods_node SHARED
src/lib/ods_node.cpp
src/lib/function_module.cpp
src/lib/diag_module.cpp
src/lib/ods_module.cpp
src/lib/services.cpp)
target_link_libraries(ifm3d_ros2_ods_node
"${msgs_typesupport_target}"
ifm3d_ros2_buffer_conversions
ifm3d_ros2_buffer_id_utils
ifm3d::device
ifm3d::framegrabber
)
ament_target_dependencies(ifm3d_ros2_ods_node ${IFM3D_ROS2_DEPS})
rclcpp_components_register_nodes(
ifm3d_ros2_ods_node "ifm3d_ros2::OdsNode"
)
#
# Exe to bring up the camera component in a standalone way allow us to manually
# drive the state machine or some other external "manager" can do so (e.g.,
# launch_ros).
#
ament_auto_add_executable(camera_standalone src/bin/camera_standalone.cpp)
target_link_libraries(camera_standalone
"${msgs_typesupport_target}"
ifm3d_ros2_camera_node)
ament_target_dependencies(camera_standalone ${IFM3D_ROS2_DEPS})
target_link_libraries(ifm3d_ros2_camera_node ${Boost_LIBRARIES})
ament_auto_add_executable(ods_standalone src/bin/ods_standalone.cpp)
target_link_libraries(ods_standalone
"${msgs_typesupport_target}"
ifm3d_ros2_ods_node)
ament_target_dependencies(ods_standalone ${IFM3D_ROS2_DEPS})
target_link_libraries(ifm3d_ros2_ods_node ${Boost_LIBRARIES}) # TODO needed?
##############
## Install ##
##############
install(
TARGETS camera_standalone ods_standalone
DESTINATION lib/${PROJECT_NAME}
)
install(
TARGETS ifm3d_ros2_camera_node ifm3d_ros2_ods_node ifm3d_ros2_buffer_conversions ifm3d_ros2_buffer_id_utils
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}/
)
install(
DIRECTORY etc
DESTINATION share/${PROJECT_NAME}/
)
install(
DIRECTORY config
DESTINATION share/${PROJECT_NAME}/
)
#############
## Test ##
#############
if(BUILD_TESTING)
find_package(launch_testing_ament_cmake)
add_launch_test(test/lifecycle.test.py)
#
# At the moment, the test(s) below cannot be run with `colcon test` b/c the
# python scripts which implement the tests cannot load `ifm3d_ros2.msg`
# module. I am not sure if this is a problem with colon or how I have set up
# my tests.
#
# Despite not being able to run the tests with `colcon test`, they can be
# direclty run with `launch_test`. In this method, the tests should pass.
#
#add_launch_test(test/pointcloud.test.py)
endif(BUILD_TESTING)
#############
ament_auto_package()