Commit 714ad4af authored by Sam Calisch's avatar Sam Calisch

streamed a single move command

parent fde8dd96
......@@ -2,6 +2,7 @@ import socket
import time
import struct
from sys import stdout
from numpy import *
#Sam Calisch, 2015
#Center for Bits and Atoms, MIT
......@@ -84,11 +85,16 @@ class UR10(object):
else:
print "Don't know how to flush port %d"%self.port
NotImplementedError
def send(self,command):
if not self.socket_opened:
assert(0) #socket not open
else:
self.socket.send(command)
def update_state_secondary(self,packet,packet_type):
print "Updating %s with packet type %d: %s"%(self.name,packet_type,UR10.subpackages[str(packet_type)][2])
if packet_type == 4:
self.tool_vector = asarray(packet[:6])
def handle_subpackage_secondary(self,remaining):
header = self.socket.recv(5)
......
from UR10 import *
from numpy import *
#Sam Calisch, 2015
#Center for Bits and Atoms, MIT
#roy = UR10("Roy","192.168.1.52",30002)
siegfried = UR10("Siegfried","192.168.1.51",30002)
#roy.open_socket()
siegfried.open_socket()
period = 10
t = arange(0,period,.1)
z_traj = .01*sin(2*pi*t/period)
last = time.time()
for i in range(10): siegfried.read_packet() #establish starting position
start = siegfried.tool_vector
print "start=",start
i = 0
#siegfried.send("set_digital_out(2,False)\n")
try:
while(True):
#roy.read_packet()
siegfried.read_packet()
#new_p = start+array([0,0,z_traj[i],0,0,0])
if i==20:
new_p = start+array([0,0,.1,0,0,0])
move_cmd = 'movej(p[%f, %f, %f, %f, %f, %f],a=1.2,v=.1)\n'%tuple(new_p)
print move_cmd
siegfried.send(move_cmd)
#siegfried.send('set_digital_out(2,True)\n')
print "[%.4f,%.4f,%.4f,%.4f,%.4f,%.4f]"%tuple(siegfried.tool_vector-start)
#i = (i+1)%shape(t)[0]
i = (i+1)#%shape(t)[0]
except(KeyboardInterrupt):
pass
#roy.close_socket()
siegfried.close_socket()
print "Thank you."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment