Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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?
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 @@
}
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>(

Check warning on line 274 in ur_robot_driver/src/dashboard_client_ros.cpp

View check run for this annotation

Codecov / codecov/patch

ur_robot_driver/src/dashboard_client_ros.cpp#L274

Added line #L274 was not covered by tests
"~/is_in_remote_control",
std::bind(&DashboardClientROS::handleRemoteControlQuery, this, std::placeholders::_1, std::placeholders::_2));

Check warning on line 276 in ur_robot_driver/src/dashboard_client_ros.cpp

View check run for this annotation

Codecov / codecov/patch

ur_robot_driver/src/dashboard_client_ros.cpp#L276

Added line #L276 was not covered by tests
}

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

bool DashboardClientROS::handleRemoteControlQuery(

Check warning on line 419 in ur_robot_driver/src/dashboard_client_ros.cpp

View check run for this annotation

Codecov / codecov/patch

ur_robot_driver/src/dashboard_client_ros.cpp#L419

Added line #L419 was not covered by tests
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;

Check warning on line 431 in ur_robot_driver/src/dashboard_client_ros.cpp

View check run for this annotation

Codecov / codecov/patch

ur_robot_driver/src/dashboard_client_ros.cpp#L423-L431

Added lines #L423 - L431 were not covered by tests
}

} // namespace ur_robot_driver
Loading