def getRobot(self, email, password, robot_id): chosenRobot=None if(self.allRobots==None): self.getAllRobots(email,password) if(self.allRobots==None): return "No robots found" for i in range(len(self.allRobots)): if(self.allRobots[i].robot_details.robot_id==robot_id): chosen_robot_details = self.allRobots.robots[id] tempRobot = animus.Robot(chosen_robot_details) connected_result = self.myrobot.connect() if not connected_result.success: # print("Could not connect with robot {}".format( # self.myrobot.robot_details.robot_id)) animus.close_client_interface() break else: chosenRobot=tempRobot if (chosenRobot==None): return "Robot conn error" else: return chosenRobot
def gen_frames(self): # generate frame by frame from camera try: while True: try: image_list, err = self.myrobot.get_modality("vision", True) except: continue if err.success: clear_img = self.fixImage(image_list[0].image) ret, buffer = cv2.imencode('.jpg', clear_img) frame = buffer.tobytes() # try: # self.writeVideo # except Exception as e: # print(e) # pass yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') # concat frame one by one and show result except KeyboardInterrupt: cv2.destroyAllWindows() self.videowriterwriter.release() self.log.info("Closing down") self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1) except SystemExit: cv2.destroyAllWindows() self.videowriterwriter.release() self.log.info("Closing down") self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1)
def closeRobot(self): # self.myrobot.disconnect() # animus.close_client_interface() cv2.destroyAllWindows() self.log.info("Closing down") self.vidThread.join() self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1)
def closeRobot(self, user): # self.myrobot.disconnect() # animus.close_client_interface() print(user) cv2.destroyAllWindows() self.log.info("Closing down") self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1)
def getRobot(self): for i in range(10): self.log.info(animus.version()) # print(animus.version()) audio_params = utils.AudioParams(Backends=["notinternal"], SampleRate=16000, Channels=1, SizeInFrames=True, TransmitRate=30) setup_result = animus.setup(audio_params, "PythonAnimusBasics", True) if not setup_result.success: time.sleep(5) continue login_result = animus.login_user("*****@*****.**", "C3):]RR[Rs$Y", False) if login_result.success: self.log.info("Logged in") else: time.sleep(5) continue get_robots_result = animus.get_robots(True, True, False) # print(get_robots_result) if not get_robots_result.localSearchError.success: self.log.error(get_robots_result.localSearchError.description) if not get_robots_result.remoteSearchError.success: self.log.error(get_robots_result.remoteSearchError.description) if len(get_robots_result.robots) == 0: self.log.info("No Robots found") animus.close_client_interface() time.sleep(5) continue chosen_robot_details = get_robots_result.robots[0] self.myrobot = animus.Robot(chosen_robot_details) connected_result = self.myrobot.connect() if not connected_result.success: print("Could not connect with robot {}".format( self.myrobot.robot_details.robot_id)) animus.close_client_interface() time.sleep(5) continue else: break
def getAllRobots(self,email,password): for i in range(10): self.log.info(animus.version()) print(animus.version()) audio_params = utils.AudioParams( Backends=["notinternal"], SampleRate=16000, Channels=1, SizeInFrames=True, TransmitRate=30 ) setup_result = animus.setup( audio_params, "PythonAnimusBasics", True) if not setup_result.success: time.sleep(5) continue login_result = animus.login_user(email, password, False) if login_result.success: self.log.info("Logged in") else: time.sleep(5) continue get_robots_result = animus.get_robots(True, True, False) # print(get_robots_result) if not get_robots_result.localSearchError.success: self.log.error(get_robots_result.localSearchError.description) if not get_robots_result.remoteSearchError.success: self.log.error(get_robots_result.remoteSearchError.description) if len(get_robots_result.robots) == 0: self.log.info("No Robots found") animus.close_client_interface() time.sleep(5) continue if not len(get_robots_result.robots) ==0: self.allRobots=get_robots_result robotsRetrieved=animus_wrapper.proto_converters.proto_obj_to_dict(get_robots_result) robotsRetrieved=json.dumps(robotsRetrieved) return robotsRetrieved else: return None
def gen_frames(self): # generate frame by frame from camera try: frame = simplejpeg.encode_jpeg(self.capFrame, colorspace='BGR', quality=90) yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n' ) # concat frame one by one and show result # yield(self.videoImgSrc) except KeyboardInterrupt: cv2.destroyAllWindows() self.log.info("Closing down") self.vidThread.join() self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1) except SystemExit: cv2.destroyAllWindows() self.log.info("Closing down") self.vidThread.join() self.myrobot.disconnect() animus.close_client_interface() sys.exit(-1)
def closeRobot(self): self.myrobot.disconnect() animus.close_client_interface()
# print(get_robots_result.robots[0].name) # print(get_robots_result.robots[0].robot_id) # print(get_robots_result.robots[0].robot_id) # print(get_robots_result.robots[0].robot_state.location.ip) # print(get_robots_result.robots[0].robot_state.location.city) # print(get_robots_result.robots[0].robot_state.location.region) if not get_robots_result.localSearchError.success: log.error(get_robots_result.localSearchError.description) if not get_robots_result.remoteSearchError.success: log.error(get_robots_result.remoteSearchError.description) if len(get_robots_result.robots) == 0: log.info("No Robots found") animus.close_client_interface() sys.exit(-1) chosen_robot_details = get_robots_result.robots[0] myrobot = animus.Robot(chosen_robot_details) connected_result = myrobot.connect() if not connected_result.success: print("Could not connect with robot {}".format( myrobot.robot_details.robot_id)) animus.close_client_interface() sys.exit(-1) # # -------------Auditory - Voice Loop------------------------ # # # # # ----------------Motor Visual Loop------------------------------------