Skip to content

Commit

Permalink
Update configuration for the examples package
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanscherzinger committed Apr 18, 2024
1 parent 11fb36a commit c30e301
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 43 deletions.
56 changes: 56 additions & 0 deletions schunk_egu_egk_gripper_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()

Empty file.
26 changes: 26 additions & 0 deletions schunk_egu_egk_gripper_examples/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<package format="3">
<name>schunk_egu_egk_gripper_examples</name>
<version>1.0.0</version>
<description>Example node for Schunk's EGU/EGK driver interfaces</description>
<author>Viktora Krimer</author>
<author>Fabian Reinwald</author>
<maintainer email="[email protected]">Stefan Scherzinger</maintainer>

<license>todo</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>schunk_egu_egk_gripper_interfaces</depend>
<depend>diagnostic_updater</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_components</depend>
<depend>control_msgs</depend>
<depend>sensor_msgs</depend>

<export>
<build_type>ament_cmake</build_type>
</export>

</package>
89 changes: 46 additions & 43 deletions schunk_egu_egk_gripper_examples/src/gripper_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rclcpp/parameter.hpp>
#include <rcl_interfaces/msg/parameter_event.hpp>
#include "sensor_msgs/msg/joint_state.hpp"
#include <diagnostic_updater/diagnostic_updater.hpp>

#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 <diagnostic_msgs/msg/diagnostic_array.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/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
Expand All @@ -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;
}
Expand Down Expand Up @@ -508,7 +511,7 @@ int main(int argc, char** argv)
auto control_client = rclcpp_action::create_client<GripperCommand>(node, name_space+"gripper_control");

//TOPICS
auto state_sub = node->create_subscription<schunk_gripper::msg::State>(name_space+"state", 1, stateCallback);
auto state_sub = node->create_subscription<State>(name_space+"state", 1, stateCallback);
auto joint_state_sub = node->create_subscription<sensor_msgs::msg::JointState>(name_space+"joint_states", 1, jointStateCallback);
auto diagnostics_sub = node->create_subscription<diagnostic_msgs::msg::DiagnosticArray>("diagnostics", 1, diagnosticsCallback);

Expand Down

0 comments on commit c30e301

Please sign in to comment.