Skip to content

Commit 85b7c01

Browse files
committed
Remove trajectory until node
change interface between hardware interface and controller Intermediate commit
1 parent b18bfc3 commit 85b7c01

File tree

8 files changed

+55
-574
lines changed

8 files changed

+55
-574
lines changed

ur_controllers/include/ur_controllers/tool_contact_controller.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ToolContactController : public controller_interface::ControllerInterface
9090

9191
RealtimeGoalHandleBuffer rt_active_goal_; ///< Currently active action goal, if any.
9292
rclcpp::TimerBase::SharedPtr goal_handle_timer_; ///< Timer to frequently check on the running goal
93-
std::chrono::nanoseconds action_monitor_period_;
93+
rclcpp::duration<std::chrono::nanoseconds> action_monitor_period_;
9494

9595
void action_handler(RealtimeGoalHandlePtr rt_goal);
9696

@@ -113,7 +113,8 @@ class ToolContactController : public controller_interface::ControllerInterface
113113

114114
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_result_interface_;
115115
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> major_version_state_interface_;
116-
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>> tool_contact_status_interface_;
116+
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_state_interface_;
117+
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>> tool_contact_set_state_interface_;
117118
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>> reference_interface_;
118119

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

ur_controllers/include/ur_controllers/trajectory_until_node.hpp

Lines changed: 0 additions & 129 deletions
This file was deleted.

