Skip to content

Commit e75ac6d

Browse files
urmahpmergify[bot]
authored andcommitted
Added 'is in remote control' call as a dashboard service (#1433)
(cherry picked from commit 868f240)
1 parent 1096ec9 commit e75ac6d

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

ur_dashboard_msgs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(srv_files
2323
srv/Load.srv
2424
srv/Popup.srv
2525
srv/RawRequest.srv
26+
srv/IsInRemoteControl.srv
2627
)
2728

2829
set(action_files
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
string answer
3+
bool remote_control # is the robot in remote control?
4+
bool success # Did the dashboard server call succeed?

ur_robot_driver/doc/dashboard_client.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ unlock_protective_stop (`std_srvs/Trigger <http://docs.ros.org/en/rolling/p/std_
133133

134134
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.
135135

136+
is_in_remote_control (`ur_dashboard_msgs/IsInRemoteControl <http://docs.ros.org/en/rolling/p/ur_dashboard_msgs/srv/IsInRemoteControl.html>`_)
137+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138+
139+
Service to query whether the robot is in remote control
140+
136141
Parameters
137142
----------
138143

ur_robot_driver/include/ur_robot_driver/dashboard_client_ros.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "ur_dashboard_msgs/srv/load.hpp"
6363
#include "ur_dashboard_msgs/srv/popup.hpp"
6464
#include "ur_dashboard_msgs/srv/raw_request.hpp"
65+
#include "ur_dashboard_msgs/srv/is_in_remote_control.hpp"
6566

6667
namespace ur_robot_driver
6768
{
@@ -115,6 +116,9 @@ class DashboardClientROS
115116
bool handleRobotModeQuery(ur_dashboard_msgs::srv::GetRobotMode::Request::SharedPtr req,
116117
ur_dashboard_msgs::srv::GetRobotMode::Response::SharedPtr resp);
117118

119+
bool handleRemoteControlQuery(ur_dashboard_msgs::srv::IsInRemoteControl::Request::SharedPtr req,
120+
ur_dashboard_msgs::srv::IsInRemoteControl::Response::SharedPtr resp);
121+
118122
bool connect();
119123

120124
std::shared_ptr<rclcpp::Node> node_;
@@ -151,6 +155,7 @@ class DashboardClientROS
151155
rclcpp::Service<ur_dashboard_msgs::srv::GetProgramState>::SharedPtr program_state_service_;
152156
rclcpp::Service<ur_dashboard_msgs::srv::GetSafetyMode>::SharedPtr safety_mode_service_;
153157
rclcpp::Service<ur_dashboard_msgs::srv::GetRobotMode>::SharedPtr robot_mode_service_;
158+
rclcpp::Service<ur_dashboard_msgs::srv::IsInRemoteControl>::SharedPtr is_in_remote_control_service_;
154159
};
155160
} // namespace ur_robot_driver
156161

ur_robot_driver/src/dashboard_client_ros.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ DashboardClientROS::DashboardClientROS(const rclcpp::Node::SharedPtr& node, cons
269269
}
270270
return true;
271271
});
272+
273+
// Service to query whether the robot is in remote control.
274+
is_in_remote_control_service_ = node_->create_service<ur_dashboard_msgs::srv::IsInRemoteControl>(
275+
"~/is_in_remote_control",
276+
std::bind(&DashboardClientROS::handleRemoteControlQuery, this, std::placeholders::_1, std::placeholders::_2));
272277
}
273278

274279
bool DashboardClientROS::connect()
@@ -410,4 +415,20 @@ bool DashboardClientROS::handleRobotModeQuery(const ur_dashboard_msgs::srv::GetR
410415
}
411416
return true;
412417
}
418+
419+
bool DashboardClientROS::handleRemoteControlQuery(
420+
const ur_dashboard_msgs::srv::IsInRemoteControl::Request::SharedPtr req,
421+
ur_dashboard_msgs::srv::IsInRemoteControl::Response::SharedPtr resp)
422+
{
423+
try {
424+
resp->remote_control = this->client_.commandIsInRemoteControl();
425+
resp->success = true;
426+
} catch (const urcl::UrException& e) {
427+
RCLCPP_ERROR(rclcpp::get_logger("Dashboard_Client"), "Service Call failed: '%s'", e.what());
428+
resp->answer = e.what();
429+
resp->success = false;
430+
}
431+
return true;
432+
}
433+
413434
} // namespace ur_robot_driver

0 commit comments

Comments
 (0)