Skip to content

Commit

Permalink
Add a set_analog_output service (#714)
Browse files Browse the repository at this point in the history
* Add a set_analog_output service

This service allows setting an analog output with an output domain.

* Fix formatting
  • Loading branch information
fmauch authored Sep 30, 2024
1 parent 27dbac5 commit b70c5b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ur_robot_driver/include/ur_robot_driver/hardware_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <ur_client_library/control/trajectory_point_interface.h>
#include <ur_msgs/IOStates.h>
#include <ur_msgs/ToolDataMsg.h>
#include <ur_msgs/SetAnalogOutput.h>
#include <ur_msgs/SetIO.h>
#include <ur_msgs/SetSpeedSliderFraction.h>
#include <ur_msgs/SetPayload.h>
Expand Down Expand Up @@ -211,6 +212,7 @@ class HardwareInterface : public hardware_interface::RobotHW

bool setSpeedSlider(ur_msgs::SetSpeedSliderFractionRequest& req, ur_msgs::SetSpeedSliderFractionResponse& res);
bool setIO(ur_msgs::SetIORequest& req, ur_msgs::SetIOResponse& res);
bool setAnalogOutput(ur_msgs::SetAnalogOutputRequest& req, ur_msgs::SetAnalogOutputResponse& res);
bool resendRobotProgram(std_srvs::TriggerRequest& req, std_srvs::TriggerResponse& res);
bool zeroFTSensor(std_srvs::TriggerRequest& req, std_srvs::TriggerResponse& res);
void commandCallback(const std_msgs::StringConstPtr& msg);
Expand Down Expand Up @@ -319,6 +321,7 @@ class HardwareInterface : public hardware_interface::RobotHW

ros::ServiceServer set_speed_slider_srv_;
ros::ServiceServer set_io_srv_;
ros::ServiceServer set_analog_output_srv_;
ros::ServiceServer resend_robot_program_srv_;
ros::Subscriber command_sub_;

Expand Down
13 changes: 12 additions & 1 deletion ur_robot_driver/src/hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
// doing. Using this with other controllers might lead to unexpected behaviors.
set_speed_slider_srv_ = robot_hw_nh.advertiseService("set_speed_slider", &HardwareInterface::setSpeedSlider, this);

// Service to set any of the robot's IOs
// Services to set any of the robot's IOs
set_io_srv_ = robot_hw_nh.advertiseService("set_io", &HardwareInterface::setIO, this);
set_analog_output_srv_ = robot_hw_nh.advertiseService("set_analog_output", &HardwareInterface::setAnalogOutput, this);

if (headless_mode)
{
Expand Down Expand Up @@ -1135,6 +1136,16 @@ bool HardwareInterface::setIO(ur_msgs::SetIORequest& req, ur_msgs::SetIOResponse
return true;
}

bool HardwareInterface::setAnalogOutput(ur_msgs::SetAnalogOutputRequest& req, ur_msgs::SetAnalogOutputResponse& res)
{
if (ur_driver_)
{
res.success = ur_driver_->getRTDEWriter().sendStandardAnalogOutput(
req.data.pin, req.data.state, static_cast<urcl::AnalogOutputType>(req.data.domain));
}
return true;
}

bool HardwareInterface::resendRobotProgram(std_srvs::TriggerRequest& req, std_srvs::TriggerResponse& res)
{
res.success = ur_driver_->sendRobotProgram();
Expand Down

3 comments on commit b70c5b2

@JoshEmbedded
Copy link

@JoshEmbedded JoshEmbedded commented on b70c5b2 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update is causing errors during catkin_make. It's unable to find the correct include file. As its called Analog in ur_msgs. After fixing that then there were a string of carry over errors.

Edit 9/10/24 15:10 - reverting to checkout 27dbac5 fixed the catkin_make issue.

@fmauch
Copy link
Collaborator Author

@fmauch fmauch commented on b70c5b2 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have the most recent version of ur_msgs installed? SetAnalogOutput is included from version 1.4.0 on. That has been made available to noetic 6 days ago: https://discourse.ros.org/t/new-packages-for-noetic-2024-10-03/39917

@JoshEmbedded
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have version 1.4.0. I attempted reverting back to master and received the error (see attached image).

Image

I determine its because I don't have the Universal Robot Client Library, however, when I did install that package it was unable to catkin_make and created bigger problems for me.

When investigating further, I found that the URCL package doesn't include the catkin macros in the CMakeLists.txt. My ROS knowledge is not sufficient enough to figure out a solution to this besides from reverting to the previous version before this update.

Please sign in to comment.