Skip to content

Commit 5d021de

Browse files
committed
Added a service to setup the active payload
1 parent b531d25 commit 5d021de

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

ur_robot_driver/doc/ROS_INTERFACE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ This is the actual driver node containing the ROS-Control stack. Interfaces docu
669669

670670
Service to set any of the robot's IOs
671671

672+
* "**set_payload**" (ur_msgs/SetPayload)
673+
674+
Setup the mounted payload through a ROS service
675+
672676
* "**set_speed_slider**" (ur_msgs/SetSpeedSliderFraction)
673677

674678
Set the speed slider fraction used by the robot's execution. Values should be between 0 and 1. Only set this smaller than 1 if you are using the scaled controllers (as by default) or you know what you're doing. Using this with other controllers might lead to unexpected behaviors.

ur_robot_driver/include/ur_robot_driver/ros/hardware_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class HardwareInterface : public hardware_interface::RobotHW
196196
std::unique_ptr<DashboardClientROS> dashboard_client_;
197197

198198
ros::ServiceServer deactivate_srv_;
199+
ros::ServiceServer set_payload_srv_;
199200

200201
hardware_interface::JointStateInterface js_interface_;
201202
ur_controllers::ScaledPositionJointInterface spj_interface_;

ur_robot_driver/src/ros/hardware_interface.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "ur_robot_driver/ur/tool_communication.h"
3030
#include <ur_robot_driver/exceptions.h>
3131

32+
#include <ur_msgs/SetPayload.h>
33+
3234
#include <Eigen/Geometry>
3335

3436
namespace ur_driver
@@ -318,6 +320,18 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
318320
ur_driver_->startRTDECommunication();
319321
ROS_INFO_STREAM_NAMED("hardware_interface", "Loaded ur_robot_driver hardware_interface");
320322

323+
// Setup the mounted payload through a ROS service
324+
set_payload_srv_ = robot_hw_nh.advertiseService<ur_msgs::SetPayload::Request, ur_msgs::SetPayload::Response>(
325+
"set_payload", [&](ur_msgs::SetPayload::Request& req, ur_msgs::SetPayload::Response& resp) {
326+
std::stringstream cmd;
327+
cmd << "sec setup():" << std::endl
328+
<< " set_payload(" << req.payload << ", [" << req.center_of_gravity.x << ", " << req.center_of_gravity.y
329+
<< ", " << req.center_of_gravity.z << "])" << std::endl
330+
<< "end";
331+
resp.success = this->ur_driver_->sendScript(cmd.str());
332+
return true;
333+
});
334+
321335
return true;
322336
}
323337

0 commit comments

Comments
 (0)