-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
280 lines (230 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
279
280
cmake_minimum_required(VERSION 3.8)
project(riptide_autonomy2)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(vision_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(riptide_msgs2 REQUIRED)
find_package(robot_localization REQUIRED)
find_package(std_srvs REQUIRED)
find_package(behaviortree_cpp_v3 REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
#sm specific depends
find_package(chameleon_tf_msgs REQUIRED)
find_package(nortek_dvl_msgs REQUIRED)
#create directory for auto-generated code which will include headers for custom nodes as well as source code that registers custom nodes
make_directory(${PROJECT_BINARY_DIR}/autonomy_generator)
#
# cmake macro to execute a process and quit cmake execution if it fails
#
function(execute_process_with_error_detection)
execute_process(COMMAND ${ARGV}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE func_out
RESULT_VARIABLE func_result
)
if(${func_result}) #nonzero function result means error
message(SEND_ERROR
"Error occurred during execution of process: ${cmd}\n\n"
"Stderr shown above. Stdout shown below: \n" #stderr automatically printed by cmake/colcon, stdout has to be manually printed
"${func_output}\n")
message(FATAL_ERROR "Review error information above. Cmake will exit.") #will quit cmake execution
endif()
endfunction()
# generate behaviortree node registrators
execute_process_with_error_detection(
./src/riptide_autonomy/assistant/btassistant.py generate_registrators ${PROJECT_BINARY_DIR}/autonomy_generator
)
set(deps
rclcpp
geometry_msgs
std_msgs
nav_msgs
sensor_msgs
vision_msgs
riptide_msgs2
robot_localization
std_srvs
behaviortree_cpp_v3
tf2
tf2_ros
tf2_geometry_msgs
tinyxml2_vendor
)
#
# util library
#
add_library(autonomy_utils SHARED
src/riptide_autonomy/util.cpp
src/riptide_autonomy/UwrtBtNode.cpp
)
target_include_directories(autonomy_utils PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(autonomy_utils ${deps})
#
# action library
#
file(GLOB simple_actions_sources RELATIVE ${PROJECT_SOURCE_DIR} src/riptide_autonomy/bt_actions/*.simple.cpp)
add_library(autonomy_actions SHARED
${simple_actions_sources}
${PROJECT_BINARY_DIR}/autonomy_generator/registerActions.cpp
)
target_include_directories(autonomy_actions PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(autonomy_actions ${deps})
target_link_libraries(autonomy_actions autonomy_utils)
target_compile_definitions(autonomy_actions PRIVATE BT_PLUGIN_EXPORT)
#
# condition library
#
file(GLOB simple_conditions_sources RELATIVE ${PROJECT_SOURCE_DIR} src/riptide_autonomy/bt_conditions/*.simple.cpp)
add_library(autonomy_conditions SHARED
${simple_conditions_sources}
${PROJECT_BINARY_DIR}/autonomy_generator/registerConditions.cpp
)
target_compile_definitions(autonomy_conditions PRIVATE BT_PLUGIN_EXPORT)
target_include_directories(autonomy_conditions PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(autonomy_conditions ${deps})
target_link_libraries(autonomy_conditions autonomy_utils)
#
# decorator library
#
file(GLOB simple_decorators_sources RELATIVE ${PROJECT_SOURCE_DIR} src/riptide_autonomy/bt_decorators/*.simple.cpp)
add_library(autonomy_decorators SHARED
${simple_decorators_sources}
${PROJECT_BINARY_DIR}/autonomy_generator/registerDecorators.cpp
)
target_compile_definitions(autonomy_decorators PRIVATE BT_PLUGIN_EXPORT)
target_include_directories(autonomy_decorators PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(autonomy_decorators ${deps})
target_link_libraries(autonomy_decorators autonomy_utils)
#
# Tree execution executable
#
add_executable(doTask src/riptide_autonomy/DoTask.cpp)
target_include_directories(doTask PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(doTask autonomy_utils)
target_compile_definitions(doTask PUBLIC AUTONOMY_PKG_NAME="${PROJECT_NAME}")
ament_target_dependencies(doTask
ament_index_cpp
rclcpp
behaviortree_cpp_v3
rclcpp_action
riptide_msgs2
)
#
# BT Health Checker executable
#
#check that we are on Ubuntu 22.04. otherwise tinyxml will be sad
execute_process(COMMAND lsb_release -s -i
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OS_NAME
)
execute_process(COMMAND lsb_release -s -r
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OS_VERSION
)
string(COMPARE EQUAL ${OS_NAME} "Ubuntu\n" OS_NAME_UBUNTU)
string(COMPARE EQUAL ${OS_VERSION} "20.04\n" OS_VERSION_20_04)
if((OS_NAME_UBUNTU AND OS_VERSION_20_04) OR BUILD_DEPLOY)
message("Skipping BT Health checker for deploy build or OS version incompatibility")
else()
add_executable(checkBT src/riptide_autonomy/CheckBT.cpp)
target_include_directories(checkBT PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty>
$<INSTALL_INTERFACE:include>)
target_link_libraries(checkBT autonomy_utils)
target_compile_definitions(checkBT PUBLIC AUTONOMY_PKG_NAME="${PROJECT_NAME}")
ament_target_dependencies(checkBT
behaviortree_cpp_v3
)
install(TARGETS checkBT
DESTINATION lib/${PROJECT_NAME}
)
endif()
#install executable
install(TARGETS doTask
DESTINATION lib/${PROJECT_NAME}
)
#install libraries
install(TARGETS autonomy_actions autonomy_conditions autonomy_decorators autonomy_utils
DESTINATION lib
)
# install the launch files
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME})
# Install Python executables
file(GLOB assistant_py_files RELATIVE ${PROJECT_SOURCE_DIR} src/riptide_autonomy/assistant/*.py)
install(PROGRAMS
${assistant_py_files}
DESTINATION lib/${PROJECT_NAME}
)
install(PROGRAMS
src/riptide_autonomy/HeadlessInterface.py
DESTINATION lib/${PROJECT_NAME})
#install bt assistant "actions" directory
install(DIRECTORY src/riptide_autonomy/assistant/actions
DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY trees
DESTINATION share/${PROJECT_NAME})
if(AUTONOMY_BUILD_TESTS)
#set up GTest
find_package(ament_cmake_gtest QUIET)
if(ament_cmake_gtest_FOUND)
#ament lint auto things
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
#glob all test sources together
file(GLOB action_test_sources RELATIVE ${PROJECT_SOURCE_DIR} test/riptide_autonomy/bt_actions/*.cpp)
file(GLOB condition_test_sources RELATIVE ${PROJECT_SOURCE_DIR} test/riptide_autonomy/bt_conditions/*.cpp)
file(GLOB decorator_test_sources RELATIVE ${PROJECT_SOURCE_DIR} test/riptide_autonomy/bt_decorators/*.cpp)
file(GLOB tool_test_sources RELATIVE ${PROJECT_SOURCE_DIR} test/riptide_autonomy/tools/*.cpp)
ament_add_gtest(test_nodes
${action_test_sources}
${condition_test_sources}
${decorator_test_sources}
${tool_test_sources}
test/riptide_autonomy/DummyActionNode.cpp
test/riptide_autonomy/BtTestTool.cpp
test/riptide_autonomy/BtTest.cpp
test/riptide_autonomy/executeTests.cpp #overrides default main() method
)
ament_target_dependencies(test_nodes ${deps})
target_link_libraries(test_nodes autonomy_utils)
target_include_directories(test_nodes PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
install(TARGETS test_nodes
DESTINATION lib/${PROJECT_NAME}
)
endif()
endif()
ament_package()