From fdfdfffef45868e53ea3779e67c50ca171322881 Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Wed, 17 Apr 2024 17:15:40 +0200 Subject: [PATCH 1/7] Restructure the package into adequate sub packages This is according to the ROS2 convention. --- README.md | 2 +- {doc => resources/images}/rqt_interface.png | Bin .../schunk_gripper_wrapper.hpp | 0 .../launch/schunk_launch.py | 0 .../launch/schunk_rqt_launch.py | 0 .../src/schunk_gripper_wrapper.cpp | 0 .../action/Grip.action | 0 .../action/GripWithPosition.action | 0 .../action/GripWithPositionAndVelocity.action | 0 .../action/GripWithVelocity.action | 0 .../action/MoveToAbsolutePosition.action | 0 .../action/MoveToRelativePosition.action | 0 .../action/ReleaseWorkpiece.action | 0 .../msg/State.msg | 0 .../srv/Acknowledge.srv | 0 .../srv/BrakeTest.srv | 0 .../srv/ChangeIp.srv | 0 .../srv/FastStop.srv | 0 .../srv/GripperInfo.srv | 0 .../srv/ParameterGet.srv | 0 .../srv/ParameterSet.srv | 0 .../srv/PrepareForShutdown.srv | 0 .../srv/ReleaseForManualMovement.srv | 0 .../srv/Softreset.srv | 0 .../srv/Stop.srv | 0 .../CMakeLists.txt | 59 +++++++++++------- .../communication.hpp | 0 .../schunk_egu_egk_gripper_library}/json.hpp | 0 .../schunk_gripper_lib.hpp | 0 .../package.xml | 0 .../src/communication.cpp | 0 .../src/gripper_example.cpp | 0 .../src/schunk_gripper_lib.cpp | 0 33 files changed, 36 insertions(+), 25 deletions(-) rename {doc => resources/images}/rqt_interface.png (100%) rename {src/schunk_gripper/include/schunk_gripper => schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver}/schunk_gripper_wrapper.hpp (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_driver}/launch/schunk_launch.py (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_driver}/launch/schunk_rqt_launch.py (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_driver}/src/schunk_gripper_wrapper.cpp (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/Grip.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/GripWithPosition.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/GripWithPositionAndVelocity.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/GripWithVelocity.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/MoveToAbsolutePosition.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/MoveToRelativePosition.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/action/ReleaseWorkpiece.action (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/msg/State.msg (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/Acknowledge.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/BrakeTest.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/ChangeIp.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/FastStop.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/GripperInfo.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/ParameterGet.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/ParameterSet.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/PrepareForShutdown.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/ReleaseForManualMovement.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/Softreset.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_interfaces}/srv/Stop.srv (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_library}/CMakeLists.txt (74%) rename {src/schunk_gripper/include/schunk_gripper => schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library}/communication.hpp (100%) rename {src/schunk_gripper/include/schunk_gripper => schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library}/json.hpp (100%) rename {src/schunk_gripper/include/schunk_gripper => schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library}/schunk_gripper_lib.hpp (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_library}/package.xml (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_library}/src/communication.cpp (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_library}/src/gripper_example.cpp (100%) rename {src/schunk_gripper => schunk_egu_egk_gripper_library}/src/schunk_gripper_lib.cpp (100%) diff --git a/README.md b/README.md index e54ce60..69f1ee6 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ ros2 launch schunk_gripper schunk_launch.py rqt ``` It is known that rqt can not get the message class for action feedback and action goals. -![rqt](doc/rqt_interface.png) +![rqt](resources/images/rqt_interface.png) Open: - Plugins/Configuration/Dynamic Reconfigure: For changing parameters. diff --git a/doc/rqt_interface.png b/resources/images/rqt_interface.png similarity index 100% rename from doc/rqt_interface.png rename to resources/images/rqt_interface.png diff --git a/src/schunk_gripper/include/schunk_gripper/schunk_gripper_wrapper.hpp b/schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp similarity index 100% rename from src/schunk_gripper/include/schunk_gripper/schunk_gripper_wrapper.hpp rename to schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp diff --git a/src/schunk_gripper/launch/schunk_launch.py b/schunk_egu_egk_gripper_driver/launch/schunk_launch.py similarity index 100% rename from src/schunk_gripper/launch/schunk_launch.py rename to schunk_egu_egk_gripper_driver/launch/schunk_launch.py diff --git a/src/schunk_gripper/launch/schunk_rqt_launch.py b/schunk_egu_egk_gripper_driver/launch/schunk_rqt_launch.py similarity index 100% rename from src/schunk_gripper/launch/schunk_rqt_launch.py rename to schunk_egu_egk_gripper_driver/launch/schunk_rqt_launch.py diff --git a/src/schunk_gripper/src/schunk_gripper_wrapper.cpp b/schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp similarity index 100% rename from src/schunk_gripper/src/schunk_gripper_wrapper.cpp rename to schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp diff --git a/src/schunk_gripper/action/Grip.action b/schunk_egu_egk_gripper_interfaces/action/Grip.action similarity index 100% rename from src/schunk_gripper/action/Grip.action rename to schunk_egu_egk_gripper_interfaces/action/Grip.action diff --git a/src/schunk_gripper/action/GripWithPosition.action b/schunk_egu_egk_gripper_interfaces/action/GripWithPosition.action similarity index 100% rename from src/schunk_gripper/action/GripWithPosition.action rename to schunk_egu_egk_gripper_interfaces/action/GripWithPosition.action diff --git a/src/schunk_gripper/action/GripWithPositionAndVelocity.action b/schunk_egu_egk_gripper_interfaces/action/GripWithPositionAndVelocity.action similarity index 100% rename from src/schunk_gripper/action/GripWithPositionAndVelocity.action rename to schunk_egu_egk_gripper_interfaces/action/GripWithPositionAndVelocity.action diff --git a/src/schunk_gripper/action/GripWithVelocity.action b/schunk_egu_egk_gripper_interfaces/action/GripWithVelocity.action similarity index 100% rename from src/schunk_gripper/action/GripWithVelocity.action rename to schunk_egu_egk_gripper_interfaces/action/GripWithVelocity.action diff --git a/src/schunk_gripper/action/MoveToAbsolutePosition.action b/schunk_egu_egk_gripper_interfaces/action/MoveToAbsolutePosition.action similarity index 100% rename from src/schunk_gripper/action/MoveToAbsolutePosition.action rename to schunk_egu_egk_gripper_interfaces/action/MoveToAbsolutePosition.action diff --git a/src/schunk_gripper/action/MoveToRelativePosition.action b/schunk_egu_egk_gripper_interfaces/action/MoveToRelativePosition.action similarity index 100% rename from src/schunk_gripper/action/MoveToRelativePosition.action rename to schunk_egu_egk_gripper_interfaces/action/MoveToRelativePosition.action diff --git a/src/schunk_gripper/action/ReleaseWorkpiece.action b/schunk_egu_egk_gripper_interfaces/action/ReleaseWorkpiece.action similarity index 100% rename from src/schunk_gripper/action/ReleaseWorkpiece.action rename to schunk_egu_egk_gripper_interfaces/action/ReleaseWorkpiece.action diff --git a/src/schunk_gripper/msg/State.msg b/schunk_egu_egk_gripper_interfaces/msg/State.msg similarity index 100% rename from src/schunk_gripper/msg/State.msg rename to schunk_egu_egk_gripper_interfaces/msg/State.msg diff --git a/src/schunk_gripper/srv/Acknowledge.srv b/schunk_egu_egk_gripper_interfaces/srv/Acknowledge.srv similarity index 100% rename from src/schunk_gripper/srv/Acknowledge.srv rename to schunk_egu_egk_gripper_interfaces/srv/Acknowledge.srv diff --git a/src/schunk_gripper/srv/BrakeTest.srv b/schunk_egu_egk_gripper_interfaces/srv/BrakeTest.srv similarity index 100% rename from src/schunk_gripper/srv/BrakeTest.srv rename to schunk_egu_egk_gripper_interfaces/srv/BrakeTest.srv diff --git a/src/schunk_gripper/srv/ChangeIp.srv b/schunk_egu_egk_gripper_interfaces/srv/ChangeIp.srv similarity index 100% rename from src/schunk_gripper/srv/ChangeIp.srv rename to schunk_egu_egk_gripper_interfaces/srv/ChangeIp.srv diff --git a/src/schunk_gripper/srv/FastStop.srv b/schunk_egu_egk_gripper_interfaces/srv/FastStop.srv similarity index 100% rename from src/schunk_gripper/srv/FastStop.srv rename to schunk_egu_egk_gripper_interfaces/srv/FastStop.srv diff --git a/src/schunk_gripper/srv/GripperInfo.srv b/schunk_egu_egk_gripper_interfaces/srv/GripperInfo.srv similarity index 100% rename from src/schunk_gripper/srv/GripperInfo.srv rename to schunk_egu_egk_gripper_interfaces/srv/GripperInfo.srv diff --git a/src/schunk_gripper/srv/ParameterGet.srv b/schunk_egu_egk_gripper_interfaces/srv/ParameterGet.srv similarity index 100% rename from src/schunk_gripper/srv/ParameterGet.srv rename to schunk_egu_egk_gripper_interfaces/srv/ParameterGet.srv diff --git a/src/schunk_gripper/srv/ParameterSet.srv b/schunk_egu_egk_gripper_interfaces/srv/ParameterSet.srv similarity index 100% rename from src/schunk_gripper/srv/ParameterSet.srv rename to schunk_egu_egk_gripper_interfaces/srv/ParameterSet.srv diff --git a/src/schunk_gripper/srv/PrepareForShutdown.srv b/schunk_egu_egk_gripper_interfaces/srv/PrepareForShutdown.srv similarity index 100% rename from src/schunk_gripper/srv/PrepareForShutdown.srv rename to schunk_egu_egk_gripper_interfaces/srv/PrepareForShutdown.srv diff --git a/src/schunk_gripper/srv/ReleaseForManualMovement.srv b/schunk_egu_egk_gripper_interfaces/srv/ReleaseForManualMovement.srv similarity index 100% rename from src/schunk_gripper/srv/ReleaseForManualMovement.srv rename to schunk_egu_egk_gripper_interfaces/srv/ReleaseForManualMovement.srv diff --git a/src/schunk_gripper/srv/Softreset.srv b/schunk_egu_egk_gripper_interfaces/srv/Softreset.srv similarity index 100% rename from src/schunk_gripper/srv/Softreset.srv rename to schunk_egu_egk_gripper_interfaces/srv/Softreset.srv diff --git a/src/schunk_gripper/srv/Stop.srv b/schunk_egu_egk_gripper_interfaces/srv/Stop.srv similarity index 100% rename from src/schunk_gripper/srv/Stop.srv rename to schunk_egu_egk_gripper_interfaces/srv/Stop.srv diff --git a/src/schunk_gripper/CMakeLists.txt b/schunk_egu_egk_gripper_library/CMakeLists.txt similarity index 74% rename from src/schunk_gripper/CMakeLists.txt rename to schunk_egu_egk_gripper_library/CMakeLists.txt index 4ce704a..a053372 100644 --- a/src/schunk_gripper/CMakeLists.txt +++ b/schunk_egu_egk_gripper_library/CMakeLists.txt @@ -74,58 +74,69 @@ ament_export_dependencies(rosidl_default_runtime) ament_export_include_directories(include) ament_export_dependencies(sensor_msgs control_msgs action_msgs diagnostic_msgs) -# Declare a C++ library for schunk_gripper_driver +#-------------------------------------------------------------------------------- +# Build +#-------------------------------------------------------------------------------- + +# The driver add_library(schunk_gripper_driver SHARED src/schunk_gripper_wrapper.cpp src/schunk_gripper_lib.cpp src/communication.cpp ) - -# Define compilation definition for schunk_gripper_driver -target_compile_definitions(schunk_gripper_driver - PRIVATE "COMPOSITION_BUILDING_DLL" +target_include_directories(schunk_gripper_driver PUBLIC + $ + $ ) - -# Link libraries to schunk_gripper_driver target_link_libraries(schunk_gripper_driver ${CURL_LIBRARIES} + ${cpp_typesupport_target} ) - -# Add dependencies for schunk_gripper_driver ament_target_dependencies(schunk_gripper_driver -"rclcpp" "sensor_msgs" "control_msgs" "rclcpp_action" "rclcpp_components" "diagnostic_updater" "diagnostic_msgs" + rclcpp + sensor_msgs + control_msgs + rclcpp_action + rclcpp_components + diagnostic_updater + diagnostic_msgs ) -rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp") -target_link_libraries(schunk_gripper_driver "${cpp_typesupport_target}") + +rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp") # Register schunk_gripper_driver as a component node rclcpp_components_register_nodes(schunk_gripper_driver "SchunkGripperNode") -# Link libraries to schunk_gripper_driver -target_link_libraries(schunk_gripper_driver - ${CURL_LIBRARIES} +# Example +add_executable(schunk_gripper_example + src/gripper_example.cpp ) - -# Install schunk_gripper_example executable -add_executable(schunk_gripper_example src/gripper_example.cpp) ament_target_dependencies(schunk_gripper_example -"rclcpp" "sensor_msgs" "control_msgs" "rclcpp_action" "rclcpp_components" "diagnostic_updater" "diagnostic_msgs" + rclcpp + sensor_msgs + control_msgs + rclcpp_action + rclcpp_components + diagnostic_updater + diagnostic_msgs +) +target_link_libraries(schunk_gripper_example + "${cpp_typesupport_target}" + schunk_gripper_driver ) -target_link_libraries(schunk_gripper_example "${cpp_typesupport_target}" schunk_gripper_driver) - -# Install targets +#-------------------------------------------------------------------------------- +# Install +#-------------------------------------------------------------------------------- install(TARGETS schunk_gripper_driver ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) - install(TARGETS schunk_gripper_example DESTINATION lib/${PROJECT_NAME} ) - install(DIRECTORY include/ DESTINATION include diff --git a/src/schunk_gripper/include/schunk_gripper/communication.hpp b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp similarity index 100% rename from src/schunk_gripper/include/schunk_gripper/communication.hpp rename to schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp diff --git a/src/schunk_gripper/include/schunk_gripper/json.hpp b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/json.hpp similarity index 100% rename from src/schunk_gripper/include/schunk_gripper/json.hpp rename to schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/json.hpp diff --git a/src/schunk_gripper/include/schunk_gripper/schunk_gripper_lib.hpp b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp similarity index 100% rename from src/schunk_gripper/include/schunk_gripper/schunk_gripper_lib.hpp rename to schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp diff --git a/src/schunk_gripper/package.xml b/schunk_egu_egk_gripper_library/package.xml similarity index 100% rename from src/schunk_gripper/package.xml rename to schunk_egu_egk_gripper_library/package.xml diff --git a/src/schunk_gripper/src/communication.cpp b/schunk_egu_egk_gripper_library/src/communication.cpp similarity index 100% rename from src/schunk_gripper/src/communication.cpp rename to schunk_egu_egk_gripper_library/src/communication.cpp diff --git a/src/schunk_gripper/src/gripper_example.cpp b/schunk_egu_egk_gripper_library/src/gripper_example.cpp similarity index 100% rename from src/schunk_gripper/src/gripper_example.cpp rename to schunk_egu_egk_gripper_library/src/gripper_example.cpp diff --git a/src/schunk_gripper/src/schunk_gripper_lib.cpp b/schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp similarity index 100% rename from src/schunk_gripper/src/schunk_gripper_lib.cpp rename to schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp From e6e6dbbafe13fc27b3cb2bbe33d7e9c2e0833106 Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Wed, 17 Apr 2024 17:47:59 +0200 Subject: [PATCH 2/7] Update configuration for the interfaces package --- schunk_egu_egk_gripper_driver/COLCON_IGNORE | 0 .../CMakeLists.txt | 54 +++++++++++++++++++ schunk_egu_egk_gripper_interfaces/README.md | 1 + schunk_egu_egk_gripper_interfaces/package.xml | 29 ++++++++++ schunk_egu_egk_gripper_library/COLCON_IGNORE | 0 5 files changed, 84 insertions(+) create mode 100644 schunk_egu_egk_gripper_driver/COLCON_IGNORE create mode 100644 schunk_egu_egk_gripper_interfaces/CMakeLists.txt create mode 100644 schunk_egu_egk_gripper_interfaces/README.md create mode 100644 schunk_egu_egk_gripper_interfaces/package.xml create mode 100644 schunk_egu_egk_gripper_library/COLCON_IGNORE diff --git a/schunk_egu_egk_gripper_driver/COLCON_IGNORE b/schunk_egu_egk_gripper_driver/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 diff --git a/schunk_egu_egk_gripper_interfaces/CMakeLists.txt b/schunk_egu_egk_gripper_interfaces/CMakeLists.txt new file mode 100644 index 0000000..466ca44 --- /dev/null +++ b/schunk_egu_egk_gripper_interfaces/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.10) +project(schunk_egu_egk_gripper_interfaces) + +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(rosidl_default_generators REQUIRED) +find_package(std_msgs REQUIRED) +find_package(sensor_msgs REQUIRED) +find_package(action_msgs REQUIRED) +find_package(control_msgs REQUIRED) +find_package(diagnostic_msgs REQUIRED) + +rosidl_generate_interfaces( + ${PROJECT_NAME} + action/Grip.action + action/GripWithPosition.action + action/GripWithPositionAndVelocity.action + action/GripWithVelocity.action + action/MoveToAbsolutePosition.action + action/MoveToRelativePosition.action + action/ReleaseWorkpiece.action + msg/State.msg + srv/Acknowledge.srv + srv/BrakeTest.srv + srv/ChangeIp.srv + srv/FastStop.srv + srv/GripperInfo.srv + srv/ParameterGet.srv + srv/ParameterSet.srv + srv/PrepareForShutdown.srv + srv/ReleaseForManualMovement.srv + srv/Softreset.srv + srv/Stop.srv + DEPENDENCIES + std_msgs + action_msgs + control_msgs + sensor_msgs + diagnostic_msgs +) + +ament_export_dependencies(rosidl_default_runtime) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + set(ament_cmake_copyright_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/schunk_egu_egk_gripper_interfaces/README.md b/schunk_egu_egk_gripper_interfaces/README.md new file mode 100644 index 0000000..8f3bb7f --- /dev/null +++ b/schunk_egu_egk_gripper_interfaces/README.md @@ -0,0 +1 @@ +# Schunk EGU/EGK Gripper Interfaces diff --git a/schunk_egu_egk_gripper_interfaces/package.xml b/schunk_egu_egk_gripper_interfaces/package.xml new file mode 100644 index 0000000..d450417 --- /dev/null +++ b/schunk_egu_egk_gripper_interfaces/package.xml @@ -0,0 +1,29 @@ + + + + schunk_egu_egk_gripper_interfaces + 1.0.0 + Provides interface descriptions to communicate with SCHUNK EGU/EGK grippers over ROS 2 + Stefan Scherzinger + todo + + ament_cmake + rosidl_default_generators + + rosidl_default_runtime + + std_msgs + action_msgs + control_msgs + sensor_msgs + diagnostic_msgs + + ament_lint_auto + ament_lint_common + + rosidl_interface_packages + + + ament_cmake + + diff --git a/schunk_egu_egk_gripper_library/COLCON_IGNORE b/schunk_egu_egk_gripper_library/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 From f5b84519bfa2eb8ceaca02542c49f1bfd9860395 Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Wed, 17 Apr 2024 19:21:57 +0200 Subject: [PATCH 3/7] Update configuration for the library package --- .../COLCON_IGNORE | 0 .../src/gripper_example.cpp | 0 schunk_egu_egk_gripper_library/CMakeLists.txt | 136 +++--------------- .../communication.hpp | 4 +- .../schunk_gripper_lib.hpp | 4 +- schunk_egu_egk_gripper_library/package.xml | 42 ++---- .../src/communication.cpp | 4 +- .../src/schunk_gripper_lib.cpp | 2 +- 8 files changed, 34 insertions(+), 158 deletions(-) rename {schunk_egu_egk_gripper_library => schunk_egu_egk_gripper_examples}/COLCON_IGNORE (100%) rename {schunk_egu_egk_gripper_library => schunk_egu_egk_gripper_examples}/src/gripper_example.cpp (100%) diff --git a/schunk_egu_egk_gripper_library/COLCON_IGNORE b/schunk_egu_egk_gripper_examples/COLCON_IGNORE similarity index 100% rename from schunk_egu_egk_gripper_library/COLCON_IGNORE rename to schunk_egu_egk_gripper_examples/COLCON_IGNORE diff --git a/schunk_egu_egk_gripper_library/src/gripper_example.cpp b/schunk_egu_egk_gripper_examples/src/gripper_example.cpp similarity index 100% rename from schunk_egu_egk_gripper_library/src/gripper_example.cpp rename to schunk_egu_egk_gripper_examples/src/gripper_example.cpp diff --git a/schunk_egu_egk_gripper_library/CMakeLists.txt b/schunk_egu_egk_gripper_library/CMakeLists.txt index a053372..f4e9e9e 100644 --- a/schunk_egu_egk_gripper_library/CMakeLists.txt +++ b/schunk_egu_egk_gripper_library/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.5) -project(schunk_gripper) +cmake_minimum_required(VERSION 3.22) +project(schunk_egu_egk_gripper_library) # Set C++ standard to 17 if not set if(NOT CMAKE_CXX_STANDARD) @@ -12,146 +12,48 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() # Find required packages -#find_package(PythonInterp 3.10 REQUIRED) -#find_package(Python3 3.10 REQUIRED) -find_package(ament_cmake REQUIRED) -find_package(ament_index_cpp REQUIRED) -find_package(rclcpp REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(control_msgs REQUIRED) -find_package(action_msgs REQUIRED) -find_package(rosidl_default_generators) -find_package(rclcpp_components REQUIRED) -find_package(rclcpp_action REQUIRED) -find_package(diagnostic_updater REQUIRED) -find_package(diagnostic_msgs REQUIRED) find_package(CURL REQUIRED) -# Additional include directories -include_directories( - include - ${CURL_INCLUDE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - -# Generate ROS interfaces -set(msg_files -"msg/State.msg" -) - -set(srv_files - "srv/BrakeTest.srv" - "srv/Acknowledge.srv" - "srv/ChangeIp.srv" - "srv/Stop.srv" - "srv/FastStop.srv" - "srv/GripperInfo.srv" - "srv/Softreset.srv" - "srv/ParameterGet.srv" - "srv/ParameterSet.srv" - "srv/PrepareForShutdown.srv" - "srv/ReleaseForManualMovement.srv" -) -set(action_files - "action/GripWithPositionAndVelocity.action" - "action/GripWithPosition.action" - "action/GripWithVelocity.action" - "action/Grip.action" - "action/MoveToAbsolutePosition.action" - "action/MoveToRelativePosition.action" - "action/ReleaseWorkpiece.action" -) - -rosidl_generate_interfaces(${PROJECT_NAME} - ${msg_files} - ${srv_files} - ${action_files} - DEPENDENCIES sensor_msgs control_msgs action_msgs diagnostic_msgs -) - -# Export dependencies -ament_export_dependencies(rosidl_default_runtime) -ament_export_include_directories(include) -ament_export_dependencies(sensor_msgs control_msgs action_msgs diagnostic_msgs) - #-------------------------------------------------------------------------------- # Build #-------------------------------------------------------------------------------- -# The driver -add_library(schunk_gripper_driver SHARED - src/schunk_gripper_wrapper.cpp +add_library(${PROJECT_NAME} + SHARED src/schunk_gripper_lib.cpp src/communication.cpp ) -target_include_directories(schunk_gripper_driver PUBLIC +target_include_directories(${PROJECT_NAME} PUBLIC $ $ + ${CURL_INCLUDE_DIR} ) -target_link_libraries(schunk_gripper_driver +target_link_libraries(${PROJECT_NAME} ${CURL_LIBRARIES} - ${cpp_typesupport_target} -) -ament_target_dependencies(schunk_gripper_driver - rclcpp - sensor_msgs - control_msgs - rclcpp_action - rclcpp_components - diagnostic_updater - diagnostic_msgs -) - -rosidl_get_typesupport_target(cpp_typesupport_target "${PROJECT_NAME}" "rosidl_typesupport_cpp") -# Register schunk_gripper_driver as a component node -rclcpp_components_register_nodes(schunk_gripper_driver "SchunkGripperNode") - -# Example -add_executable(schunk_gripper_example - src/gripper_example.cpp -) -ament_target_dependencies(schunk_gripper_example - rclcpp - sensor_msgs - control_msgs - rclcpp_action - rclcpp_components - diagnostic_updater - diagnostic_msgs -) -target_link_libraries(schunk_gripper_example - "${cpp_typesupport_target}" - schunk_gripper_driver ) #-------------------------------------------------------------------------------- # Install #-------------------------------------------------------------------------------- -install(TARGETS - schunk_gripper_driver + +install(TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}_targets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin + INCLUDES DESTINATION include ) -install(TARGETS - schunk_gripper_example - DESTINATION lib/${PROJECT_NAME} -) -install(DIRECTORY - include/ - DESTINATION include -) -install(DIRECTORY - launch - DESTINATION share/${PROJECT_NAME}/ + +install( + DIRECTORY include/${PROJECT_NAME}/ + DESTINATION include/${PROJECT_NAME} + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" ) #-------------------------------------------------------------------------------- # Test #-------------------------------------------------------------------------------- -if(BUILD_TESTING) -endif() - -# Ament package configuration -ament_package() +enable_testing() diff --git a/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp index ed18729..de22066 100644 --- a/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp +++ b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/communication.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include //Control double word #define FAST_STOP 0x01000000 @@ -400,4 +400,4 @@ inline void AnybusCom::updateSaveData(std::vector &vector, const size } } } -#endif \ No newline at end of file +#endif diff --git a/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp index d906da3..9799fd2 100644 --- a/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp +++ b/schunk_egu_egk_gripper_library/include/schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp @@ -12,7 +12,7 @@ #ifndef SCHUNK_GRIPPER_HPP #define SCHUNK_GRIPPER_HPP -#include "schunk_gripper/communication.hpp" +#include "schunk_egu_egk_gripper_library/communication.hpp" #include #include #include @@ -97,4 +97,4 @@ inline void Gripper::changeVectorParameter(const char inst[7], std::vector - - schunk_gripper - 0.0.0 - The schunk_gripper package - + schunk_egu_egk_gripper_library + 1.0.0 + Standalone C++ library for Schunk's EGU/EGK grippers Viktora Krimer Fabian Reinwald - Viktoria Krimer - - BSD - MIT - curl + Stefan Scherzinger - ament_cmake - rosidl_default_generators - - ament_index_cpp - rclcpp - action_msgs - control_msgs - sensor_msgs - diagnostic_msgs - diagnostic_updater - rclcpp_action - rclcpp_components + todo - ros2launch - rosidl_default_runtime - - ament_lint_auto - ament_lint_common - - rosidl_interface_packages - - + cmake - - ament_cmake - + cmake + diff --git a/schunk_egu_egk_gripper_library/src/communication.cpp b/schunk_egu_egk_gripper_library/src/communication.cpp index 09c6067..9677979 100644 --- a/schunk_egu_egk_gripper_library/src/communication.cpp +++ b/schunk_egu_egk_gripper_library/src/communication.cpp @@ -9,7 +9,7 @@ * and posting a ByteString if any action needs to be performed by the gripper. */ -#include "schunk_gripper/communication.hpp" +#include "schunk_egu_egk_gripper_library/communication.hpp" //Write server response for storage in the Program size_t writeCallback(void* contents, size_t size, size_t nmemb, void* userp) { @@ -352,4 +352,4 @@ void AnybusCom::getMetadata(const std::string &instance) AnybusCom::~AnybusCom() { curl_easy_cleanup(curl); -} \ No newline at end of file +} diff --git a/schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp b/schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp index 328497b..6d79d5b 100644 --- a/schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp +++ b/schunk_egu_egk_gripper_library/src/schunk_gripper_lib.cpp @@ -9,7 +9,7 @@ * */ -#include "schunk_gripper/schunk_gripper_lib.hpp" +#include "schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp" std::recursive_mutex lock_mutex; //Locks if something is receiving or posting data //Commands for using in ROS From 033b2872aba5351d49d48f61c1e47a247370516c Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Thu, 18 Apr 2024 09:58:28 +0200 Subject: [PATCH 4/7] Make sure the library can be found with `find_package()` --- schunk_egu_egk_gripper_library/CMakeLists.txt | 36 +++++++++++++++++-- ...schunk_egu_egk_gripper_libraryConfig.cmake | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 schunk_egu_egk_gripper_library/schunk_egu_egk_gripper_libraryConfig.cmake diff --git a/schunk_egu_egk_gripper_library/CMakeLists.txt b/schunk_egu_egk_gripper_library/CMakeLists.txt index f4e9e9e..bf109b1 100644 --- a/schunk_egu_egk_gripper_library/CMakeLists.txt +++ b/schunk_egu_egk_gripper_library/CMakeLists.txt @@ -14,6 +14,22 @@ endif() # Find required packages find_package(CURL REQUIRED) +# -------------------------------------------------------------------------------- +# Make sure that library relocation works for both build and install. +# See here: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling +# -------------------------------------------------------------------------------- + +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +# The RPATH to use when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + #-------------------------------------------------------------------------------- # Build #-------------------------------------------------------------------------------- @@ -36,7 +52,8 @@ target_link_libraries(${PROJECT_NAME} # Install #-------------------------------------------------------------------------------- -install(TARGETS ${PROJECT_NAME} +install(TARGETS + ${PROJECT_NAME} EXPORT ${PROJECT_NAME}_targets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib @@ -44,9 +61,22 @@ install(TARGETS ${PROJECT_NAME} INCLUDES DESTINATION include ) +# Create and install a file with all exported targets +install(EXPORT ${PROJECT_NAME}_targets + DESTINATION lib/cmake/${PROJECT_NAME} + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE Schunk:: +) + +# Install the Config file so that find_package() works with this package +install(FILES ${PROJECT_NAME}Config.cmake + DESTINATION lib/cmake/${PROJECT_NAME} +) + +# Install the include directories install( - DIRECTORY include/${PROJECT_NAME}/ - DESTINATION include/${PROJECT_NAME} + DIRECTORY include/${PROJECT_NAME} + DESTINATION include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" diff --git a/schunk_egu_egk_gripper_library/schunk_egu_egk_gripper_libraryConfig.cmake b/schunk_egu_egk_gripper_library/schunk_egu_egk_gripper_libraryConfig.cmake new file mode 100644 index 0000000..1186d21 --- /dev/null +++ b/schunk_egu_egk_gripper_library/schunk_egu_egk_gripper_libraryConfig.cmake @@ -0,0 +1,2 @@ +include(CMakeFindDependencyMacro) +include("${CMAKE_CURRENT_LIST_DIR}/schunk_egu_egk_gripper_libraryTargets.cmake") From e0018735d0fd5e6990def62e0b091cf4401ba09d Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Thu, 18 Apr 2024 10:00:17 +0200 Subject: [PATCH 5/7] Update configuration for the driver package --- schunk_egu_egk_gripper_driver/CMakeLists.txt | 72 +++++++++++++++ schunk_egu_egk_gripper_driver/COLCON_IGNORE | 0 .../schunk_gripper_wrapper.hpp | 89 ++++++++++--------- schunk_egu_egk_gripper_driver/package.xml | 32 +++++++ .../src/schunk_gripper_wrapper.cpp | 4 +- 5 files changed, 151 insertions(+), 46 deletions(-) create mode 100644 schunk_egu_egk_gripper_driver/CMakeLists.txt delete mode 100644 schunk_egu_egk_gripper_driver/COLCON_IGNORE create mode 100644 schunk_egu_egk_gripper_driver/package.xml diff --git a/schunk_egu_egk_gripper_driver/CMakeLists.txt b/schunk_egu_egk_gripper_driver/CMakeLists.txt new file mode 100644 index 0000000..f4094de --- /dev/null +++ b/schunk_egu_egk_gripper_driver/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 3.22) +project(schunk_egu_egk_gripper_driver) + +# Set C++ standard to 17 if not set +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +# Compiler-specific options +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# Find required packages +find_package(schunk_egu_egk_gripper_library REQUIRED) +find_package(schunk_egu_egk_gripper_interfaces REQUIRED) +find_package(ament_cmake REQUIRED) +find_package(ament_index_cpp REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_components REQUIRED) +find_package(rclcpp_action REQUIRED) +find_package(diagnostic_updater REQUIRED) +find_package(sensor_msgs REQUIRED) +find_package(control_msgs REQUIRED) +find_package(diagnostic_msgs REQUIRED) + + +#-------------------------------------------------------------------------------- +# Build +#-------------------------------------------------------------------------------- + +add_library(${PROJECT_NAME} SHARED + src/schunk_gripper_wrapper.cpp +) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) +ament_target_dependencies(${PROJECT_NAME} + rclcpp + sensor_msgs + control_msgs + rclcpp_action + rclcpp_components + diagnostic_updater + diagnostic_msgs + schunk_egu_egk_gripper_interfaces +) +target_link_libraries(${PROJECT_NAME} + Schunk::schunk_egu_egk_gripper_library +) + +#-------------------------------------------------------------------------------- +# Install +#-------------------------------------------------------------------------------- +install(TARGETS ${PROJECT_NAME} + DESTINATION lib/${PROJECT_NAME}) + +install( + DIRECTORY launch + DESTINATION share/${PROJECT_NAME} +) + +#-------------------------------------------------------------------------------- +# Test +#-------------------------------------------------------------------------------- +if(BUILD_TESTING) +endif() + +# Ament package configuration +ament_package() + diff --git a/schunk_egu_egk_gripper_driver/COLCON_IGNORE b/schunk_egu_egk_gripper_driver/COLCON_IGNORE deleted file mode 100644 index e69de29..0000000 diff --git a/schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp b/schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp index f77250e..de162e2 100644 --- a/schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp +++ b/schunk_egu_egk_gripper_driver/include/schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp @@ -6,30 +6,30 @@ #include "rclcpp_components/register_node_macro.hpp" #include #include -#include "schunk_gripper/schunk_gripper_lib.hpp" +#include "schunk_egu_egk_gripper_library/schunk_gripper_lib.hpp" #include "sensor_msgs/msg/joint_state.hpp" +#include "control_msgs/action/gripper_command.hpp" #include -#include "schunk_gripper/action/grip_with_position.hpp" -#include "schunk_gripper/action/grip_with_velocity.hpp" -#include "schunk_gripper/action/grip_with_position_and_velocity.hpp" -#include "schunk_gripper/action/move_to_absolute_position.hpp" -#include "schunk_gripper/action/move_to_relative_position.hpp" -#include "schunk_gripper/msg/state.hpp" -#include "schunk_gripper/srv/acknowledge.hpp" -#include "schunk_gripper/srv/brake_test.hpp" -#include "schunk_gripper/srv/stop.hpp" -#include "schunk_gripper/srv/fast_stop.hpp" -#include "schunk_gripper/srv/prepare_for_shutdown.hpp" -#include "schunk_gripper/srv/softreset.hpp" -#include "schunk_gripper/action/release_workpiece.hpp" -#include "schunk_gripper/srv/release_for_manual_movement.hpp" -#include "schunk_gripper/srv/gripper_info.hpp" -#include "schunk_gripper/srv/change_ip.hpp" -#include "control_msgs/action/gripper_command.hpp" -#include "schunk_gripper/action/grip.hpp" -#include "schunk_gripper/srv/parameter_get.hpp" -#include "schunk_gripper/srv/parameter_set.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_position.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_velocity.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_position_and_velocity.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/move_to_absolute_position.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/move_to_relative_position.hpp" +#include "schunk_egu_egk_gripper_interfaces/msg/state.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/acknowledge.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/brake_test.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/stop.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/fast_stop.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/prepare_for_shutdown.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/softreset.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/release_workpiece.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/release_for_manual_movement.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/gripper_info.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/change_ip.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/parameter_get.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/parameter_set.hpp" extern std::map param_inst; extern std::map inst_param; @@ -39,26 +39,27 @@ class SchunkGripperNode : public rclcpp::Node, public Gripper private: std::mutex lock_service_post; - - using Acknowledge = schunk_gripper::srv::Acknowledge; - using BrakeTest = schunk_gripper::srv::BrakeTest; - using Stop = schunk_gripper::srv::Stop; - using FastStop = schunk_gripper::srv::FastStop; - using ReleaseForManualMovement = schunk_gripper::srv::ReleaseForManualMovement; - using Softreset = schunk_gripper::srv::Softreset; - using PrepareForShutdown = schunk_gripper::srv::PrepareForShutdown; - using GripperInfo= schunk_gripper::srv::GripperInfo; - using ChangeIp = schunk_gripper::srv::ChangeIp; - using ParameterGet = schunk_gripper::srv::ParameterGet; - using ParameterSet = schunk_gripper::srv::ParameterSet; - - using MoveToAbsolutePosition = schunk_gripper::action::MoveToAbsolutePosition; - using MoveToRelativePosition = schunk_gripper::action::MoveToRelativePosition; - using GripWithVelocity = schunk_gripper::action::GripWithVelocity; - using Grip = schunk_gripper::action::Grip; - using GripWithPositionAndVelocity = schunk_gripper::action::GripWithPositionAndVelocity; - using GripWithPosition = schunk_gripper::action::GripWithPosition; - using ReleaseWorkpiece = schunk_gripper::action::ReleaseWorkpiece; + using State = schunk_egu_egk_gripper_interfaces::msg::State; + + using Acknowledge = schunk_egu_egk_gripper_interfaces::srv::Acknowledge; + using BrakeTest = schunk_egu_egk_gripper_interfaces::srv::BrakeTest; + using Stop = schunk_egu_egk_gripper_interfaces::srv::Stop; + using FastStop = schunk_egu_egk_gripper_interfaces::srv::FastStop; + using ReleaseForManualMovement = schunk_egu_egk_gripper_interfaces::srv::ReleaseForManualMovement; + using Softreset = schunk_egu_egk_gripper_interfaces::srv::Softreset; + using PrepareForShutdown = schunk_egu_egk_gripper_interfaces::srv::PrepareForShutdown; + using GripperInfo= schunk_egu_egk_gripper_interfaces::srv::GripperInfo; + using ChangeIp = schunk_egu_egk_gripper_interfaces::srv::ChangeIp; + using ParameterGet = schunk_egu_egk_gripper_interfaces::srv::ParameterGet; + using ParameterSet = schunk_egu_egk_gripper_interfaces::srv::ParameterSet; + + using MoveToAbsolutePosition = schunk_egu_egk_gripper_interfaces::action::MoveToAbsolutePosition; + using MoveToRelativePosition = schunk_egu_egk_gripper_interfaces::action::MoveToRelativePosition; + using GripWithVelocity = schunk_egu_egk_gripper_interfaces::action::GripWithVelocity; + using Grip = schunk_egu_egk_gripper_interfaces::action::Grip; + using GripWithPositionAndVelocity = schunk_egu_egk_gripper_interfaces::action::GripWithPositionAndVelocity; + using GripWithPosition = schunk_egu_egk_gripper_interfaces::action::GripWithPosition; + using ReleaseWorkpiece = schunk_egu_egk_gripper_interfaces::action::ReleaseWorkpiece; using GripperCommand = control_msgs::action::GripperCommand; //Flags @@ -70,11 +71,11 @@ class SchunkGripperNode : public rclcpp::Node, public Gripper void publishState(); rclcpp::Publisher::SharedPtr jointStatePublisher; - rclcpp::Publisher::SharedPtr statePublisher; + rclcpp::Publisher::SharedPtr statePublisher; rclcpp::TimerBase::SharedPtr publish_state_timer; rclcpp::TimerBase::SharedPtr publish_joint_timer; - schunk_gripper::msg::State msg; + schunk_egu_egk_gripper_interfaces::msg::State msg; double state_frq; double j_state_frq; //Diagnostic updater @@ -205,4 +206,4 @@ class SchunkGripperNode : public rclcpp::Node, public Gripper rclcpp::Service::SharedPtr change_ip_service; }; -#endif \ No newline at end of file +#endif diff --git a/schunk_egu_egk_gripper_driver/package.xml b/schunk_egu_egk_gripper_driver/package.xml new file mode 100644 index 0000000..ea7a84d --- /dev/null +++ b/schunk_egu_egk_gripper_driver/package.xml @@ -0,0 +1,32 @@ + + + schunk_egu_egk_gripper_driver + 1.0.0 + ROS2 driver for Schunk's EGU/EGK grippers + Viktora Krimer + Fabian Reinwald + Stefan Scherzinger + + todo + + ament_cmake + + schunk_egu_egk_gripper_library + schunk_egu_egk_gripper_interfaces + ament_index_cpp + diagnostic_updater + rclcpp + rclcpp_action + rclcpp_components + control_msgs + sensor_msgs + + ros2launch + + + ament_cmake + + + + + diff --git a/schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp b/schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp index 11a2e3f..ecde8f4 100644 --- a/schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp +++ b/schunk_egu_egk_gripper_driver/src/schunk_gripper_wrapper.cpp @@ -1,4 +1,4 @@ -#include "schunk_gripper/schunk_gripper_wrapper.hpp" +#include "schunk_egu_egk_gripper_driver/schunk_gripper_wrapper.hpp" std::map param_inst = { @@ -168,7 +168,7 @@ void SchunkGripperNode::advertiseTopics() { //Advertise state last_time = this->now(); //Initialize last_time - statePublisher = this->create_publisher("state", 1); + statePublisher = this->create_publisher("state", 1); publish_state_timer=this->create_wall_timer(std::chrono::duration(1 / state_frq), std::bind(&SchunkGripperNode::publishState, this), messages_group); //Initialize diagnostics From 11fb36a9524a2bffea1362165520761bc0a4dfdd Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Thu, 18 Apr 2024 10:06:37 +0200 Subject: [PATCH 6/7] Increase the minimum CMake version for the interfaces --- schunk_egu_egk_gripper_interfaces/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schunk_egu_egk_gripper_interfaces/CMakeLists.txt b/schunk_egu_egk_gripper_interfaces/CMakeLists.txt index 466ca44..70847e4 100644 --- a/schunk_egu_egk_gripper_interfaces/CMakeLists.txt +++ b/schunk_egu_egk_gripper_interfaces/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.22) project(schunk_egu_egk_gripper_interfaces) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") From c30e30134906a5ca7abe4d036235a38e597cfeae Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Thu, 18 Apr 2024 17:24:30 +0200 Subject: [PATCH 7/7] Update configuration for the examples package --- .../CMakeLists.txt | 56 ++++++++++++ schunk_egu_egk_gripper_examples/COLCON_IGNORE | 0 schunk_egu_egk_gripper_examples/package.xml | 26 ++++++ .../src/gripper_example.cpp | 89 ++++++++++--------- 4 files changed, 128 insertions(+), 43 deletions(-) create mode 100644 schunk_egu_egk_gripper_examples/CMakeLists.txt delete mode 100644 schunk_egu_egk_gripper_examples/COLCON_IGNORE create mode 100644 schunk_egu_egk_gripper_examples/package.xml diff --git a/schunk_egu_egk_gripper_examples/CMakeLists.txt b/schunk_egu_egk_gripper_examples/CMakeLists.txt new file mode 100644 index 0000000..437422e --- /dev/null +++ b/schunk_egu_egk_gripper_examples/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.22) +project(schunk_egu_egk_gripper_examples) + +# Set C++ standard to 17 if not set +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) +endif() + +# Compiler-specific options +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# Find required packages +find_package(schunk_egu_egk_gripper_interfaces REQUIRED) +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_action REQUIRED) +find_package(sensor_msgs REQUIRED) +find_package(control_msgs REQUIRED) +find_package(diagnostic_msgs REQUIRED) + +#-------------------------------------------------------------------------------- +# Build +#-------------------------------------------------------------------------------- + +# Example +add_executable(${PROJECT_NAME} + src/gripper_example.cpp +) +ament_target_dependencies(${PROJECT_NAME} + schunk_egu_egk_gripper_interfaces + rclcpp + sensor_msgs + control_msgs + rclcpp_action + diagnostic_msgs +) + +#-------------------------------------------------------------------------------- +# Install +#-------------------------------------------------------------------------------- +install(TARGETS + ${PROJECT_NAME} + DESTINATION lib/${PROJECT_NAME} +) + +#-------------------------------------------------------------------------------- +# Test +#-------------------------------------------------------------------------------- +if(BUILD_TESTING) +endif() + +# Ament package configuration +ament_package() + diff --git a/schunk_egu_egk_gripper_examples/COLCON_IGNORE b/schunk_egu_egk_gripper_examples/COLCON_IGNORE deleted file mode 100644 index e69de29..0000000 diff --git a/schunk_egu_egk_gripper_examples/package.xml b/schunk_egu_egk_gripper_examples/package.xml new file mode 100644 index 0000000..335bfa1 --- /dev/null +++ b/schunk_egu_egk_gripper_examples/package.xml @@ -0,0 +1,26 @@ + + + schunk_egu_egk_gripper_examples + 1.0.0 + Example node for Schunk's EGU/EGK driver interfaces + Viktora Krimer + Fabian Reinwald + Stefan Scherzinger + + todo + + ament_cmake + + schunk_egu_egk_gripper_interfaces + diagnostic_updater + rclcpp + rclcpp_action + rclcpp_components + control_msgs + sensor_msgs + + + ament_cmake + + + diff --git a/schunk_egu_egk_gripper_examples/src/gripper_example.cpp b/schunk_egu_egk_gripper_examples/src/gripper_example.cpp index 5f6e606..f873780 100644 --- a/schunk_egu_egk_gripper_examples/src/gripper_example.cpp +++ b/schunk_egu_egk_gripper_examples/src/gripper_example.cpp @@ -3,56 +3,59 @@ #include "rclcpp/rclcpp.hpp" #include "rclcpp_action/rclcpp_action.hpp" #include "rclcpp/wait_for_message.hpp" -#include "rclcpp_components/register_node_macro.hpp" #include #include #include "sensor_msgs/msg/joint_state.hpp" -#include - -#include "schunk_gripper/schunk_gripper_wrapper.hpp" - -#include "schunk_gripper/action/grip_with_velocity.hpp" -#include "schunk_gripper/action/grip_with_position_and_velocity.hpp" -#include "schunk_gripper/action/move_to_absolute_position.hpp" -#include "schunk_gripper/action/move_to_relative_position.hpp" -#include "schunk_gripper/msg/state.hpp" -#include "schunk_gripper/srv/acknowledge.hpp" -#include "schunk_gripper/srv/stop.hpp" -#include "schunk_gripper/srv/fast_stop.hpp" -#include "schunk_gripper/srv/prepare_for_shutdown.hpp" -#include "schunk_gripper/srv/softreset.hpp" -#include "schunk_gripper/action/release_workpiece.hpp" -#include "schunk_gripper/srv/release_for_manual_movement.hpp" -#include "schunk_gripper/srv/gripper_info.hpp" +#include + +#include "schunk_egu_egk_gripper_interfaces/msg/state.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/acknowledge.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/stop.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/fast_stop.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/prepare_for_shutdown.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/softreset.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/brake_test.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/change_ip.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/parameter_get.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/parameter_set.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/release_for_manual_movement.hpp" +#include "schunk_egu_egk_gripper_interfaces/srv/gripper_info.hpp" + +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_velocity.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_position_and_velocity.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/move_to_absolute_position.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/move_to_relative_position.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/release_workpiece.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip.hpp" +#include "schunk_egu_egk_gripper_interfaces/action/grip_with_position.hpp" #include "control_msgs/action/gripper_command.hpp" -#include "schunk_gripper/action/grip.hpp" -#include "schunk_gripper/action/grip_with_position.hpp" -schunk_gripper::msg::State state_msg; +schunk_egu_egk_gripper_interfaces::msg::State state_msg; sensor_msgs::msg::JointState joint_state_msg; diagnostic_msgs::msg::DiagnosticArray diagnostic_msg; bool handshake; std::string name_space; - - using Acknowledge = schunk_gripper::srv::Acknowledge; - using BrakeTest = schunk_gripper::srv::BrakeTest; - using Stop = schunk_gripper::srv::Stop; - using FastStop = schunk_gripper::srv::FastStop; - using ReleaseForManualMovement = schunk_gripper::srv::ReleaseForManualMovement; - using Softreset = schunk_gripper::srv::Softreset; - using PrepareForShutdown = schunk_gripper::srv::PrepareForShutdown; - using GripperInfo= schunk_gripper::srv::GripperInfo; - using ChangeIp = schunk_gripper::srv::ChangeIp; - using ParameterGet = schunk_gripper::srv::ParameterGet; - using ParameterSet = schunk_gripper::srv::ParameterSet; - - using MoveToAbsolutePosition = schunk_gripper::action::MoveToAbsolutePosition; - using MoveToRelativePosition = schunk_gripper::action::MoveToRelativePosition; - using GripWithVelocity = schunk_gripper::action::GripWithVelocity; - using Grip = schunk_gripper::action::Grip; - using GripWithPositionAndVelocity = schunk_gripper::action::GripWithPositionAndVelocity; - using GripWithPosition = schunk_gripper::action::GripWithPosition; - using ReleaseWorkpiece = schunk_gripper::action::ReleaseWorkpiece; + using State = schunk_egu_egk_gripper_interfaces::msg::State; + + using Acknowledge = schunk_egu_egk_gripper_interfaces::srv::Acknowledge; + using BrakeTest = schunk_egu_egk_gripper_interfaces::srv::BrakeTest; + using Stop = schunk_egu_egk_gripper_interfaces::srv::Stop; + using FastStop = schunk_egu_egk_gripper_interfaces::srv::FastStop; + using ReleaseForManualMovement = schunk_egu_egk_gripper_interfaces::srv::ReleaseForManualMovement; + using Softreset = schunk_egu_egk_gripper_interfaces::srv::Softreset; + using PrepareForShutdown = schunk_egu_egk_gripper_interfaces::srv::PrepareForShutdown; + using GripperInfo= schunk_egu_egk_gripper_interfaces::srv::GripperInfo; + using ChangeIp = schunk_egu_egk_gripper_interfaces::srv::ChangeIp; + using ParameterGet = schunk_egu_egk_gripper_interfaces::srv::ParameterGet; + using ParameterSet = schunk_egu_egk_gripper_interfaces::srv::ParameterSet; + + using MoveToAbsolutePosition = schunk_egu_egk_gripper_interfaces::action::MoveToAbsolutePosition; + using MoveToRelativePosition = schunk_egu_egk_gripper_interfaces::action::MoveToRelativePosition; + using GripWithVelocity = schunk_egu_egk_gripper_interfaces::action::GripWithVelocity; + using Grip = schunk_egu_egk_gripper_interfaces::action::Grip; + using GripWithPositionAndVelocity = schunk_egu_egk_gripper_interfaces::action::GripWithPositionAndVelocity; + using GripWithPosition = schunk_egu_egk_gripper_interfaces::action::GripWithPosition; + using ReleaseWorkpiece = schunk_egu_egk_gripper_interfaces::action::ReleaseWorkpiece; using GripperCommand = control_msgs::action::GripperCommand; //Callback Functions @@ -64,7 +67,7 @@ std::string name_space; * * @param msg The shared pointer to the state message. */ -void stateCallback(const schunk_gripper::msg::State::SharedPtr msg) +void stateCallback(const State::SharedPtr msg) { state_msg = *msg; } @@ -508,7 +511,7 @@ int main(int argc, char** argv) auto control_client = rclcpp_action::create_client(node, name_space+"gripper_control"); //TOPICS - auto state_sub = node->create_subscription(name_space+"state", 1, stateCallback); + auto state_sub = node->create_subscription(name_space+"state", 1, stateCallback); auto joint_state_sub = node->create_subscription(name_space+"joint_states", 1, jointStateCallback); auto diagnostics_sub = node->create_subscription("diagnostics", 1, diagnosticsCallback);