Skip to content

Commit f302220

Browse files
author
Felix Exner
committed
Make sure to reset the abort command interface when starting the controller
1 parent 9a3bad2 commit f302220

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ur_controllers/src/freedrive_mode_controller.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ ur_controllers::FreedriveModeController::on_activate(const rclcpp_lifecycle::Sta
152152
[&](auto& interface) { return (interface.get_name() == interface_name); });
153153
if (it != command_interfaces_.end()) {
154154
abort_command_interface_ = *it;
155+
abort_command_interface_->get().set_value(0.0);
155156
} else {
156157
RCLCPP_ERROR(get_node()->get_logger(), "Did not find '%s' in command interfaces.", interface_name.c_str());
157158
return controller_interface::CallbackReturn::ERROR;
@@ -186,7 +187,8 @@ controller_interface::return_type ur_controllers::FreedriveModeController::updat
186187
if (freedrive_active_) {
187188
// Check if the freedrive mode has been aborted from the hardware interface. E.g. the robot was stopped on the teach
188189
// pendant.
189-
if (abort_command_interface_->get().get_value() == 1.0) {
190+
if (!std::isnan(abort_command_interface_->get().get_value()) &&
191+
abort_command_interface_->get().get_value() == 1.0) {
190192
RCLCPP_INFO(get_node()->get_logger(), "Freedrive mode aborted by hardware, aborting action.");
191193
std::shared_ptr<ur_msgs::action::EnableFreedriveMode::Result> result =
192194
std::make_shared<ur_msgs::action::EnableFreedriveMode::Result>();

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,11 @@ void URPositionHardwareInterface::checkAsyncIO()
751751
freedrive_action_requested_ = true;
752752
}
753753

754-
if (!std::isnan(freedrive_mode_abort_) && freedrive_action_requested_ && ur_driver_ != nullptr) {
754+
if (!std::isnan(freedrive_mode_abort_) && freedrive_mode_abort_ == 1.0 && freedrive_action_requested_ &&
755+
ur_driver_ != nullptr) {
755756
RCLCPP_INFO(get_logger(), "Stopping freedrive mode.");
756757
freedrive_mode_async_success_ = ur_driver_->writeFreedriveControlMessage(urcl::control::FreedriveControlMessage::FREEDRIVE_STOP);
758+
freedrive_action_requested_ = false;
757759
freedrive_mode_abort_ = NO_NEW_CMD_;
758760
}
759761
}

0 commit comments

Comments
 (0)