ur_controllers/src/tool_contact_controller.cpp

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,29 @@ controller_interface::CallbackReturn
9393
ToolContactController::on_activate(const rclcpp_lifecycle::State& /* previous_state */)
9494
{
9595
{
96-
const std::string interface_name = tool_contact_params_.tf_prefix + "tool_contact/tool_contact_status";
96+
const std::string interface_name = tool_contact_params_.tf_prefix + "tool_contact/tool_contact_state";
97+
auto it = std::find_if(state_interfaces_.begin(), state_interfaces_.end(),
98+
[&](auto& interface) { return (interface.get_name() == interface_name); });
99+
if (it != state_interfaces_.end()) {
100+
tool_contact_state_interface_ = *it;
101+
if (!tool_contact_state_interface_->get().get_value()) {
102+
RCLCPP_ERROR(get_node()->get_logger(),
103+
"Failed to set '%s' command interface, aborting activation of controller.",
104+
interface_name.c_str());
105+
return controller_interface::CallbackReturn::ERROR;
106+
}
107+
} else {
108+
RCLCPP_ERROR(get_node()->get_logger(), "Did not find '%s' in command interfaces.", interface_name.c_str());
109+
return controller_interface::CallbackReturn::ERROR;
110+
}
111+
}
112+
{
113+
const std::string interface_name = tool_contact_params_.tf_prefix + "tool_contact/tool_contact_set_state";
97114
auto it = std::find_if(command_interfaces_.begin(), command_interfaces_.end(),
98115
[&](auto& interface) { return (interface.get_name() == interface_name); });
99116
if (it != command_interfaces_.end()) {
100-
tool_contact_status_interface_ = *it;
101-
if (!tool_contact_status_interface_->get().set_value(TOOL_CONTACT_STANDBY)) {
117+
tool_contact_set_state_interface_ = *it;
118+
if (!tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_STANDBY)) {
102119
RCLCPP_ERROR(get_node()->get_logger(),
103120
"Failed to set '%s' command interface, aborting activation of controller.",
104121
interface_name.c_str());
@@ -148,7 +165,8 @@ ToolContactController::on_activate(const rclcpp_lifecycle::State& /* previous_st
148165
}
149166
}
150167

151-
action_monitor_period_ = rclcpp::Rate(tool_contact_params.action_monitor_rate).period();
168+
action_monitor_period_ =
169+
rclcpp::duration<std::chrono::nanoseconds>(rclcpp::Rate(tool_contact_params_.action_monitor_rate).period());
152170
return controller_interface::CallbackReturn::SUCCESS;
153171
}
154172

@@ -167,7 +185,7 @@ ToolContactController::on_deactivate(const rclcpp_lifecycle::State& /* previous_
167185
}
168186
if (tool_contact_active_) {
169187
tool_contact_active_ = false;
170-
if (!tool_contact_status_interface_->get().set_value(TOOL_CONTACT_WAITING_END)) {
188+
if (!tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_WAITING_END)) {
171189
RCLCPP_FATAL(get_node()->get_logger(), "Controller failed to update command interface.");
172190
return controller_interface::CallbackReturn::ERROR;
173191
}
@@ -260,16 +278,16 @@ controller_interface::return_type ToolContactController::update(const rclcpp::Ti
260278
if (tool_contact_abort_) {
261279
tool_contact_abort_ = false;
262280
tool_contact_enable_ = false;
263-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_WAITING_END);
281+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_WAITING_END);
264282
} else if (tool_contact_enable_) {
265283
tool_contact_enable_ = false;
266-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_WAITING_BEGIN);
284+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_WAITING_BEGIN);
267285
}
268286

269287
const auto active_goal = *rt_active_goal_.readFromRT();
270288

271-
const int status = static_cast<int>(tool_contact_status_interface_->get().get_value());
272-
switch (status) {
289+
const int state = static_cast<int>(tool_contact_state_interface_->get().get_value());
290+
switch (state) {
273291
case static_cast<int>(TOOL_CONTACT_EXECUTING):
274292
{
275293
tool_contact_active_ = true;
@@ -282,7 +300,7 @@ controller_interface::return_type ToolContactController::update(const rclcpp::Ti
282300
tool_contact_active_ = false;
283301
RCLCPP_INFO(get_node()->get_logger(), "Tool contact finished successfully.");
284302

285-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_WAITING_END);
303+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_WAITING_END);
286304
if (active_goal) {
287305
auto result = std::make_shared<ur_msgs::action::ToolContact::Result>();
288306
result->result = ur_msgs::action::ToolContact::Result::SUCCESS;
@@ -292,7 +310,7 @@ controller_interface::return_type ToolContactController::update(const rclcpp::Ti
292310
tool_contact_active_ = false;
293311
RCLCPP_ERROR(get_node()->get_logger(), "Tool contact aborted by hardware.");
294312

295-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_STANDBY);
313+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_STANDBY);
296314
if (active_goal) {
297315
auto result = std::make_shared<ur_msgs::action::ToolContact::Result>();
298316
result->result = ur_msgs::action::ToolContact::Result::ABORTED_BY_HARDWARE;
@@ -305,7 +323,7 @@ controller_interface::return_type ToolContactController::update(const rclcpp::Ti
305323
{
306324
RCLCPP_ERROR(get_node()->get_logger(), "Tool contact could not be enabled.");
307325
tool_contact_active_ = false;
308-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_STANDBY);
326+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_STANDBY);
309327

310328
if (active_goal) {
311329
auto result = std::make_shared<ur_msgs::action::ToolContact::Result>();
@@ -319,14 +337,14 @@ controller_interface::return_type ToolContactController::update(const rclcpp::Ti
319337
RCLCPP_INFO(get_node()->get_logger(), "Tool contact disabled successfully.");
320338
tool_contact_active_ = false;
321339

322-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_STANDBY);
340+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_STANDBY);
323341
} break;
324342

325343
case static_cast<int>(TOOL_CONTACT_FAILURE_END):
326344
{
327345
RCLCPP_ERROR(get_node()->get_logger(), "Tool contact could not be disabled.");
328346

329-
write_success &= tool_contact_status_interface_->get().set_value(TOOL_CONTACT_STANDBY);
347+
write_success &= tool_contact_set_state_interface_->get().set_value(TOOL_CONTACT_STANDBY);
330348

331349
if (active_goal) {
332350
auto result = std::make_shared<ur_msgs::action::ToolContact::Result>();

0 commit comments

Comments
 (0)