Skip to content

Commit 2992337

Browse files
committed
Intermediate commit
1 parent c499541 commit 2992337

File tree

5 files changed

+183
-0
lines changed

5 files changed

+183
-0
lines changed

ur_controllers/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
5151

5252
include_directories(include)
5353

54+
generate_parameter_library(
55+
tool_contact_controller_parameters
56+
src/tool_contact_controller_parameters.yaml
57+
)
58+
5459
generate_parameter_library(
5560
force_mode_controller_parameters
5661
src/force_mode_controller_parameters.yaml
@@ -87,6 +92,7 @@ generate_parameter_library(
8792
)
8893

8994
add_library(${PROJECT_NAME} SHARED
95+
src/tool_contact_controller.cpp
9096
src/force_mode_controller.cpp
9197
src/scaled_joint_trajectory_controller.cpp
9298
src/speed_scaling_state_broadcaster.cpp
@@ -99,6 +105,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
99105
include
100106
)
101107
target_link_libraries(${PROJECT_NAME}
108+
tool_contact_controller_parameters
102109
force_mode_controller_parameters
103110
gpio_controller_parameters
104111
speed_scaling_state_broadcaster_parameters

ur_controllers/controller_plugins.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@
3434
Controller used to get and change the configuration of the robot
3535
</description>
3636
</class>
37+
<class name="ur_controllers/ToolContactController" type="ur_controllers::ToolContactController" base_class_type="controller_interface::ChainableControllerInterface">
38+
<description>
39+
Chainable controller to use the tool contact functionality of the robot.
40+
</description>
41+
</class>
3742
</library>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// Copyright 2025, Universal Robots A/S
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are met:
5+
//
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
//
9+
// * Redistributions in binary form must reproduce the above copyright
10+
// notice, this list of conditions and the following disclaimer in the
11+
// documentation and/or other materials provided with the distribution.
12+
//
13+
// * Neither the name of the {copyright_holder} nor the names of its
14+
// contributors may be used to endorse or promote products derived from
15+
// this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
// POSSIBILITY OF SUCH DAMAGE.
28+
29+
//----------------------------------------------------------------------
30+
/*!\file
31+
*
32+
* \author Jacob Larsen [email protected]
33+
* \date 2025-01-07
34+
*
35+
*
36+
*
37+
*
38+
*/
39+
//----------------------------------------------------------------------
40+
41+
#ifndef UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_
42+
#define UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_
43+
44+
#include <controller_interface/chainable_controller_interface.hpp>
45+
46+
namespace ur_controllers
47+
{
48+
class ToolContactController : public controller_interface::ChainableControllerInterface
49+
{
50+
public:
51+
CallbackReturn on_init() override;
52+
controller_interface::InterfaceConfiguration command_interface_configuration() override;
53+
controller_interface::InterfaceConfiguration state_interface_configuration() override;
54+
55+
protected:
56+
/// Virtual method that each chainable controller should implement to export its read-only
57+
/// chainable interfaces.
58+
/**
59+
* Each chainable controller implements this methods where all its state(read only) interfaces are
60+
* exported. The method has the same meaning as `export_state_interfaces` method from
61+
* hardware_interface::SystemInterface or hardware_interface::ActuatorInterface.
62+
*
63+
* \returns list of StateInterfaces that other controller can use as their inputs.
64+
*/
65+
std::vector<hardware_interface::StateInterface> on_export_state_interfaces() override;
66+
67+
/// Virtual method that each chainable controller should implement to export its read/write
68+
/// chainable interfaces.
69+
/**
70+
* Each chainable controller implements this methods where all input (command) interfaces are
71+
* exported. The method has the same meaning as `export_command_interface` method from
72+
* hardware_interface::SystemInterface or hardware_interface::ActuatorInterface.
73+
*
74+
* \returns list of CommandInterfaces that other controller can use as their outputs.
75+
*/
76+
std::vector<hardware_interface::CommandInterface> on_export_reference_interfaces() override;
77+
78+
/// Virtual method that each chainable controller should implement to switch chained mode.
79+
/**
80+
* Each chainable controller implements this methods to switch between "chained" and "external"
81+
* mode. In "chained" mode all external interfaces like subscriber and service servers are
82+
* disabled to avoid potential concurrency in input commands.
83+
*
84+
* \param[in] flag marking a switch to or from chained mode.
85+
*
86+
* \returns true if controller successfully switched between "chained" and "external" mode.
87+
* \default returns true so the method don't have to be overridden if controller can always switch
88+
* chained mode.
89+
*/
90+
bool on_set_chained_mode(bool chained_mode) override;
91+
92+
/// Update reference from input topics when not in chained mode.
93+
/**
94+
* Each chainable controller implements this method to update reference from subscribers when not
95+
* in chained mode.
96+
*
97+
* \returns return_type::OK if update is successfully, otherwise return_type::ERROR.
98+
*/
99+
controller_interface::return_type update_reference_from_subscribers(const rclcpp::Time& time,
100+
const rclcpp::Duration& period) override;
101+
102+
/// Execute calculations of the controller and update command interfaces.
103+
/**
104+
* Update method for chainable controllers.
105+
* In this method is valid to assume that \reference_interfaces_ hold the values for calculation
106+
* of the commands in the current control step.
107+
* This means that this method is called after \update_reference_from_subscribers if controller is
108+
* not in chained mode.
109+
*
110+
* \returns return_type::OK if calculation and writing of interface is successfully, otherwise
111+
* return_type::ERROR.
112+
*/
113+
controller_interface::return_type update_and_write_commands(const rclcpp::Time& time,
114+
const rclcpp::Duration& period) override;
115+
};
116+
} // namespace ur_controllers
117+
118+
#endif
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2025, Universal Robots A/S
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are met:
5+
//
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
//
9+
// * Redistributions in binary form must reproduce the above copyright
10+
// notice, this list of conditions and the following disclaimer in the
11+
// documentation and/or other materials provided with the distribution.
12+
//
13+
// * Neither the name of the {copyright_holder} nor the names of its
14+
// contributors may be used to endorse or promote products derived from
15+
// this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
// POSSIBILITY OF SUCH DAMAGE.
28+
29+
//----------------------------------------------------------------------
30+
/*!\file
31+
*
32+
* \author Jacob Larsen [email protected]
33+
* \date 2025-01-07
34+
*
35+
*
36+
*
37+
*
38+
*/
39+
//----------------------------------------------------------------------
40+
41+
#include <ur_controllers/tool_contact_controller.hpp>
42+
43+
namespace ur_controllers
44+
{
45+
46+
} // namespace ur_controllers
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
tool_contact_controller:
3+
tf_prefix: {
4+
type: string,
5+
default_value: "",
6+
description: "Urdf prefix of the corresponding arm"
7+
}

0 commit comments

Comments
 (0)