Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure gripper speed and effort with hardware interface #1002

Merged
merged 39 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c7a0dfc
add gripper controller with optional velocity/effort
pac48 Feb 1, 2024
9e8b95a
add deprecation warning + fix test
pac48 Feb 1, 2024
9a4f9f5
update not released repos
pac48 Feb 5, 2024
9cb63e8
Use correct ref for scheduled workflows (#1013)
christophfroehlich Feb 5, 2024
9ae38f1
Add test_depend on `hardware_interface_testing` (#1018)
christophfroehlich Feb 5, 2024
f22922e
Add test_depend on `hardware_interface_testing` also for diff_drive (…
christophfroehlich Feb 5, 2024
6b83c4b
Bump codecov/codecov-action from 3.1.5 to 4.0.1 (#1023)
dependabot[bot] Feb 6, 2024
f06c43d
Bump actions/upload-artifact from 4.3.0 to 4.3.1 (#1024)
dependabot[bot] Feb 6, 2024
38cb474
Update antipodal_gripper_controller/doc/userdoc.rst
pac48 Feb 6, 2024
7eef191
Update antipodal_gripper_controller/CMakeLists.txt
pac48 Feb 6, 2024
8b6a5bd
Update antipodal_gripper_controller/doc/userdoc.rst
pac48 Feb 6, 2024
1d2f8b0
Update antipodal_gripper_controller/include/antipodal_gripper_control…
pac48 Feb 6, 2024
5a11b3e
Update antipodal_gripper_controller/include/antipodal_gripper_control…
pac48 Feb 6, 2024
6bdacf3
fix use of commmand struct
pac48 Feb 6, 2024
1d626aa
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Feb 6, 2024
f9a5a66
update parameters
pac48 Feb 13, 2024
61a3fee
update interface names
pac48 Feb 13, 2024
114012b
update parameter name
pac48 Feb 15, 2024
ef2efb8
Update antipodal_gripper_controller/src/antipodal_gripper_action_cont…
pac48 Apr 2, 2024
4a99502
change boolean interface parameter to string
pac48 Apr 2, 2024
5f7c2d8
Update antipodal_gripper_controller/src/antipodal_gripper_action_cont…
pac48 Apr 2, 2024
f6dc00c
Merge branch 'pr-add-gripper-velocity-target-main' of github.com:pac4…
pac48 Apr 2, 2024
24160ca
Update antipodal_gripper_controller/src/antipodal_gripper_action_cont…
pac48 Apr 2, 2024
2a5754f
Merge branch 'pr-add-gripper-velocity-target-main' of github.com:pac4…
pac48 Apr 2, 2024
7145368
add detail userdoc and configurable state interface
pac48 Apr 2, 2024
347b235
update cmake
pac48 Apr 2, 2024
deff36a
fix test
pac48 Apr 2, 2024
e2cc8eb
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Apr 2, 2024
6b44ba8
rename controller
pac48 Apr 2, 2024
254ae07
fix format and add control_msgs to repos file
pac48 Apr 8, 2024
02aa67a
fix parameter file name
pac48 Apr 8, 2024
72b2f6c
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Apr 9, 2024
562bf51
Merge branch 'master' into pr-add-gripper-velocity-target-main
bmagyar May 8, 2024
fcbe5d2
use upstream control_msgs
bmagyar May 8, 2024
ebb347f
Add controller to index
christophfroehlich May 8, 2024
cda3718
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Jul 3, 2024
20141a8
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Jul 4, 2024
2c74803
Update parallel_gripper_controller/include/parallel_gripper_controlle…
pac48 Jul 11, 2024
1d5090d
Merge branch 'master' into pr-add-gripper-velocity-target-main
pac48 Jul 11, 2024
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
1 change: 1 addition & 0 deletions doc/controllers_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The controllers are using `common hardware interface definitions`_, and may use
Forward Command Controller <../forward_command_controller/doc/userdoc.rst>
Gripper Controller <../gripper_controllers/doc/userdoc.rst>
Joint Trajectory Controller <../joint_trajectory_controller/doc/userdoc.rst>
Parallel Gripper Controller <../parallel_gripper_controller/doc/userdoc.rst>
PID Controller <../pid_controller/doc/userdoc.rst>
Position Controllers <../position_controllers/doc/userdoc.rst>
Velocity Controllers <../velocity_controllers/doc/userdoc.rst>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ void GripperActionController<HardwareInterface>::preempt_active_goal()
template <const char * HardwareInterface>
controller_interface::CallbackReturn GripperActionController<HardwareInterface>::on_init()
{
RCLCPP_WARN(
bmagyar marked this conversation as resolved.
Show resolved Hide resolved
get_node()->get_logger(),
"[Deprecated]: the `position_controllers/GripperActionController` and "
"`effort_controllers::GripperActionController` controllers are replaced by "
"'parallel_gripper_controllers/GripperActionController' controller");
try
{
param_listener_ = std::make_shared<ParamListener>(get_node());
Expand Down
84 changes: 84 additions & 0 deletions parallel_gripper_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
cmake_minimum_required(VERSION 3.16)
project(parallel_gripper_controller LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_msgs
control_toolbox
controller_interface
generate_parameter_library
hardware_interface
pluginlib
rclcpp
rclcpp_action
realtime_tools
)

find_package(ament_cmake REQUIRED)
find_package(backward_ros REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

generate_parameter_library(parallel_gripper_action_controller_parameters
src/gripper_action_controller_parameters.yaml
)

add_library(parallel_gripper_action_controller SHARED
src/parallel_gripper_action_controller.cpp
)
target_compile_features(parallel_gripper_action_controller PUBLIC cxx_std_17)
target_include_directories(parallel_gripper_action_controller PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/parallel_gripper_action_controller>
)
target_link_libraries(parallel_gripper_action_controller PUBLIC
parallel_gripper_action_controller_parameters
)
ament_target_dependencies(parallel_gripper_action_controller PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})

pluginlib_export_plugin_description_file(controller_interface ros_control_plugins.xml)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(controller_manager REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

ament_add_gmock(test_load_parallel_gripper_action_controllers
test/test_load_parallel_gripper_action_controller.cpp
)
ament_target_dependencies(test_load_parallel_gripper_action_controllers
controller_manager
ros2_control_test_assets
)

ament_add_gmock(test_parallel_gripper_controller
test/test_parallel_gripper_controller.cpp
)
target_link_libraries(test_parallel_gripper_controller
parallel_gripper_action_controller
)
endif()

install(
DIRECTORY include/
DESTINATION include/parallel_gripper_action_controller
)
install(
TARGETS
parallel_gripper_action_controller
parallel_gripper_action_controller_parameters
EXPORT export_parallel_gripper_action_controller
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)

ament_export_targets(export_parallel_gripper_action_controller HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()
19 changes: 19 additions & 0 deletions parallel_gripper_controller/doc/userdoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:github_url: https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/parallel_gripper_controller/doc/userdoc.rst

.. _parallel_gripper_controller_userdoc:

Parallel Gripper Action Controller
-----------------------------------

Controller for executing a ``ParallelGripperCommand`` action for simple parallel grippers.
This controller supports grippers that offer position only control as well as grippers that allow configuring the velocity and effort.
By default, the controller will only claim the ``{joint}/position`` interface for control.
The velocity and effort interfaces can be optionally claimed by setting the ``max_velocity_interface`` and ``max_effort_interface`` parameter, respectively.
By default, the controller will try to claim position and velocity state interfaces.
The claimed state interfaces can be configured by setting the ``state_interfaces`` parameter.

Parameters
^^^^^^^^^^^
This controller uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ to handle its parameters.

.. generate_parameter_library_details:: ../src/gripper_action_controller_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// Copyright 2014, SRI International
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// \author Sachin Chitta, Adolfo Rodriguez Tsouroukdissian

#ifndef PARALLEL_GRIPPER_CONTROLLER__PARALLEL_GRIPPER_ACTION_CONTROLLER_HPP_
#define PARALLEL_GRIPPER_CONTROLLER__PARALLEL_GRIPPER_ACTION_CONTROLLER_HPP_

// C++ standard
#include <cassert>
#include <memory>
#include <stdexcept>
#include <string>

// ROS
#include "rclcpp/rclcpp.hpp"

// ROS messages
#include "control_msgs/action/parallel_gripper_command.hpp"

// rclcpp_action
#include "rclcpp_action/create_server.hpp"

// ros_controls
#include "controller_interface/controller_interface.hpp"
#include "hardware_interface/loaned_command_interface.hpp"
#include "hardware_interface/loaned_state_interface.hpp"
#include "parallel_gripper_controller/visibility_control.hpp"
#include "realtime_tools/realtime_buffer.h"
#include "realtime_tools/realtime_server_goal_handle.h"

// Project
#include "parallel_gripper_action_controller_parameters.hpp"

namespace parallel_gripper_action_controller
{
/**
* \brief Controller for executing a `ParallelGripperCommand` action.
*
* \tparam HardwareInterface Controller hardware interface. Currently \p
* hardware_interface::HW_IF_POSITION and \p
* hardware_interface::HW_IF_EFFORT are supported out-of-the-box.
*/

class GripperActionController : public controller_interface::ControllerInterface
{
public:
/**
* \brief Store position and max effort in struct to allow easier realtime
* buffer usage
*/
struct Commands
{
double position_cmd_; // Commanded position
double max_velocity_; // Desired max gripper velocity
double max_effort_; // Desired max allowed effort
};

GRIPPER_ACTION_CONTROLLER_PUBLIC GripperActionController();

/**
* @brief command_interface_configuration This controller requires the
* position command interfaces for the controlled joints
*/
GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::InterfaceConfiguration command_interface_configuration() const override;

/**
* @brief command_interface_configuration This controller requires the
* position and velocity state interfaces for the controlled joints
*/
GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::InterfaceConfiguration state_interface_configuration() const override;

GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::return_type update(
const rclcpp::Time & time, const rclcpp::Duration & period) override;

GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_init() override;

GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_configure(
const rclcpp_lifecycle::State & previous_state) override;

GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_activate(
const rclcpp_lifecycle::State & previous_state) override;

GRIPPER_ACTION_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_deactivate(
const rclcpp_lifecycle::State & previous_state) override;

realtime_tools::RealtimeBuffer<Commands> command_;
// pre-allocated memory that is re-used to set the realtime buffer
Commands command_struct_, command_struct_rt_;

protected:
using GripperCommandAction = control_msgs::action::ParallelGripperCommand;
using ActionServer = rclcpp_action::Server<GripperCommandAction>;
using ActionServerPtr = ActionServer::SharedPtr;
using GoalHandle = rclcpp_action::ServerGoalHandle<GripperCommandAction>;
using RealtimeGoalHandle =
realtime_tools::RealtimeServerGoalHandle<control_msgs::action::ParallelGripperCommand>;
using RealtimeGoalHandlePtr = std::shared_ptr<RealtimeGoalHandle>;
using RealtimeGoalHandleBuffer = realtime_tools::RealtimeBuffer<RealtimeGoalHandlePtr>;

bool update_hold_position_;

bool verbose_ = false; ///< Hard coded verbose flag to help in debugging
std::string name_; ///< Controller name.
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
joint_command_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
effort_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
speed_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>>
joint_position_state_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>>
joint_velocity_state_interface_;

std::shared_ptr<ParamListener> param_listener_;
Params params_;

RealtimeGoalHandleBuffer
rt_active_goal_; ///< Container for the currently active action goal, if any.
control_msgs::action::ParallelGripperCommand::Result::SharedPtr pre_alloc_result_;

rclcpp::Duration action_monitor_period_;

// ROS API
ActionServerPtr action_server_;

rclcpp::TimerBase::SharedPtr goal_handle_timer_;

rclcpp_action::GoalResponse goal_callback(
const rclcpp_action::GoalUUID & uuid, std::shared_ptr<const GripperCommandAction::Goal> goal);

rclcpp_action::CancelResponse cancel_callback(const std::shared_ptr<GoalHandle> goal_handle);

void accepted_callback(std::shared_ptr<GoalHandle> goal_handle);

void preempt_active_goal();

void set_hold_position();

rclcpp::Time last_movement_time_ = rclcpp::Time(0, 0, RCL_ROS_TIME); ///< Store stall time
double computed_command_; ///< Computed command

/**
* \brief Check for success and publish appropriate result and feedback.
**/
void check_for_success(
const rclcpp::Time & time, double error_position, double current_position,
double current_velocity);
};

} // namespace parallel_gripper_action_controller

#include "parallel_gripper_controller/parallel_gripper_action_controller_impl.hpp"

#endif // PARALLEL_GRIPPER_CONTROLLER__PARALLEL_GRIPPER_ACTION_CONTROLLER_HPP_
Loading
Loading