cleanup
This commit is contained in:
parent
18eb417933
commit
16750f79f4
@ -5,4 +5,5 @@ Python library to control an UR robot through its TCP/IP interface
|
|||||||
|
|
||||||
|
|
||||||
from .urx import Robot, RobotException, URScript
|
from .urx import Robot, RobotException, URScript
|
||||||
|
from .tracker import Tracker
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
from multiprocessing import Process, Queue, Event
|
from multiprocessing import Process, Queue, Event
|
||||||
|
|
||||||
from urx.urrtmon import URRTMonitor
|
from urx import urrtmon
|
||||||
|
|
||||||
|
|
||||||
class Tracker(Process):
|
class Tracker(Process):
|
||||||
@ -18,7 +18,7 @@ class Tracker(Process):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._log("Running")
|
self._log("Running")
|
||||||
rtmon = URRTMonitor(self.host)
|
rtmon = urrtmon.URRTMonitor(self.host)
|
||||||
rtmon.start()
|
rtmon.start()
|
||||||
while not self._stop.is_set():
|
while not self._stop.is_set():
|
||||||
data = rtmon.get_all_data(wait=True)
|
data = rtmon.get_all_data(wait=True)
|
||||||
@ -36,7 +36,7 @@ class Tracker(Process):
|
|||||||
def get_result(self):
|
def get_result(self):
|
||||||
self._stop.set()
|
self._stop.set()
|
||||||
while not self._finished.is_set():
|
while not self._finished.is_set():
|
||||||
time.sleep(0.1)
|
time.sleep(0.01)
|
||||||
return self._queue.get()
|
return self._queue.get()
|
||||||
|
|
||||||
def shutdown(self, join=True):
|
def shutdown(self, join=True):
|
||||||
|
@ -19,7 +19,6 @@ import socket
|
|||||||
import struct
|
import struct
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import datetime
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class URRTMonitor(threading.Thread):
|
|||||||
self._qTarget = None
|
self._qTarget = None
|
||||||
self._tcp = None
|
self._tcp = None
|
||||||
self._tcp_force = None
|
self._tcp_force = None
|
||||||
|
self.__recvTime = 0
|
||||||
|
|
||||||
def __recv_bytes(self, nBytes):
|
def __recv_bytes(self, nBytes):
|
||||||
''' Facility method for receiving exactly "nBytes" bytes from
|
''' Facility method for receiving exactly "nBytes" bytes from
|
||||||
@ -178,18 +178,8 @@ class URRTMonitor(threading.Thread):
|
|||||||
self.__recv_rt_data()
|
self.__recv_rt_data()
|
||||||
self._rtSock.close()
|
self._rtSock.close()
|
||||||
|
|
||||||
i = 1
|
|
||||||
def dumptcp():
|
|
||||||
global i
|
|
||||||
tcf = urRTMon.getTcp()
|
|
||||||
pos = tcf[:3]
|
|
||||||
rot = tcf[3:]
|
|
||||||
filename = 'robot%d.txt'%i
|
|
||||||
print('Dumping file: %s (at time %s)' % (filename, str(datetime.datetime.now())))
|
|
||||||
f = file(filename,'w')
|
|
||||||
f.write((3*'%.5f ' + '\n' + 3*'%.5f ') % tuple(tcf))
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
|
|
||||||
def startupInteractive():
|
def startupInteractive():
|
||||||
global urRTMon
|
global urRTMon
|
||||||
|
11
urx/urx.py
11
urx/urx.py
@ -75,8 +75,9 @@ except ImportError:
|
|||||||
MATH3D = False
|
MATH3D = False
|
||||||
print("pymath3d library could not be found on this computer, disabling use of matrices")
|
print("pymath3d library could not be found on this computer, disabling use of matrices")
|
||||||
|
|
||||||
#import urrtmon #temproarely disabled
|
from urx import urrtmon
|
||||||
import urx.urparser as urparser
|
from urx import urparser
|
||||||
|
from urx import tracker
|
||||||
|
|
||||||
|
|
||||||
class RobotException(Exception):
|
class RobotException(Exception):
|
||||||
@ -622,6 +623,12 @@ class Robot(object):
|
|||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.robot.cleanup()
|
self.robot.cleanup()
|
||||||
|
|
||||||
|
def get_tracker(self):
|
||||||
|
"""
|
||||||
|
return an object able to track robot move for logging
|
||||||
|
"""
|
||||||
|
return tracker.Tracker(self.robot.host)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not MATH3D:
|
if not MATH3D:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user