-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
455 lines (371 loc) · 13.3 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
cmake_minimum_required(VERSION 2.8.3)
project(end_effector)
## Compile as C++11, supported in ROS Kinetic and newer
add_compile_options(-std=c++11)
##test code coverage
option(ROSEE_ENABLE_COVERAGE "Compile with coverage information" ON)
if(${ROSEE_ENABLE_COVERAGE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -g")
endif()
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS srdfdom
kdl_parser
roscpp
rospy
message_generation
moveit_ros_planning_interface
rosee_msg
)
find_package(Eigen3 REQUIRED)
#TODO on my pc, find_package works. On iit pc, I need the find_library. Why?
#find_package(muparser REQUIRED)
find_library(_MUPARSER_LIB muparser REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(matlogger2 QUIET)
if (${matlogger2_FOUND})
message("Logging with MatLogger2")
add_definitions(-D_MATLOGGER2)
endif (${matlogger2_FOUND})
#Xbot stuff
option(BUILD_WITH_XBOT2 "Compile also the HAL used with XBot2" OFF)
if (BUILD_WITH_XBOT2)
message("Compiling with XBOT2")
option(XBOT2_ENABLE_XENO OFF "Compile against xenomai") #TODO necessary?
find_package(xbot2 REQUIRED)
else()
message("Compiling without XBOT2")
endif(BUILD_WITH_XBOT2)
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
# LIBRARIES end_effector
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)
###########
## Build ##
###########
include_directories(
include
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
list(APPEND libToInstall)
add_library(ROSEEParser
src/Parser.cpp
)
list(APPEND libToInstall ROSEEParser)
add_library(ROSEEInterface
src/EEInterface.cpp
)
list(APPEND libToInstall ROSEEInterface)
add_library(DummyHal
src/HAL/DummyHal.cpp
)
list(APPEND libToInstall DummyHal)
add_library(EEHal
src/HAL/EEHal.cpp
)
list(APPEND libToInstall EEHal)
if (BUILD_WITH_XBOT2)
add_library(XBot2Hal
src/HAL/XBot2Hal.cpp
)
list(APPEND libToInstall XBot2Hal)
endif(BUILD_WITH_XBOT2)
add_library(UniversalRosEndEffectorExecutor
src/UniversalRosEndEffectorExecutor.cpp
)
list(APPEND libToInstall UniversalRosEndEffectorExecutor)
add_library(ROSEEFindActions
src/FindActions.cpp
)
list(APPEND libToInstall ROSEEFindActions)
add_library(ROSEEParserMoveIt
src/ParserMoveIt.cpp
)
list(APPEND libToInstall ROSEEParserMoveIt)
add_library(ROSEEYamlWorker
src/YamlWorker.cpp
)
list(APPEND libToInstall ROSEEYamlWorker)
add_library(ROSEERosActionServer
src/RosActionServer.cpp
)
list(APPEND libToInstall ROSEERosActionServer)
add_library(ROSEERosServiceHandler
src/RosServiceHandler.cpp
)
list(APPEND libToInstall ROSEERosServiceHandler)
add_library(ROSEEMapActionHandler
src/MapActionHandler.cpp
)
list(APPEND libToInstall ROSEEMapActionHandler)
add_library(ROSEEActions
src/GraspingActions/Action.cpp
src/GraspingActions/ActionPrimitive.cpp
src/GraspingActions/ActionPinchTight.cpp
src/GraspingActions/ActionPinchGeneric.cpp
src/GraspingActions/ActionPinchLoose.cpp
src/GraspingActions/ActionTrig.cpp
src/GraspingActions/ActionSingleJointMultipleTips.cpp
src/GraspingActions/ActionMultiplePinchTight.cpp
src/GraspingActions/ActionGeneric.cpp
src/GraspingActions/ActionComposed.cpp
src/GraspingActions/ActionTimed.cpp
)
list(APPEND libToInstall ROSEEActions)
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_executable(UniversalRosEndEffector src/UniversalRosEndEffector.cpp)
add_executable(UniversalFindActions src/UniversalFindActions.cpp)
add_executable(EEHalExecutor src/HAL/EEHalExecutor.cpp)
# # add_dependencies(UniversalRosEndEffectorExecutor end_effector_generate_messages_cpp)
# # add_dependencies(UniversalFindActions end_effector_generate_messages_cpp)
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
target_link_libraries(ROSEEParser
${catkin_LIBRARIES}
yaml-cpp
)
target_link_libraries(ROSEEInterface
${catkin_LIBRARIES}
ROSEEParser
)
target_link_libraries(UniversalRosEndEffectorExecutor
${catkin_LIBRARIES}
ROSEEParser
ROSEEInterface
ROSEEYamlWorker
ROSEEMapActionHandler
ROSEERosActionServer
ROSEERosServiceHandler
)
target_link_libraries(ROSEEYamlWorker
yaml-cpp
ROSEEActions
)
target_link_libraries(ROSEEMapActionHandler
ROSEEActions
ROSEEYamlWorker
)
target_link_libraries(ROSEERosActionServer
${catkin_LIBRARIES}
)
add_dependencies(ROSEERosActionServer rosee_msg_generate_messages_cpp)
target_link_libraries(ROSEERosServiceHandler
${catkin_LIBRARIES}
)
add_dependencies(ROSEERosServiceHandler rosee_msg_generate_messages_cpp)
target_link_libraries(ROSEEFindActions
${catkin_LIBRARIES}
ROSEEParserMoveIt
ROSEEYamlWorker
ROSEEActions
muparser
)
target_link_libraries(ROSEEParserMoveIt
${catkin_LIBRARIES}
)
target_link_libraries(UniversalRosEndEffector
UniversalRosEndEffectorExecutor
)
target_link_libraries(UniversalFindActions
ROSEEParserMoveIt
ROSEEParser
ROSEEFindActions
ROSEEActions
ROSEEMapActionHandler
)
if (${matlogger2_FOUND})
target_link_libraries(EEHalExecutor
${catkin_LIBRARIES}
EEHal
matlogger2::matlogger2
)
else()
target_link_libraries(EEHalExecutor
${catkin_LIBRARIES}
EEHal
)
endif(${matlogger2_FOUND})
target_link_libraries(EEHal
${catkin_LIBRARIES}
yaml-cpp
)
add_dependencies(EEHal rosee_msg_generate_messages_cpp)
target_link_libraries(DummyHal
${catkin_LIBRARIES}
EEHal
)
if(BUILD_WITH_XBOT2)
target_link_libraries(XBot2Hal
xbot2::xbot2
EEHal
)
endif(BUILD_WITH_XBOT2)
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
# Mark executables and/or libraries for installation
install(TARGETS UniversalRosEndEffector
UniversalFindActions
EEHalExecutor
${libToInstall}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
FILES_MATCHING PATTERN "*.launch"
)
install(FILES
configs/urdf/heri_II.urdf
configs/urdf/qbhand.urdf
configs/urdf/robotiq_2f_140.urdf
configs/urdf/robotiq_3f.urdf
configs/urdf/schunk.urdf
configs/urdf/test_ee.urdf
configs/urdf/test_ee_spread.urdf
configs/urdf/two_finger.urdf
configs/urdf/two_finger_mimic.urdf
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/configs/urdf
)
install(FILES
configs/srdf/heri_II.srdf
configs/srdf/qbhand.srdf
configs/srdf/robotiq_2f_140.srdf
configs/srdf/robotiq_3f.srdf
configs/srdf/schunk.srdf
configs/srdf/test_ee.srdf
configs/srdf/test_ee_spread.srdf
configs/srdf/two_finger.srdf
configs/srdf/two_finger_mimic.srdf
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/configs/srdf
)
#############
## Testing ##
#############
if(CATKIN_ENABLE_TESTING)
# Add gtest based cpp test target and link libraries
#catkin_add_gtest(EEInterface_test test/test_ee_interface.cpp)
add_executable(EEInterface_test test/test_ee_interface.cpp)
target_link_libraries(EEInterface_test ${catkin_LIBRARIES}
ROSEEParser
ROSEEInterface
gtest)
add_executable(FindPinches_test test/test_find_pinches.cpp)
target_link_libraries(FindPinches_test ${catkin_LIBRARIES}
ROSEEFindActions
ROSEEActions
gtest)
add_executable(FindTrigs_test test/test_find_trigs.cpp)
target_link_libraries(FindTrigs_test ${catkin_LIBRARIES}
ROSEEFindActions
ROSEEActions
gtest)
add_executable(ComposedAction_test test/test_composedAction.cpp)
target_link_libraries(ComposedAction_test ${catkin_LIBRARIES}
ROSEEFindActions
ROSEEActions
gtest)
add_executable(TimedAction_test test/test_timedAction.cpp)
target_link_libraries(TimedAction_test ${catkin_LIBRARIES}
ROSEEFindActions
ROSEEActions
gtest)
add_executable(SendAction_test test/test_send_action.cpp)
target_link_libraries(SendAction_test ${catkin_LIBRARIES}
ROSEEActions
gtest
ROSEEYamlWorker
ROSEEParser
ROSEEInterface
ROSEEFindActions)
add_executable(ServiceHandler_test test/test_service_handler.cpp)
target_link_libraries(ServiceHandler_test ${catkin_LIBRARIES}
gtest
ROSEEParser
ROSEEInterface
ROSEEMapActionHandler
ROSEERosServiceHandler)
list(APPEND testsExecutable
EEInterface_test
FindPinches_test
FindTrigs_test
ComposedAction_test
TimedAction_test
SendAction_test
ServiceHandler_test
)
list(APPEND handsForTests
test_ee
test_ee_spread
two_finger
two_finger_mimic
)
#run each test with each hand
foreach(hand ${handsForTests})
foreach(testEx ${testsExecutable})
add_test(
NAME ${testEx}_${hand}
COMMAND ${testEx} ${hand}
)
endforeach()
endforeach()
#for code coverage, from Arturo xbot2
add_custom_target(test_clean_coverage
COMMAND /bin/sh ${CMAKE_CURRENT_SOURCE_DIR}/test/scripts/clean_gcov.sh
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(test_coverage
COMMAND lcov -c -d . --output-file main_coverage.info
#remove external libraries in the coverage
COMMAND lcov -r main_coverage.info '/usr*' 'boost*' 'eigen3*' 'c++*' '/opt*' -o main_coverage.info
COMMAND genhtml main_coverage.info --output-directory coverage_out
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
## doxygen documentation
#A macro to allow clean, readable inclusion of subdirectories
macro(optional_build name path ONOFF)
option(BUILD_${name} ${ONOFF})
if( BUILD_${name} )
#We this need to make include files available examples... a bit brute force
#include_directories("${PROJECT_SOURCE_DIR}/${path}")
add_subdirectory(${path})
endif()
endmacro(optional_build name path ONOFF)
optional_build(documentation doc ON)
#unset(BUILD_WITH_XBOT2 CACHE) # todo check if necesasry