It’s an 8byte double, yet I would expect it only to be one byte as “Robot Modes” under DataStreamFromURController states that there are only 9 different robot modes. What am I missing? How do I interpret the 8 byte double?
Probably it does not make sense. However, the data type didn’t change since then, I think it is either copy-paste error or this is an internal note for UR employees.
I noticed, that @ajp is the most familiar with communication interfaces, but last time he posted was over a month ago.
To make it even more confusing RTDE states that its robot_mode is Int32 and then refers to the excel sheet containing the client interfaces I linked in my first post.
Apologies for the delay, I have been on leave recently.
I can see how this can be confusing as the various interfaces have been updated individually and now provide slightly different formats for the robotmode field.
As you correctly referenced, in the realtime datastream the format of this value adheres to that listed in the DataStreamFromURController in the client interface excel sheet:
This value is formatted as a double presumably for simplicity so it can be processed in the same way as the surrounding values, most of which need to be non integer.
It’s easiest to unpack this using the python struct library as we have done with the other client interface examples: here’s a sample:
#!/usr/bin/env python
import socket
import struct
TCP_PORT = 30003
BUFFER_SIZE = 1108
TCP_IP = '127.0.0.1'
# Connect to Real Time Client
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
# Receive one package
rcvd = s.recv(BUFFER_SIZE)
s.close()
#unpack an integer and then 138 doubles
data = struct.unpack('!i138d',rcvd)
print "robotmode ", data[95]
RTDE is considerably simpler to get to grips with than the realtime client interface if you start from our Python samples.
Recommend you download the sample zip from the bottom of the following how to guide, familiarise yourself with the Python code and come back with any specific questions.