ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Unable to control I/O states on UR10 (python) [closed]

asked 2020-01-16 10:05:54 -0600

SSar gravatar image

Hi. I'm working on a project where I need to pick up objects using a Universal Robots UR10 robot and a vacuum gripper. So far I am seeing positive results in executing move commands using movegroup python interface. I am, however, experiencing some problems in controlling digital output states using my script. I am using universal_robots package and the official Universal Robots ROS Driver.

Here's my import list:

import sys
import copy
import rospy
import tf2_ros
import tf
import moveit_commander
import moveit_msgs.msg
import geometry_msgs.msg
#from math import pi
import math
from std_msgs.msg import String
from moveit_commander.conversions import pose_to_list
from ur_msgs.msg import SetIO

My function which I'm calling in the main function:

  def apply_vacuum(self):
    rospy.wait_for_service('/ur_hardware_interface/set_io')
    try:
        set_io = rospy.ServiceProxy('/ur_hardware_interface/set_io',SetIO)
        set_io(fun = 1,pin = 2,state = 1)
    except rospy.ServiceException, e:
        print "Something went wrong: %s"%e

I'm getting no ServiceException. On my ur10_bringup.launch terminal I'm getting this error whenever I run the script above:

[ERROR] [1579178138.697529807]: Could not get fresh data package from robot

I can do a rosservice call (results in True):

rosservice call /ur_hardware_interface/set_io 1 2 1
success: True

I'm probably missing something. Any help is much appreciated. I'm running ROS Kinetic on Ubuntu 16.04 LTS with Lenovo Thinkpad X260.

EDIT: Seems like I'm trying to call a service that is present in the driver within universal_robots package, not the driver I am using. Am I correct? Running $rosservice list still yields /ur_hardware_interface/set_io.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by gvdhoorn
close date 2020-01-16 15:15:48.829352

Comments

I would suggest to post an issue on the UniversalRobots/Universal_Robots_ROS_Driver issue tracker, as I have the impression the usage of the service is correct, but there is something else going wrong (ie: inside the driver itself). The "could not get fresh data package from robot" is suspicious.

If you do post on the tracker, please post a comment here with a link to your issue there, so we keep things connected.

gvdhoorn gravatar image gvdhoorn  ( 2020-01-16 11:00:21 -0600 )edit
SSar gravatar image SSar  ( 2020-01-16 12:30:07 -0600 )edit

Closing as a duplicate then, with the duplicate being the issue on the tracker.

Summarising the discussion there: there is a good chance this is caused by the fact that OP Is also using EtherNet/IP, and the UR controller (at least with the current version of system software) does not seem to support using both EtherNet/IP and RTDE at the same time in certain configurations and with certain usage patterns.

gvdhoorn gravatar image gvdhoorn  ( 2020-01-16 15:17:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-25 03:27:46 -0600

stefvanlierop gravatar image

updated 2020-02-26 08:51:16 -0600

for the time being, until it is fixed. you could send raw script messages to the ur_hardware_interface/script_command

the code would ook like this

// include
from std_msgs.msg import String 
// the function 
def apply_vacuum(self):
rospy.init_node("apply_vacum_node") 
publisher1 = rospy.Publisher('/ur_hardware_interface/script_command', String, quesize=2)
try:
   // first 1 is the pin number and second number is the state of the pin 
    message = "sec MyProgram():" + "\n" + "set_standard_digital_out(1,1)" + "\n" + "end " + "\n"
    publisher1.publish(message)  
except rospy.ServiceException, e:
    print "Something went wrong: %s"%e

this will work but make sure you read the scripting manual for the functions that you can use in this format. make sure that you input the correct information. The format i used can be seen here

edit flag offensive delete link more

Comments

I've converted this to an answer, as even though the question itself is a duplicate of an issue on the UniversalRobots/Universal_Robots_ROS_Driver issue tracker, this answer shows how to send a URScript snippet to the script_command topic and I feel it deserves more visibility than a comment.

Do please note: from the issue the OP posted on the tracker it would actually appear that his problems were elsewhere. Not with the service per se.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-25 04:49:14 -0600 )edit

@stefvanlierop: I believe your line-endings are incorrect. Shouldn't the /n be \n?

gvdhoorn gravatar image gvdhoorn  ( 2020-02-25 04:51:12 -0600 )edit

yes i changed them

stefvanlierop gravatar image stefvanlierop  ( 2020-02-26 08:51:29 -0600 )edit

Question Tools

Stats

Asked: 2020-01-16 07:15:43 -0600

Seen: 1,201 times

Last updated: Feb 26 '20