Universal Robots+

Accessing Robot Limits programmatically

Hi!

We would like to be able to access limits of the UR Joint/speed limits.

In our tests we would like to:
a) check what are the current joint limits on a robot (to verify it matches our config), and
b) set joint limits in URsim to whatever we have in our config (to make sure it matches real robot settings).

Regarding b), we plan to use suggestions from this topic. Is it a recommended solution?

Regarding a), this topic suggests that there is some undocumented API as part of secondary client interface that contain this type of data. Is it something we could use? Does it contain joint limits? If not, how can we read current joint limits?

Hello Jarek,

I think you can get it from Primary and Secondary Interface from package type 16 Robot_State, subpackage 6 Configuration Data.

You can also find it in installation file, so if you copy the program from robot to ursim limits will be the same. Installation file is a mix of xml and ini format, but it looks easily parsable.

@dozminkowski Is correct you should be able to get your joint limits through the client interfaces. I ran a quick test using the secondary Interface:

# Echo client program
import socket
import struct
import time

HOST = "192.168.7.110" # The remote host
PORT_30002 = 30002

def main():
	print "Starting Program"
	test = True
		
	count = 1
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	s.connect((HOST, PORT_30002))
	
	while (test):
		i= 0
		print ""
		
		data = s.recv(4096)
		packetLength = struct.unpack('!i', data[0:4])[0]

		while i+5 < packetLength:
			msglen = (struct.unpack('!i', data[5+i:9+i]))[0] 
			msgtype = (struct.unpack('!b', data[9+i]))[0] 
		

			if msgtype == 6:
			#extract length and type of message and print
				print 'packet length: ' + str(msglen)
				print 'message type: ' + str(msgtype)
				print '*******'
				print "success"
				print "joint 0"
				print (struct.unpack('!d', data[10+i:18+i])[0])*180/(3.14)
				print struct.unpack('!d', data[18+i:26+i])[0]*180/(3.14)
				print "Joint 1"
				print (struct.unpack('!d', data[26+i:34+i])[0])*180/(3.14)
				print struct.unpack('!d', data[34+i:42+i])[0]*180/(3.14)
				print "joint 2"
				print (struct.unpack('!d', data[42+i:50+i])[0])*180/(3.14)
				print struct.unpack('!d', data[50+i:58+i])[0]*180/(3.14)
				print "joint 3"
				print (struct.unpack('!d', data[58+i:66+i])[0])*180/(3.14)
				print struct.unpack('!d', data[66+i:74+i])[0]*180/(3.14)
				print "joint 4"
				print (struct.unpack('!d', data[74+i:82+i])[0])*180/(3.14)
				print struct.unpack('!d', data[82+i:90+i])[0]*180/(3.14)
				print "joint 5"
				print (struct.unpack('!d', data[90+i:98+i])[0])*180/(3.14)
				print struct.unpack('!d', data[98+i:106+i])[0]*180/(3.14)
				
				
			if msgtype == 7:
				test = False
			i = msglen + i
	s.close()

		
		
if	__name__ == '__main__':
    import sys
    main()

image

It seems like my example shows the max and min only, not the current joint limit settings. You are probably better off parsing the data from the installation file.

The values will be listed under [SafetyLimits Normal Joints] in the installation tab. Here is a post that covers opening the installation file.

@inu - I’m not sure I understand. Are you saying that this value represents what is max/min of safety limit for joint position and not the actual limit? Does that mean there are 3 types of values:

  • actual joint position
  • min and max safety limit for joint position
  • max and min for safety limit

@fpg Yeah you could look at it that way. The example I showed above using the secondary client interface (30002) shows the min/max of the joint limit:

image

Where the installation file will show you what you currently have your limits set too:

image

Then you can also get your actual joint position as well through the secondary client interface - through subpackage 1 - Joint Data.

1 Like

Can we get the joint limits using URScripts?

Hi Ronshi

it is not possible to get info about the used Safety Parameters using UR Script.
How would you use this information in your application?

Sorry for the late response. I need to just retrieve the joint limits.
I tried retrieving them via secondary interface. I do get all the robot state data using c++ in byte string format.
But I’m not able to extract the joint limit from the data returned.
Is there any method equivalent to struct.unpack in c++?

Thanks and sorry for the late response. I was able to retrieve it using the socket connection