# Accessing Robot Limits programmatically

**URL:** <https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919>\
**Category:** Robot Communication\
**Created:** [April 24, 2018, 7:35pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919 "2018-04-24T19:35:17Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon48249377](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@anon48249377](https://forum.universal-robots.com/u/anon48249377)\
**Post date:** [April 24, 2018, 7:35pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/1 "2018-04-24T19:35:17Z")

</div>

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](https://forum.universal-robots.com/t/safety-and-configuration-checksums/1430). Is it a recommended solution?

Regarding a), [this topic](https://forum.universal-robots.com/t/safety-checksum/988/3) 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?

---

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [April 26, 2018, 4:47am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/2 "2018-04-26T04:47:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![inu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/inu/32/732_2.png) [@inu](https://forum.universal-robots.com/u/inu)\
**Post date:** [April 26, 2018, 9:36pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/3 "2018-04-26T21:36:24Z")

</div>

@anon42905246 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](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/10f5c73d83cb3df34dfb8b33afca5c5587d05a40.png)

---

<div class="post-metadata">

**Author:** ![inu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/inu/32/732_2.png) [@inu](https://forum.universal-robots.com/u/inu)\
**Post date:** [April 26, 2018, 10:22pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/4 "2018-04-26T22:22:17Z")

</div>

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](https://forum.universal-robots.com/t/safety-and-configuration-checksums/1430/2) is a post that covers opening the installation file.

---

<div class="post-metadata">

**Author:** ![anon61872178](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@anon61872178](https://forum.universal-robots.com/u/anon61872178)\
**Post date:** [April 27, 2018, 1:49pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/6 "2018-04-27T13:49:23Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![inu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/inu/32/732_2.png) [@inu](https://forum.universal-robots.com/u/inu)\
**Post date:** [April 27, 2018, 2:52pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/7 "2018-04-27T14:52:47Z")

</div>

@anon61872178 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](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/2271f29f9a910c23b2c5a371d60eaffef685bd55.png)

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

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/1X/d60048352a19d8709c6b5ad4673d6b15da323443.png)

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

---

<div class="post-metadata">

**Author:** ![anon30805486](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon30805486](https://forum.universal-robots.com/u/anon30805486)\
**Post date:** [August 26, 2020, 7:55am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/8 "2020-08-26T07:55:07Z")

</div>

Can we get the joint limits using URScripts?

---

<div class="post-metadata">

**Author:** ![sko](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sko/32/573_2.png) [@sko](https://forum.universal-robots.com/u/sko)\
**Post date:** [September 1, 2020, 10:29am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/9 "2020-09-01T10:29:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anon30805486](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon30805486](https://forum.universal-robots.com/u/anon30805486)\
**Post date:** [September 15, 2020, 1:02pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/10 "2020-09-15T13:02:10Z")

</div>

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++?

---

<div class="post-metadata">

**Author:** ![anon30805486](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon30805486](https://forum.universal-robots.com/u/anon30805486)\
**Post date:** [September 18, 2020, 9:02am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/11 "2020-09-18T09:02:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![liyunbao123](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@liyunbao123](https://forum.universal-robots.com/u/liyunbao123)\
**Post date:** [January 4, 2021, 5:52am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/12 "2021-01-04T05:52:39Z")

</div>

Could you tell me the method that you get the data ?

I have tried but failed.

---

<div class="post-metadata">

**Author:** ![anon30805486](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon30805486](https://forum.universal-robots.com/u/anon30805486)\
**Post date:** [January 4, 2021, 6:12am UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/13 "2021-01-04T06:12:57Z")

</div>

I got the joint limits using the jointMinLimit and jointMaxLimit returned from the secondary interface. You need to extract the joint limits from the Robot State Message -\> Configuration Data .

What is the issue that you’re facing?

---

<div class="post-metadata">

**Author:** ![malacasse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/malacasse/32/56_2.png) [@malacasse](https://forum.universal-robots.com/u/malacasse)\
**Post date:** [February 15, 2021, 5:32pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/14 "2021-02-15T17:32:09Z")

</div>

@anon30805486 The Configuration Data gives you the robot min/max joint values but not those defined in the safety configuration.

---

<div class="post-metadata">

**Author:** ![malacasse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/malacasse/32/56_2.png) [@malacasse](https://forum.universal-robots.com/u/malacasse)\
**Post date:** [February 15, 2021, 5:35pm UTC](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/15 "2021-02-15T17:35:22Z")

</div>

@inu This [post #7 example](https://forum.universal-robots.com/t/accessing-robot-limits-programmatically/1919/7) is not really using the secondary client interface ?

The minJointRevolutions and maxJointRevolutions data are not in the secondary client interface and the minJointPosition and maxJointPosition from secondary client interface are not related to the safety settings.
