Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 ur_dashboard_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(srv_files
srv/Load.srv
srv/Popup.srv
srv/RawRequest.srv
srv/IsInRemoteControl.srv
)

set(action_files
Expand Down
4 changes: 4 additions & 0 deletions ur_dashboard_msgs/srv/IsInRemoteControl.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
string answer
bool remote_control # is the robot in remote control?
bool success # Did the dashboard server call succeed?
4 changes: 4 additions & 0 deletions ur_robot_driver/doc/ROS_INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ Stop program execution on the robot

Dismiss a protective stop to continue robot movements. NOTE: It is the responsibility of the user to ensure the cause of the protective stop is resolved before calling this service.

##### is_in_remote_control [ur_dashboard_msgs/IsInRemoteControl](http://docs.ros.org/en/rolling/p/ur_dashboard_msgs/srv/IsInRemoteControl.html)

Service to query whether the robot is in remote control

#### Parameters

##### receive_timeout (Required)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "ur_dashboard_msgs/srv/load.hpp"
#include "ur_dashboard_msgs/srv/popup.hpp"
#include "ur_dashboard_msgs/srv/raw_request.hpp"
#include "ur_dashboard_msgs/srv/is_in_remote_control.hpp"

namespace ur_robot_driver
{
Expand Down Expand Up @@ -115,6 +116,9 @@ class DashboardClientROS
bool handleRobotModeQuery(ur_dashboard_msgs::srv::GetRobotMode::Request::SharedPtr req,
ur_dashboard_msgs::srv::GetRobotMode::Response::SharedPtr resp);

bool handleRemoteControlQuery(ur_dashboard_msgs::srv::IsInRemoteControl::Request::SharedPtr req,
ur_dashboard_msgs::srv::IsInRemoteControl::Response::SharedPtr resp);

bool connect();

std::shared_ptr<rclcpp::Node> node_;
Expand Down Expand Up @@ -151,6 +155,7 @@ class DashboardClientROS
rclcpp::Service<ur_dashboard_msgs::srv::GetProgramState>::SharedPtr program_state_service_;
rclcpp::Service<ur_dashboard_msgs::srv::GetSafetyMode>::SharedPtr safety_mode_service_;
rclcpp::Service<ur_dashboard_msgs::srv::GetRobotMode>::SharedPtr robot_mode_service_;
rclcpp::Service<ur_dashboard_msgs::srv::IsInRemoteControl>::SharedPtr is_in_remote_control_service_;
};
} // namespace ur_robot_driver

Expand Down
21 changes: 21 additions & 0 deletions ur_robot_driver/src/dashboard_client_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ DashboardClientROS::DashboardClientROS(const rclcpp::Node::SharedPtr& node, cons
}
return true;
});

// Service to query whether the robot is in remote control.
is_in_remote_control_service_ = node_->create_service<ur_dashboard_msgs::srv::IsInRemoteControl>(
"~/is_in_remote_control",
std::bind(&DashboardClientROS::handleRemoteControlQuery, this, std::placeholders::_1, std::placeholders::_2));
}

bool DashboardClientROS::connect()
Expand Down Expand Up @@ -410,4 +415,20 @@ bool DashboardClientROS::handleRobotModeQuery(const ur_dashboard_msgs::srv::GetR
}
return true;
}

bool DashboardClientROS::handleRemoteControlQuery(
const ur_dashboard_msgs::srv::IsInRemoteControl::Request::SharedPtr req,
ur_dashboard_msgs::srv::IsInRemoteControl::Response::SharedPtr resp)
{
try {
resp->remote_control = this->client_.commandIsInRemoteControl();
resp->success = true;
} catch (const urcl::UrException& e) {
RCLCPP_ERROR(rclcpp::get_logger("Dashboard_Client"), "Service Call failed: '%s'", e.what());
resp->answer = e.what();
resp->success = false;
}
return true;
}

} // namespace ur_robot_driver
Loading