def __init__(self, host, port): """Creates connection to robot.""" self.next_msg_id = 1 self.futures = {} self.out_lock = Lock() self.connected_event = Event() self.error_connecting = False self.client = CorobotClient(host, port, self) self.io_thread = Thread(target=self._io_loop) self.io_thread.start() self.connected_event.wait() if self.error_connecting: raise CorobotException("Couldn't connect to robot at %s:%d" % (host, port))
def __init__(self): """Creates connection to robot.""" self.next_msg_id = 1 self.futures = {} self.out_lock = Lock() self.connected_event = Event() self.error_connecting = False #print ("In robot constructor. Fetching IP.") robotName, host = getIdleRobotIP() if (host is None): print("Sorry, no IDLE corobot available.") raise CorobotException print("Got IP as : %s" % str(host)) print("Robot assigned : %s" % robotName) port = 15001 self.client = CorobotClient(host, port, self) self.io_thread = Thread(target=self._io_loop) self.io_thread.start() self.connected_event.wait() if self.error_connecting: raise CorobotException("Couldn't connect to robot at %s:%d" % (host, port))