def setHome(self): self.cont_rob = ct.Control() dc_port = 'COM18' # dc_port = input("COM port for dc motor: ") # print(type(dc_port)) self.serialPort = self.cont_rob.OpenSerialPort(dc_port) if self.serialPort == None: sys.exit(1) self.cont_rob.setHome(self.serialPort)
def Robot(self, queue, serialPort, stopped): print("Hair transplant process is starting!") serialPort.timeout = 1.0 while not stopped.is_set(): try: robot = ct.Control() while True: distance = queue.get() # distance = ([2.5413621708824894, 3.496339433599953]) robot.Motors_Control(serialPort, distance) except: exctype, errorMsg = sys.exc_info()[:2] print("Error reading port - %s" % errorMsg) stopped.set() break # serialPort.close() print("...Hair transplant process is finished...")
def Robot(queue, serialPort, stopped): print("Hair transplant process is starting!") serialPort.timeout = 1.0 while not stopped.is_set(): try: robot = ct.Control() while True: for i in range(1, 4): # distance = queue.get() distance = ([1 + i, 1 + i]) robot.Motors_Control(serialPort, distance) except: exctype, errorMsg = sys.exc_info()[:2] print("Error reading port - %s" % errorMsg) stopped.set() break # serialPort.close() print("...Hair transplant process is finished...")
robot = ct.Control() while True: for i in range(1, 4): # distance = queue.get() distance = ([1 + i, 1 + i]) robot.Motors_Control(serialPort, distance) except: exctype, errorMsg = sys.exc_info()[:2] print("Error reading port - %s" % errorMsg) stopped.set() break # serialPort.close() print("...Hair transplant process is finished...") robot = ct.Control() serialPort = robot.OpenSerialPort('COM15') if serialPort == None: sys.exit(1) robot.setHome(serialPort) queue = multiprocessing.Queue() stopped = threading.Event() p1_ = threading.Thread(target=gui, args=(queue, )) # p2_ = threading.Thread(target=dxl_motor, args=(queue, )) p2_ = threading.Thread(target=Robot, args=( queue, serialPort, stopped, ))