def stop_robot_feedback(self): """Called eg. in mult-logic just after finishing robot logic.""" self.logger.info("Stop robot feed...") self.conn.send_message(message="stop", type=types.ROBOT_FEEDBACK_CONTROL, flush=True) time.sleep(0.5) #make sure(?) robot feedback will not overwrite below ugm_helper.send_logo(self.conn, 'obci.gui.ugm.resources.bci.png')
def stop_robot_feedback(self): """Called eg. in mult-logic just after finishing robot logic.""" self.logger.info("Stop robot feed...") self.conn.send_message( message = "stop", type=types.ROBOT_FEEDBACK_CONTROL, flush=True) time.sleep(0.5)#make sure(?) robot feedback will not overwrite below ugm_helper.send_logo(self.conn, 'obci.gui.ugm.resources.bci.png')
def handle_message(self, mxmsg): if mxmsg.type == types.ROBOT_FEEDBACK_CONTROL: if mxmsg.message == 'start': self.logger.info("Got start message. Start robot feedback!!!") self.is_on = True elif mxmsg.message == 'stop': self.logger.info("Got stop message. Stop robot feedback!!!") self.is_on = False ugm_helper.send_logo(self.conn, 'obci.gui.ugm.resources.bci.png')#todo - CEBIT fix... should be done somewhere in logic, but to ensure that robot feed will not overwrite log do it here... else: self.logger.warning("Unrecognised control message:" + str(mxmsg.message)) if DEBUG: self.debug.next_sample() diff = (time.time() - self._last_time) if not self.is_on: self.no_response() return elif diff > 1.0: self._last_time = time.time() self.logger.error("Last time bigger than 1.0... give it a chance next time. ...") self.no_response() return elif diff > 0.2: self.logger.debug("Last time bigger than 0.2... don`t try read image for a while ...") self.no_response() return elif diff > 0.05: self._last_time = time.time() t = time.time() try: self.logger.debug("Start getting image...") image = self._robot.get_image(timeout=0.5) self.logger.debug("Succesful get_image time:"+str(time.time()-t)) except: self.logger.error("UNSuccesful get_image time:"+str(time.time()-t)) self.logger.error("Could not connect to ROBOT. Feedback is OFF!") else: try: with open(self.imgpath, 'w') as fil: fil.write(image) fil.close() ugm_helper.send_config_for(self.conn, self.robot_image_id, 'image_path', self.imgpath) self.logger.debug("Robot image sent " + self.imgpath + ' id: ' + str(self.robot_image_id)) self.index = int(not self.index) self.imgpath = self.paths[self.index] except Exception, e: self.logger.error("An error occured while writing image to file!") print(repr(e)) self.no_response() return
def handle_message(self, mxmsg): if mxmsg.type == types.ROBOT_FEEDBACK_CONTROL: if mxmsg.message == 'start': self.logger.info("Got start message. Start robot feedback!!!") self.is_on = True elif mxmsg.message == 'stop': self.logger.info("Got stop message. Stop robot feedback!!!") self.is_on = False ugm_helper.send_logo( self.conn, 'obci.gui.ugm.resources.bci.png' ) #todo - CEBIT fix... should be done somewhere in logic, but to ensure that robot feed will not overwrite log do it here... else: self.logger.warning("Unrecognised control message:" + str(mxmsg.message)) if DEBUG: self.debug.next_sample() diff = (time.time() - self._last_time) if not self.is_on: self.no_response() return elif diff > 1.0: self._last_time = time.time() self.logger.error( "Last time bigger than 1.0... give it a chance next time. ...") self.no_response() return elif diff > 0.2: self.logger.debug( "Last time bigger than 0.2... don`t try read image for a while ..." ) self.no_response() return elif diff > 0.05: self._last_time = time.time() t = time.time() try: self.logger.debug("Start getting image...") image = self._robot.get_image(timeout=0.5) self.logger.debug("Succesful get_image time:" + str(time.time() - t)) except: self.logger.error("UNSuccesful get_image time:" + str(time.time() - t)) self.logger.error( "Could not connect to ROBOT. Feedback is OFF!") else: try: with open(self.imgpath, 'w') as fil: fil.write(image) fil.close() ugm_helper.send_config_for(self.conn, self.robot_image_id, 'image_path', self.imgpath) self.logger.debug("Robot image sent " + self.imgpath + ' id: ' + str(self.robot_image_id)) self.index = int(not self.index) self.imgpath = self.paths[self.index] except Exception, e: self.logger.error( "An error occured while writing image to file!") print(repr(e)) self.no_response() return