forked from ISIR-EXTENDER/robot_interfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
115 lines (87 loc) · 2.88 KB
/
CMakeLists.txt
File metadata and controls
115 lines (87 loc) · 2.88 KB
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
cmake_minimum_required(VERSION 3.8)
project(robot_interfaces)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
#### Options
option(ENABLE_FRANKA "Build with Franka Emika support" OFF)
option(BUILD_TESTING "Build tests" OFF)
### ROS2 Control dependencies
set(ROS2_CONTROL_DEPS
hardware_interface
controller_interface)
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(Eigen3 REQUIRED)
### ROS2 messages
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
### KDL and URDF
find_package(orocos_kdl REQUIRED)
find_package(kdl_parser REQUIRED)
find_package(urdf REQUIRED)
### ROS2_control packages
foreach(dep IN ITEMS ${ROS2_CONTROL_DEPS})
find_package(${dep} REQUIRED)
endforeach()
### Franka
if(ENABLE_FRANKA)
set(FRANKA_DEPS
Franka
franka_hardware
franka_msgs)
foreach(dep IN ITEMS ${FRANKA_DEPS})
find_package(${dep} REQUIRED)
endforeach()
endif()
### Sources
set(SRCS
src/kinova_velocity_component.cpp
src/generic_component.cpp
src/robot_interfaces_algos.cpp
src/joint_position_component.cpp
src/explorer_velocity_component.cpp
)
if(ENABLE_FRANKA)
list(APPEND SRCS src/franka_velocity_component.cpp)
endif()
# Create library
add_library(
robot_interfaces SHARED ${SRCS})
target_include_directories(
robot_interfaces PRIVATE include ${EIGEN3_INCLUDE_DIRS})
target_link_libraries(robot_interfaces Eigen3::Eigen ${orocos_kdl_LIBRARIES})
ament_target_dependencies(robot_interfaces Eigen3 geometry_msgs sensor_msgs
orocos_kdl kdl_parser urdf
${ROS2_CONTROL_DEPS})
# Franka specific linking and definitions
if(ENABLE_FRANKA)
target_compile_definitions(robot_interfaces PUBLIC BUILD_FRANKA_SUPPORT)
target_link_libraries(robot_interfaces Franka::Franka)
ament_target_dependencies(robot_interfaces ${FRANKA_DEPS})
target_compile_definitions(robot_interfaces PUBLIC ENABLE_FRANKA)
endif()
install(TARGETS robot_interfaces DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
ament_export_include_directories(include)
ament_export_libraries(robot_interfaces)
# Base exports
ament_export_dependencies(
Eigen3 geometry_msgs sensor_msgs
orocos_kdl kdl_parser urdf
${ROS2_CONTROL_DEPS}
)
# Conditional exports
if(ENABLE_FRANKA)
ament_export_dependencies(${FRANKA_DEPS})
endif()
# ==================== Testing ====================
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
# Generic FK Unit Test (works for any robot via environment variables)
ament_add_gtest(test_generic_fk_unit test/test_generic_fk_unit.cpp)
target_include_directories(test_generic_fk_unit PRIVATE include)
target_link_libraries(test_generic_fk_unit robot_interfaces)
ament_target_dependencies(test_generic_fk_unit rclcpp sensor_msgs Eigen3 orocos_kdl kdl_parser urdf)
endif()
ament_package()