Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
373 changes: 204 additions & 169 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,169 +1,204 @@
cmake_minimum_required(VERSION 3.5)
project(hardware_interface)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
endif()

find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rcutils REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)

add_library(
hardware_interface
SHARED
src/actuator.cpp
src/component_parser.cpp
src/resource_manager.cpp
src/sensor.cpp
src/system.cpp
)
target_include_directories(
hardware_interface
PUBLIC
include
)
ament_target_dependencies(
hardware_interface
control_msgs
pluginlib
rcutils
rcpputils
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(hardware_interface PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
# prevent pluginlib from using boost
target_compile_definitions(hardware_interface PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

# Fake components
add_library(
fake_components
SHARED
src/fake_components/generic_system.cpp
)
target_include_directories(
fake_components
PUBLIC
include
)
target_link_libraries(
fake_components
hardware_interface
)
ament_target_dependencies(
fake_components
pluginlib
rcpputils
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(fake_components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
# prevent pluginlib from using boost
target_compile_definitions(fake_components PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(
hardware_interface fake_components_plugin_description.xml)

install(
DIRECTORY include/
DESTINATION include
)

install(
TARGETS
fake_components
hardware_interface
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gmock REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

ament_add_gmock(test_macros test/test_macros.cpp)
target_include_directories(test_macros PRIVATE include)
ament_target_dependencies(test_macros rcpputils)

ament_add_gmock(test_joint_handle test/test_handle.cpp)
target_link_libraries(test_joint_handle hardware_interface)
ament_target_dependencies(test_joint_handle rcpputils)

ament_add_gmock(test_component_interfaces test/test_component_interfaces.cpp)
target_link_libraries(test_component_interfaces hardware_interface)

ament_add_gmock(test_component_parser test/test_component_parser.cpp)
target_link_libraries(test_component_parser hardware_interface)
ament_target_dependencies(test_component_parser ros2_control_test_assets)

add_library(test_components SHARED
test/test_components/test_actuator.cpp
test/test_components/test_sensor.cpp
test/test_components/test_system.cpp)
target_link_libraries(test_components hardware_interface)
ament_target_dependencies(test_components
pluginlib)
install(TARGETS test_components
DESTINATION lib
)
pluginlib_export_plugin_description_file(
hardware_interface test/test_components/test_components.xml)

add_library(test_hardware_components SHARED
test/test_hardware_components/test_single_joint_actuator.cpp
test/test_hardware_components/test_force_torque_sensor.cpp
test/test_hardware_components/test_two_joint_system.cpp
test/test_hardware_components/test_system_with_command_modes.cpp
)
target_link_libraries(test_hardware_components hardware_interface)
ament_target_dependencies(test_hardware_components
pluginlib)
install(TARGETS test_hardware_components
DESTINATION lib
)
pluginlib_export_plugin_description_file(
hardware_interface test/test_hardware_components/test_hardware_components.xml
)

ament_add_gmock(test_resource_manager test/test_resource_manager.cpp)
target_link_libraries(test_resource_manager hardware_interface)
ament_target_dependencies(test_resource_manager ros2_control_test_assets)

ament_add_gmock(test_generic_system test/fake_components/test_generic_system.cpp)
target_include_directories(test_generic_system PRIVATE include)
target_link_libraries(test_generic_system hardware_interface)
ament_target_dependencies(test_generic_system
pluginlib
ros2_control_test_assets
)
endif()

ament_export_include_directories(
include
)
ament_export_libraries(
fake_components
hardware_interface
)
ament_export_dependencies(
control_msgs
pluginlib
rcpputils
tinyxml2_vendor
TinyXML2
)
ament_package()
cmake_minimum_required(VERSION 3.5)
project(hardware_interface)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
endif()

find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rcutils REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)
find_package(urdf REQUIRED)

add_library(
hardware_interface
SHARED
src/actuator.cpp
src/component_parser.cpp
src/resource_manager.cpp
src/sensor.cpp
src/system.cpp
)
target_include_directories(
hardware_interface
PUBLIC
include
)
ament_target_dependencies(
hardware_interface
control_msgs
pluginlib
rcutils
rcpputils
urdf
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(hardware_interface PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
# prevent pluginlib from using boost
target_compile_definitions(hardware_interface PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

# Fake components
add_library(
fake_components
SHARED
src/fake_components/generic_system.cpp
)
target_include_directories(
fake_components
PUBLIC
include
)
target_link_libraries(
fake_components
hardware_interface
)
ament_target_dependencies(
fake_components
pluginlib
rcpputils
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(fake_components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
# prevent pluginlib from using boost
target_compile_definitions(fake_components PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(
hardware_interface fake_components_plugin_description.xml)

install(
DIRECTORY include/
DESTINATION include
)

install(
TARGETS
fake_components
hardware_interface
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gmock REQUIRED)
find_package(ros2_control_test_assets REQUIRED)
find_package(launch_testing_ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

ament_add_gmock(test_macros test/test_macros.cpp)
target_include_directories(test_macros PRIVATE include)
ament_target_dependencies(test_macros rcpputils)

ament_add_gmock(test_joint_handle test/test_handle.cpp)
target_link_libraries(test_joint_handle hardware_interface)
ament_target_dependencies(test_joint_handle rcpputils)

ament_add_gmock(test_component_interfaces test/test_component_interfaces.cpp)
target_link_libraries(test_component_interfaces hardware_interface)

ament_add_gmock(test_component_parser test/test_component_parser.cpp)
target_link_libraries(test_component_parser hardware_interface)
ament_target_dependencies(test_component_parser ros2_control_test_assets)

add_library(test_components SHARED
test/test_components/test_actuator.cpp
test/test_components/test_sensor.cpp
test/test_components/test_system.cpp)
target_link_libraries(test_components hardware_interface)
ament_target_dependencies(test_components
pluginlib)
install(TARGETS test_components
DESTINATION lib
)
pluginlib_export_plugin_description_file(
hardware_interface test/test_components/test_components.xml)

add_library(test_hardware_components SHARED
test/test_hardware_components/test_single_joint_actuator.cpp
test/test_hardware_components/test_force_torque_sensor.cpp
test/test_hardware_components/test_two_joint_system.cpp
)
target_link_libraries(test_hardware_components hardware_interface)
ament_target_dependencies(test_hardware_components
pluginlib)
install(TARGETS test_hardware_components
DESTINATION lib
)
pluginlib_export_plugin_description_file(
hardware_interface test/test_hardware_components/test_hardware_components.xml
)

ament_add_gmock(test_resource_manager test/test_resource_manager.cpp)
target_link_libraries(test_resource_manager hardware_interface)
ament_target_dependencies(test_resource_manager ros2_control_test_assets)

ament_add_gmock(test_generic_system test/fake_components/test_generic_system.cpp)
target_include_directories(test_generic_system PRIVATE include)
target_link_libraries(test_generic_system hardware_interface)
ament_target_dependencies(test_generic_system
pluginlib
ros2_control_test_assets
)

# joint_limiter tests
ament_add_gmock(test_joint_limiter_interface test/joint_limits/test_joint_limiter_interface.cpp)
target_include_directories(test_joint_limiter_interface PUBLIC include)
ament_target_dependencies(test_joint_limiter_interface rcutils)

# joint_limit_interface tests
ament_add_gmock(joint_limits_interface_test test/joint_limits/joint_limits_interface_test.cpp)
target_include_directories(joint_limits_interface_test PUBLIC include)
ament_target_dependencies(joint_limits_interface_test rclcpp)

add_executable(joint_limits_rosparam_test test/joint_limits/joint_limits_rosparam_test.cpp)
target_include_directories(joint_limits_rosparam_test PUBLIC include ${GTEST_INCLUDE_DIRS})
target_link_libraries(joint_limits_rosparam_test ${GTEST_LIBRARIES})
ament_target_dependencies(joint_limits_rosparam_test rclcpp)
add_launch_test(test/joint_limits/joint_limits_rosparam.launch.py)
install(
TARGETS
joint_limits_rosparam_test
DESTINATION lib/${PROJECT_NAME}
)
install(
FILES
test/joint_limits/joint_limits_rosparam.yaml
DESTINATION share/${PROJECT_NAME}/test
)

ament_add_gmock(joint_limits_urdf_test test/joint_limits/joint_limits_urdf_test.cpp)
target_include_directories(joint_limits_urdf_test PUBLIC include)
ament_target_dependencies(joint_limits_urdf_test rclcpp urdf)
endif()

ament_export_include_directories(
include
)
ament_export_libraries(
fake_components
hardware_interface
)
ament_export_dependencies(
control_msgs
pluginlib
rcpputils
tinyxml2_vendor
TinyXML2
urdf
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the entire file flagged up as changed? changes between windows line ending vs unix?

)
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2021-06-20T21:44:25.360Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.6.13 Chrome/89.0.4389.128 Electron/12.0.7 Safari/537.36" etag="_8fPPfwWs52ysSfnFzpX" version="14.6.13" type="device"><diagram id="XTXSa4aPs-Zi3sgrq5kp" name="Seite-1">7Zrdc9o4EMD/GmbSh+tgGRt4LCRN7655KXPXjxdGsYWtxrZ8sghwf/2tZMkf2FAHCrRXZjLBWn0g7e5Pu5Lp2dN4fc9xGj4wn0Q91PfXPfu2hxDquwg+pGSTSyxrZOeSgFNfy0rBjP5LtLCvpUvqk6zWUDAWCZrWhR5LEuKJmgxzzlb1ZgsW1b81xQFpCGYejprSj9QXYS4doWEpf0doEJpvttxxXhNj01ivJAuxz1YVkX3Xs6ecMZE/xespiaT2jF7yfm931BYT4yQRXTrc3yPi/EnIl+xv92ltWffuw/w3PcozjpZ6wR9IxpbcIzPBuNLNG/ijCRUUR2Cd+Q32xBJDZW84zUiS5Q+bTJD4lV6o2BjtcbZMfCIn0O/Zk1VIBZml2JO1K3AYkIUijqBkweOCRtGURTCgfZuwBBpN4CuDBIo81/DkmXBBwThvtFwwOcaCJUJ7juWasp6EWSB0JOudmrMKe4AnExYTwTfQxLixq02onXigi6vSIQa2loUVZ3CHWoi1EwbF0KWd4EGb6gVmcxuaJj64rS4yLkIWsARHd6V0UrdF2eY9k0pUFvhKhNhoTeKlYHX7kDUVn2T3144ufa7U3K71yKqwMYUEllvpJIufq3VlN1Uy/aomBctM8vXKRe63IehEee8e3ekdSWAeELGnndPuE5xEWNDn+jy+u4FRg8sKgiHm/gpWfnMscFtK3gOgB2omvDDEUTgNrDpOltPkyRq08GSfCqfBFaeDcbI74oQuiZPdwOndx3y9GZgQ9f/6cPtWZikk8zhNBWVJT0ZTF8cSmfx/0WzLVQAEUbdsJjh7IlskdYFrO7zF1PeVs7WBXHfAdgsfxymqczpuwRSdE9PRFdODMXU6Yjq8JKZOM+rFKdhsngksCOSZHotjnPhzKoFZAA7ZTxoD7VGdreK8U4EL9c8Jl5nAla4D6Bp2pGt8SbqGDboy4efnu2c4OoPLm4AXCRXFdCWEM5oERWUg8mComKyQqKSu6voohwpqgxzyDU3aC6t91/gbkUXb4fKy0dd2nPoOMWzZIZyz7hDoukMcvEOMO+4Q1g6vOM8WMW5sESpFBtFXBhTCZ0RjKjJ5k8ZZXGbOgKkENiTek3TRkHqhuoAjKqte0ESm2f+DOG2jjnF6cDIKnSuFB1NomSvkb2I4uCSGZpoVDiOGJWF/SAzfSwbBwwG4CGcKRhla+wQr6jSq26H45hErksUmVbe69cF+NzH2VbNnUwJI46WUyWFmkKRHpD6znxH14RbqLedd1HbePdktL7qm5EegPuiK+kWTcjPNrlm5gnuuo7Bq1Urxdi6tS8ljpq+yKuMQ/kvl1Vu3WoMWzG3knDOijxou0DBGAHpJd65ev/zEj6Z5/6VaKVantTJs0UrrOy7rdMcNt6EW827yASc4kPu+9P8VBy86+hrocu8e9/hE01wXNEfz+gCUIbvB7vLPUr7Fhs0dEhGPmO2pkBcZitp1ZMLCFmW+Asf8FFSeiB/2Lu9FJlrXswINlNuyy5z13NCyqVyTic7JRNfj+65t9kzJRPP8nkEGQcy5XUZ6GEK+3MI9+ROVVHmkkBSal8pVIOE5wTHJp4r6T2TzgwL6rcweva5fpjktOLbm9s7JcGwe8Yq8T9mlmvTtuVc1V6dTZZaTJY7d0sh5jNNfOJV0W34Y1JpKHuBVUCx/KqbqKr+4s+/+Aw==</diagram></mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading