Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
af26b1e
Added service to enable and disable tool contact
URJala Feb 29, 2024
c1940cf
Revert "Added service to enable and disable tool contact"
URJala Apr 11, 2024
a62e842
Implemented tool contact
URJala Apr 11, 2024
da6c288
Implement test of tool contact
URJala Apr 11, 2024
4a4baa9
Merge remote-tracking branch 'origin/main' into tool_contact
Oct 18, 2024
c499541
Merge branch 'main' into tool_contact
URJala Jan 7, 2025
2992337
Intermediate commit
URJala Jan 7, 2025
4e4a24b
intermediate coomit
URJala Jan 7, 2025
b7eaf35
Tool contact controller is functional
URJala Jan 10, 2025
b19f71e
Intermediate commit
URJala Jan 13, 2025
b17a72c
Tool contact controller works when used with an action. Chaining is s…
URJala Jan 14, 2025
2224514
Merge branch 'main' into tool_contact
URJala Jan 14, 2025
947c30f
Add version check and fix formatting
URJala Jan 15, 2025
8b46761
started writing integration tests
URJala Jan 15, 2025
395a09c
Merge branch 'main' into tool_contact
URJala Jan 15, 2025
102204e
Remove chaining from controller and add trajectory_until node
URJala Jan 22, 2025
8e570be
Merge branch 'main' into tool_contact
URJala Jan 22, 2025
bdf5ae8
Clean up of code and logging. Added comments as well.
URJala Jan 23, 2025
b8917af
Merge branch 'main' into tool_contact
URJala Jan 23, 2025
a45d546
Added documentation and started writing tests
URJala Jan 24, 2025
a5a3ed6
Add test parameter of initial joint controller to test with different…
URJala Jan 27, 2025
57b4693
Remove until node from docs and cmake
URJala Feb 12, 2025
b18bfc3
Refactor tool contact controller
URJala Feb 12, 2025
85b7c01
Remove trajectory until node
URJala Feb 13, 2025
bd7d050
Wrote more tests and a little refactoring
URJala Feb 14, 2025
179224f
Merge branch 'main' into tool_contact
URJala Feb 26, 2025
06a9b39
Merge branch 'main' into tool_contact
URJala Mar 4, 2025
7f46156
Revert "Apply renaming of member variables of JTC (#1275)"
URJala Mar 4, 2025
0f92d5f
Remove Aborted and preempted from result reports
URJala Mar 4, 2025
3b27be0
Remove succesful result as well
URJala Mar 4, 2025
9959221
Revert "Apply renaming of member variables of JTC (#1275)"
URJala Mar 4, 2025
ed02c20
Reapply "Apply renaming of member variables of JTC (#1275)"
URJala Mar 14, 2025
c154ea5
Reapply "Apply renaming of member variables of JTC (#1275)"
URJala Mar 14, 2025
f7b898c
Update test and docs to the empty action definition
URJala Mar 14, 2025
e65e5fe
Merge branch 'main' into tool_contact
URJala Mar 14, 2025
79f3025
Update to use std::optional
URJala Mar 14, 2025
d3c228c
Merge remote-tracking branch 'origin/main' into tool_contact
urfeex Mar 18, 2025
f5bcaea
Add tool_contact_controllert to controller_switch tests
urfeex Mar 18, 2025
7bc8df1
Update controller documentation
urfeex Mar 18, 2025
39d1830
Use escaped parentheses in script_directory_url
urfeex Mar 18, 2025
2b46088
forward command interface to state interface
URJala Mar 25, 2025
2cf021f
Merge branch 'tool_contact' of github.com:URJala/Universal_Robots_ROS…
URJala Mar 25, 2025
e77410c
Change status to set_state in start_interfaces
URJala Mar 27, 2025
de7c107
Merge remote-tracking branch 'origin/main' into tool_contact
urfeex Apr 1, 2025
c36e961
Allow starting and stopping multiple interfaces at once
urfeex Apr 1, 2025
86a59ca
Fix state interface to get version information from
urfeex Apr 1, 2025
baa9f7c
Apply suggestions from code review
URJala Apr 8, 2025
7443b54
Merge branch 'main' into tool_contact
URJala Apr 8, 2025
e4a2bf4
Change name of goal_canceled_callback
URJala Apr 8, 2025
d173581
Tool contact is ended in the hardware interface, when controller is a…
URJala Apr 8, 2025
0d1fb3b
Publish feedback and handle cancel correctly
urfeex Apr 8, 2025
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
8 changes: 8 additions & 0 deletions ur_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS

include_directories(include)

generate_parameter_library(
tool_contact_controller_parameters
src/tool_contact_controller_parameters.yaml
)

generate_parameter_library(
force_mode_controller_parameters
src/force_mode_controller_parameters.yaml
Expand Down Expand Up @@ -87,6 +92,7 @@ generate_parameter_library(
)

add_library(${PROJECT_NAME} SHARED
src/tool_contact_controller.cpp
src/force_mode_controller.cpp
src/scaled_joint_trajectory_controller.cpp
src/speed_scaling_state_broadcaster.cpp
Expand All @@ -99,6 +105,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
include
)
target_link_libraries(${PROJECT_NAME}
tool_contact_controller_parameters
force_mode_controller_parameters
gpio_controller_parameters
speed_scaling_state_broadcaster_parameters
Expand All @@ -107,6 +114,7 @@ target_link_libraries(${PROJECT_NAME}
passthrough_trajectory_controller_parameters
ur_configuration_controller_parameters
)

ament_target_dependencies(${PROJECT_NAME}
${THIS_PACKAGE_INCLUDE_DEPENDS}
)
Expand Down
5 changes: 5 additions & 0 deletions ur_controllers/controller_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@
Controller used to get and change the configuration of the robot
</description>
</class>
<class name="ur_controllers/ToolContactController" type="ur_controllers::ToolContactController" base_class_type="controller_interface::ControllerInterface">
<description>
Controller to use the tool contact functionality of the robot.
</description>
</class>
</library>
44 changes: 44 additions & 0 deletions ur_controllers/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ robot family. Currently this contains:
but it uses the speed scaling reported to align progress of the trajectory between the robot and controller.
* A **io_and_status_controller** that allows setting I/O ports, controlling some UR-specific
functionality and publishes status information about the robot.
* A **tool_contact_controller** that exposes an action to enable the tool contact function on the robot.

About this package
------------------
Expand Down Expand Up @@ -378,3 +379,46 @@ The controller provides the ``~/enable_freedrive_mode`` topic of type ``[std_msg
* to deactivate freedrive mode is enough to publish a ``False`` msg on the indicated topic or
to deactivate the controller or to stop publishing ``True`` on the enable topic and wait for the
controller timeout.

.. _tool_contact_controller:

ur_controllers/ToolContactController
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This controller can enable tool contact on the robot. When tool contact is enabled, and the robot
senses whether the tool has made contact with something. When that happens, it will stop all
motion, and retract to where it first sensed the contact.

This controller can be used with any of the motion controllers.

The controller is not a direct representation of the URScript function `tool_contact(direction)
<https://www.universal-robots.com/manuals/EN/HTML/SW5_21/Content/prod-scriptmanual/all_scripts/tool_contact%28direction%29.htm?Highlight=tool_contact>`_,
as it does not allow for choosing the direction. The direction of tool contact will always be the
current TCP direction of movement.

Parameters
""""""""""

+-------------------------+--------+---------------+---------------------------------------------------------------------------------------+
| Parameter name | Type | Default value | Description |
| | | | |
+-------------------------+--------+---------------+---------------------------------------------------------------------------------------+
| ``tf_prefix`` | string | <empty> | Urdf prefix of the corresponding arm |
+-------------------------+--------+---------------+---------------------------------------------------------------------------------------+
| ``action_monitor_rate`` | double | 20.0 | The rate at which the action should be monitored in Hz. |
+-------------------------+--------+---------------+---------------------------------------------------------------------------------------+

Action interface / usage
""""""""""""""""""""""""
The controller provides one action for enabling tool contact. For the controller to accept action goals it needs to be in ``active`` state.

* ``~/detect_tool_contact [ur_msgs/action/ToolContact]``

The action definition of ``ur_msgs/action/ToolContact`` has no fields, as a call to the action implicitly means that tool contact should be enabled.
The result of the action is available through the status of the action itself. If the action succeeds it means that tool contact was detected, otherwise tool contact will remain active until it is either cancelled by the user, or aborted by the hardware.
The action provides no feedback.

The action can be called from the command line using the following command, when the controller is active:

.. code-block::

ros2 action send_goal /tool_contact_controller/detect_tool_contact ur_msgs/action/ToolContact
135 changes: 135 additions & 0 deletions ur_controllers/include/ur_controllers/tool_contact_controller.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright 2025, Universal Robots A/S
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the {copyright_holder} nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

//----------------------------------------------------------------------
/*!\file
*
* \author Jacob Larsen [email protected]
* \date 2025-01-07
*
*
*
*
*/
//----------------------------------------------------------------------

#ifndef UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_
#define UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_

#include <chrono>
#include <vector>
#include <memory>

#include <controller_interface/controller_interface.hpp>
#include "std_msgs/msg/bool.hpp"
#include <rclcpp_action/server.hpp>
#include <rclcpp_action/create_server.hpp>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_action/server_goal_handle.hpp>
#include <rclcpp/duration.hpp>

#include <realtime_tools/realtime_buffer.hpp>
#include <realtime_tools/realtime_server_goal_handle.hpp>

#include <ur_msgs/action/tool_contact.hpp>
#include "ur_controllers/tool_contact_controller_parameters.hpp"

namespace ur_controllers
{
class ToolContactController : public controller_interface::ControllerInterface
{
public:
ToolContactController() = default;
~ToolContactController() override = default;

Check warning on line 68 in ur_controllers/include/ur_controllers/tool_contact_controller.hpp

View check run for this annotation

Codecov / codecov/patch

ur_controllers/include/ur_controllers/tool_contact_controller.hpp#L67-L68

Added lines #L67 - L68 were not covered by tests

controller_interface::CallbackReturn on_init() override;

controller_interface::InterfaceConfiguration command_interface_configuration() const override;

controller_interface::InterfaceConfiguration state_interface_configuration() const override;

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

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

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

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

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

private:
using RealtimeGoalHandle = realtime_tools::RealtimeServerGoalHandle<ur_msgs::action::ToolContact>;
using RealtimeGoalHandlePtr = std::shared_ptr<RealtimeGoalHandle>;
using RealtimeGoalHandleBuffer = realtime_tools::RealtimeBuffer<RealtimeGoalHandlePtr>;

RealtimeGoalHandleBuffer rt_active_goal_; ///< Currently active action goal, if any.
ur_msgs::action::ToolContact::Feedback::SharedPtr feedback_; ///< preallocated feedback
rclcpp::TimerBase::SharedPtr goal_handle_timer_; ///< Timer to frequently check on the running goal

// non-rt function that will be called with action_monitor_period to monitor the rt action
rclcpp::Duration action_monitor_period_ = rclcpp::Duration::from_seconds(0.05);
void action_handler();

rclcpp_action::GoalResponse goal_received_callback(const rclcpp_action::GoalUUID& /*uuid*/,
std::shared_ptr<const ur_msgs::action::ToolContact::Goal> goal);

void
goal_accepted_callback(std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::ToolContact>> goal_handle);

rclcpp_action::CancelResponse goal_canceled_callback(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::ToolContact>> goal_handle);

std::atomic<bool> tool_contact_enable_ = false;
std::atomic<bool> tool_contact_active_ = false;
std::atomic<bool> tool_contact_abort_ = false;
std::atomic<bool> change_requested_ = false;
std::atomic<bool> logged_once_ = false;
std::atomic<bool> should_reset_goal = false;

std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_result_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> major_version_state_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_state_interface_;
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>> tool_contact_set_state_interface_;

rclcpp_action::Server<ur_msgs::action::ToolContact>::SharedPtr tool_contact_action_server_;

std::shared_ptr<tool_contact_controller::ParamListener> tool_contact_param_listener_;
tool_contact_controller::Params tool_contact_params_;

static constexpr double TOOL_CONTACT_STANDBY = 1.0;
static constexpr double TOOL_CONTACT_WAITING_BEGIN = 2.0;
static constexpr double TOOL_CONTACT_EXECUTING = 3.0;
static constexpr double TOOL_CONTACT_FAILURE_BEGIN = 4.0;
static constexpr double TOOL_CONTACT_WAITING_END = 5.0;
static constexpr double TOOL_CONTACT_SUCCESS_END = 6.0;
static constexpr double TOOL_CONTACT_FAILURE_END = 7.0;
};
} // namespace ur_controllers

#endif // UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_
Loading
Loading