RealTime client Robot Mode

Hi @erik,

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:

0		ROBOT_MODE_DISCONNECTED				
1		ROBOT_MODE_CONFIRM_SAFETY				
2		ROBOT_MODE_BOOTING				
3		ROBOT_MODE_POWER_OFF				
4		ROBOT_MODE_POWER_ON				
5		ROBOT_MODE_IDLE				
6		ROBOT_MODE_BACKDRIVE				
7		ROBOT_MODE_RUNNING				
8		ROBOT_MODE_UPDATING_FIRMWARE				

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]
1 Like