Skip to content

Commit

Permalink
Fix parameter library export (ros-controls#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjw authored Oct 11, 2022
1 parent 9be3bfe commit eecb7f7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 50 deletions.
39 changes: 10 additions & 29 deletions admittance_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

add_library(${PROJECT_NAME} SHARED src/admittance_controller.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE include)
generate_parameter_library(${PROJECT_NAME}_parameters src/admittance_controller_parameters.yaml)
target_link_libraries(${PROJECT_NAME} admittance_controller_parameters)
ament_target_dependencies(${PROJECT_NAME} ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_library(admittance_controller SHARED src/admittance_controller.cpp)
target_include_directories(admittance_controller PRIVATE include)
generate_parameter_library(admittance_controller_parameters src/admittance_controller_parameters.yaml)
target_link_libraries(admittance_controller admittance_controller_parameters)
ament_target_dependencies(admittance_controller ${THIS_PACKAGE_INCLUDE_DEPENDS})

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE "ADMITTANCE_CONTROLLER_BUILDING_DLL")
target_compile_definitions(admittance_controller PRIVATE "ADMITTANCE_CONTROLLER_BUILDING_DLL")

pluginlib_export_plugin_description_file(controller_interface admittance_controller.xml)

install(DIRECTORY include/
DESTINATION include
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS admittance_controller admittance_controller_parameters
EXPORT export_admittance_controller
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand All @@ -68,23 +69,6 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

## create custom test function to pass yaml file into test main
#function(add_test_with_yaml_input TARGET SOURCES YAML_FILE)
#add_executable(${TARGET} ${SOURCES})
#_ament_cmake_gmock_find_gmock()
#target_include_directories(${TARGET} PUBLIC "${GMOCK_INCLUDE_DIRS}")
#target_link_libraries(${TARGET} ${GMOCK_LIBRARIES})
#set(executable "$<TARGET_FILE:${TARGET}>")
#set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${TARGET}.gtest.xml")
#ament_add_test(
#${TARGET}
#COMMAND ${executable} --ros-args --params-file ${YAML_FILE}
#--gtest_output=xml:${result_file}
#OUTPUT_FILE ${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${TARGET}.txt
#RESULT_FILE ${result_file}
#)
#endfunction()

# test loading admittance controller
add_rostest_with_parameters_gmock(test_load_admittance_controller test/test_load_admittance_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/test_params.yaml)
Expand All @@ -110,13 +94,10 @@ if(BUILD_TESTING)
)
endif()

ament_export_include_directories(
include
ament_export_targets(
export_admittance_controller HAS_LIBRARY_TARGET
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}
)
ament_export_libraries(
${PROJECT_NAME}
)
ament_package()
13 changes: 5 additions & 8 deletions force_torque_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
generate_parameter_library
geometry_msgs
hardware_interface
pluginlib
Expand All @@ -26,7 +27,6 @@ foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

find_package(generate_parameter_library REQUIRED)
generate_parameter_library(force_torque_sensor_broadcaster_parameters
src/force_torque_sensor_broadcaster_parameters.yaml
)
Expand Down Expand Up @@ -54,8 +54,8 @@ pluginlib_export_plugin_description_file(
controller_interface force_torque_sensor_broadcaster.xml)

install(
TARGETS
${PROJECT_NAME}
TARGETS force_torque_sensor_broadcaster force_torque_sensor_broadcaster_parameters
EXPORT export_force_torque_sensor_broadcaster
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down Expand Up @@ -101,11 +101,8 @@ if(BUILD_TESTING)
)
endif()

ament_export_include_directories(
include
)
ament_export_libraries(
${PROJECT_NAME}
ament_export_targets(
export_force_torque_sensor_broadcaster HAS_LIBRARY_TARGET
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}
Expand Down
3 changes: 1 addition & 2 deletions force_torque_sensor_broadcaster/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>generate_parameter_library</build_depend>

<depend>controller_interface</depend>
<depend>geometry_msgs</depend>
<depend>hardware_interface</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>realtime_tools</depend>
<depend>generate_parameter_library</depend>

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>controller_manager</test_depend>
Expand Down
17 changes: 7 additions & 10 deletions joint_trajectory_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
angles
controller_interface
control_msgs
control_toolbox
controller_interface
generate_parameter_library
hardware_interface
pluginlib
rclcpp
Expand All @@ -29,8 +30,6 @@ foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

find_package(generate_parameter_library REQUIRED)

generate_parameter_library(joint_trajectory_controller_parameters
src/joint_trajectory_controller_parameters.yaml
include/joint_trajectory_controller/validate_jtc_parameters.hpp
Expand All @@ -52,7 +51,8 @@ install(DIRECTORY include/
DESTINATION include
)

install(TARGETS ${PROJECT_NAME}
install(TARGETS joint_trajectory_controller joint_trajectory_controller_parameters
EXPORT export_joint_trajectory_controller
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down Expand Up @@ -105,13 +105,10 @@ if(BUILD_TESTING)
# )
endif()

ament_export_targets(
export_joint_trajectory_controller HAS_LIBRARY_TARGET
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}
)
ament_export_include_directories(
include
)
ament_export_libraries(
${PROJECT_NAME}
)
ament_package()
2 changes: 1 addition & 1 deletion joint_trajectory_controller/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>angles</build_depend>
<build_depend>generate_parameter_library</build_depend>
<build_depend>pluginlib</build_depend>
<build_depend>realtime_tools</build_depend>

Expand All @@ -27,6 +26,7 @@
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>trajectory_msgs</depend>
<depend>generate_parameter_library</depend>

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>controller_manager</test_depend>
Expand Down

0 comments on commit eecb7f7

Please sign in to comment.