def main(): parser = OptionParser() parser.add_option("--pip", help="NAO's IP address.", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi listens on.", dest="pport", type="int") parser.set_defaults(pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # Broker used to construct NAOqi modules and subscribe to other modules. # Broker is active until the program terminates. myBroker = ALBroker( "myBroker", "0.0.0.0", # Listen to anyone. 0, # Use any free port. pip, # Parent broker IP address. pport) # Parent broker port. global NAOInteraction NAOInteraction = SpeechGestures("NAOInteraction") try: while True: time.sleep(1) except KeyboardInterrupt: print print "INTERRUPTED: Shutting down speech module now." myBroker.shutdown() sys.exit(0)
def main(ip, port): """ Main entry point """ # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global walkTo walkTo = walkTo("walkTo") try: while True: time.sleep(1) except SystemExit as e: print("System error : {0}".format(e)) except KeyboardInterrupt: print("") print("Interrupted by user, shutting down") finally: myBroker.shutdown() sys.exit(0)
def main(): # ----------> 命令行解析 <---------- global ROBOT_IP parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip=ROBOT_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # 如果运行前指定ip参数,则更新ROBOT_IP全局变量; # 其他模块会用到ROBOT_IP变量; ROBOT_IP = pip # ----------> 创建python broker <---------- myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # ----------> 创建Robot ALProxy Module<---------- global tts, motion, autonomous tts = ALProxy("ALTextToSpeech") # 默认为英语语言包 tts.setLanguage("English") motion = ALProxy("ALMotion") # turn ALAutonomousLife off autonomous = ALProxy("ALAutonomousLife") autonomous.setState("disabled") # ----------> 自己实现的类 <---------- global avoid avoid = avoidance(ROBOT_IP, ROBOT_PORT) # 超声波避障类 global video video = VideoImage(ROBOT_IP, ROBOT_PORT) # 拍照类 try: video.addXtionCamera() video.subscribeCamera() video.setCamera(0) # 开启线程避障 avoid.start() video.takeRGBDimage(1000) except KeyboardInterrupt: print print "Interrupted by user, shutting down" avoid.stop() # 关闭避障 video.close() # 关闭视频传输模块 myBroker.shutdown() # 关闭代理Broker sys.exit(0)
def main(ip, port): """ Main entry point """ # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global tts, memory tts = ALProxy("ALTextToSpeech", ip, port) memory = ALProxy("ALMemory", ip, port) global FrontTouch, MiddleTouch, RearTouch global LeftFootTouch, RightFootTouch FrontTouch = FrontTouch("FrontTouch") MiddleTouch = MiddleTouch("MiddleTouch") RearTouch = RearTouch("RearTouch") LeftFootTouch = LeftFootTouch("LeftFootTouch") RightFootTouch = RightFootTouch("RightFootTouch") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): """主函数""" parser = argparse.ArgumentParser() parser.add_argument("--ip", type=str, default="192.168.1.101", help="192.168.1.102") parser.add_argument("--port", type=int, default=9559, help="9987") parser.add_argument("--facesize", type=float, default=0.1, help="0.2") args = parser.parse_args() # 设置代理 myBroker = ALBroker("myBroker", "0.0.0.0", 0, args.ip, args.port) global mymotion mymotion = SoundAndMoveHead('mymotion') mymotion.sound() # 在类外部也能使用订阅事件,使事件被触发时,也能做出反应 # mymotion.memory.subscribeToEvent('ALSoundLocalization/SoundLocated','mymotion','test') # global mymove # mymove=MoveAfterSound('mymove') try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(robot_IP, robot_PORT=9559): # We need this broker to be able to construct NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it robot_IP, # parent broker IP robot_PORT) # parent broker port # ----------> touch password system <---------- # 使用具体的类实例名称来初始化类; global touchSystem touchSystem = touchPasswd("touchSystem") touchSystem.setPassword('123') # touchSystem.skipVerify() # 直接跳过验证; try: # 没有通过验证,则一直循环等待; while touchSystem.isVerify() == False: time.sleep(1) print 'verify succeed, exit!' except KeyboardInterrupt: # 中断程序 print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ try: signal.signal(signal.SIGINT, signal_handler) print "[Execution server] - Press Ctrl + C to exit system correctly" myBroker = ALBroker("myBroker", "0.0.0.0", 0, Constants.NAO_IP,Constants.PORT) global Execution_server Execution_server = MoveNaoModule("Execution_server") rospy.spin() except (KeyboardInterrupt, SystemExit): print "[Execution server] - SystemExit Exception caught" #unsubscribe() myBroker.shutdown() sys.exit(0) except Exception, ex: print "[Execution server] - Exception caught %s" % str(ex) #unsubscribe() myBroker.shutdown() sys.exit(0)
def main(): parser = OptionParser() parser.add_option('--ip', help='IP address of pepper.', dest='ip') parser.add_option('--port', help='port.', dest='port', type='int') parser.set_defaults(port=9559) opts, args = parser.parse_args() ip = opts.ip port = opts.port myBroker = ALBroker('myBroker', '0.0.0.0', 0, ip, port) global memory memory = ALProxy('ALMemory') global engage engage = EngagementZoneModule('engage', memory) global QRCodeReader QRCodeReader = QRCodeReaderModule('QRCodeReader', memory) print("picture start") takeAndShowPics = TakeAndShowPics(ip, port) takeAndShowPics.start() print("picture comp") try: while True: time.sleep(1) except KeyboardInterrupt: print() print('Interrupted.') myBroker.shutdown() sys.exit()
def main(robot_IP, robot_PORT=9559): # We need this broker to be able to construct NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it robot_IP, # parent broker IP robot_PORT) # parent broker port # ----------> touch password system <---------- # 使用具体的类实例名称来初始化类; global touchSystem touchSystem = touchPasswd("touchSystem") touchSystem.setPassword('123') # touchSystem.skipVerify() # 直接跳过验证; try: # 没有通过验证,则一直循环等待; while touchSystem.isVerify() == False: time.sleep(1) print 'verify succeed, exit!' except KeyboardInterrupt: # 中断程序 print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): parser = OptionParser() parser.add_option('--ip', help='IP address of pepper.', dest='ip') parser.add_option('--port', help='port.', dest='port', type='int') parser.set_defaults(port=9559) opts, args = parser.parse_args() ip = opts.ip port = opts.port myBroker = ALBroker('myBroker', '0.0.0.0', 0, ip, port) global QRCodeReader QRCodeReader = QRCodeReaderModule('QRCodeReader') # takeAndShowPics = TakeAndShowPics() # p = multiprocessing.Process(target=takeAndShowPics.start) # p.start() takeAndShowPics = TakeAndShowPics(ip, port) takeAndShowPics.start() try: while True: time.sleep(1) except KeyboardInterrupt: print() print('Interrupted.') myBroker.shutdown() sys.exit()
def main(ip, port): """ Main entry point """ # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global memory, sonar memory = ALProxy("ALMemory", ip, port) sonar = ALProxy("ALSonar", ip, port) sonar.subscribe("SonarTestModule") global LeftDetected, RightDetected, LeftNothing, RightNothing LeftDetected = LeftDetected("LeftDetected") RightDetected = RightDetected("RightDetected") LeftNothing = LeftNothing("LeftNothing") RightNothing = RightNothing("RightNothing") try: while True: time.sleep(1) # print "Left Sonar:", memory.getData("Device/SubDeviceList/US/Left/Sensor/Value") print "" except KeyboardInterrupt: print print "Interrupted by user, shutting down" sonar.unsubscribe("SonarTestModule") myBroker.shutdown() sys.exit(0)
def connectNaoQi(self): try: parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip="127.0.0.1", pport=9559) parser.add_option("--robot_description", help="Parent broker port. The IP address or your robot", dest="name") (opts, args_) = parser.parse_args() self.pip = get_param('pip', None) self.pport = get_param('pport', None) self.description = opts.name myBroker = ALBroker("myBroker","0.0.0.0",0,self.pip, self.pport) except KeyboardInterrupt: print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(ip, port): """ Main entry point """ # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global tts, memory tts = ALProxy("ALTextToSpeech", ip, port) memory = ALProxy("ALMemory", ip, port) global FrontTouch, MiddleTouch, RearTouch global LeftFootTouch, RightFootTouch FrontTouch = FrontTouch("FrontTouch") MiddleTouch = MiddleTouch("MiddleTouch") RearTouch = RearTouch("RearTouch") LeftFootTouch = LeftFootTouch("LeftFootTouch") RightFootTouch = RightFootTouch("RightFootTouch") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) global MarkovTickle MarkovTickle = MarkovTickleModule("MarkovTickle") print "Running, hit CTRL+C to stop script" MarkovTickle.mainTask() try: while True: time.sleep(1) except KeyboardInterrupt: print "Interrupted by user, shutting down" # stop any post tasks # eg void ALModule::stop(const int& id) try: myBroker.shutdown() except Exception, e: print "Error shutting down broker: ", e try: sys.exit(0) except Exception, e: print "Error exiting system: ", e
def play(args): global broker, nao_motion, nao_video nao_strategies = {'basic': Basic, 'human': Human} other_strategies = {'vision': NAOVision, 'human': Human} nao_strat = nao_strategies.get(args['--nao-strategy'], None) other_strat = other_strategies.get(args['--other-strategy'], None) if nao_strat is None: exit("{0} is not a valid strategy. The valid strategies for NAO are basic and " "human".format(args['--nao-strategy'])) if other_strat is None: exit("{0} is not a valid strategy. The valid strategies for the other player are " "vision and human".format(args['--other-strategy'])) basic.ALPHA_BETA_MAX_DEPTH = int(args['--max-depth']) data.IP = args['--ip'] data.PORT = int(args['--port']) broker = ALBroker("myBroker", "0.0.0.0", 0, data.IP, data.PORT) nao_motion = MotionController() nao_video = VideoController() nao_tts = ALProxy("ALTextToSpeech", data.IP, data.PORT) try: loop = LogicalLoop(nao_motion=nao_motion, nao_video=nao_video, nao_tts=nao_tts, ppA=float(args['--ppA']), cA=float(args['--cA']), rA=float(args['--rA']), min_detections=int(args['--min-detections']), sloped=args['--sloped'], dist=float(args['--dist']), nao_strategy=nao_strat, other_strategy=other_strat, wait_disc_func=wait_for_disc, ) loop.loop() except KeyboardInterrupt: print "Keyboard interrupt" finally: broker.shutdown() return 0
def main(): #IP = "localhost" #PORT =51394 IP = "pepper.local" PORT = 9559 myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it IP, # parent broker IP PORT) global SoundLocator SoundLocator = SoundLocatorModule("SoundLocator", IP, PORT) try: while True: # print("-") time.sleep(1) pass except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
class ToMarkovChoiceGoodInput(unittest.TestCase): """ Markov choice should give known result with known input. """ def setUp(self): self.myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) self.MarkovTickle = MarkovTickleModule("MarkovTickle") def tearDown(self): self.MarkovTickle = None self.myBroker.shutdown() def testSmallMatrix(self): testValue = self.MarkovTickle.markovChoice([1]) result = 0 self.assertEquals(testValue, result) def testLargeMatrix(self): testValue = self.MarkovTickle.markovChoice([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]) result = 0 self.assertGreaterEqual(testValue, result) def testHugeMatrix(self): """ Pass v large matrix e.g. 1000 elements.""" arraySize = 1000 array = np.random.random(arraySize) arraySum = np.sum(array) arrayNormalised = array / arraySum testValue = self.MarkovTickle.markovChoice(arrayNormalised) result = 0 self.assertGreaterEqual(testValue, result)
def main(): """ Punto de entrada al Módulo. """ parser = OptionParser() parser.add_option("--pip", help = "Parent broker IP, robot IP address", dest = "pip") parser.add_option("--pport", help = "Parent broker IP, NaoQi port", dest = "pport", type = "int") parser.set_defaults( pip = NAO_IP, pport = 9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # Nuevo broker para la construcción de nuevos módulos. # Debe ejecutarse en tanto el programa exista. myBroker = ALBroker("myBroker", "0.0.0.0", 0, pip, pport) global ballSpy ballSpy = ballSpyModule("ballSpy") try: while True: time.sleep(1) except KeyboardInterrupt: print print "KeyboardInterrupt, shutting down..." myBroker.shutdown() sys.exit(0)
def main(): ### # Summary: main execution method # Parameters: -- # Return: -- ### parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport myBroker = ALBroker("myBroker", "0.0.0.0", 0, pip, pport) global bootloadr bootloadr = Bootloader("bootloadr") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it '192.168.3.68', # parent broker IP 9559) # parent broker port # Warning: Adviser must be a global variable # The name given to the constructor must be the name of the # variable global Adviser Adviser = AdviserModule("Adviser") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" Adviser.shutoff() # stop the module myBroker.shutdown() sys.exit(0)
def main(): myBroker = ALBroker("myBroker", "0.0.0.0", 0, PEPPER_IP, 9559) global PepperModule PepperModule = PepperModuleClass("PepperModule") while True: #録音開始 PepperModule.startRecord() # 30秒録音 time.sleep(30) #録音終了 check = PepperModule.stopRecord() index = check.find("satellite") #実行結果にファイル名が含まれているか検索 if index != -1: #ファイル名が含まれている = 曲が見つかったら commands.getoutput( "/usr/bin/python satellite.py") #アイドルオタク化プログラムを実行 myBroker.shutdown() sys.exit(0) else: print "not found"
def __init__(self, broker_name, broker_ip=None, broker_port=0, nao_id=None, nao_port=None, **kwargs): if any(x in kwargs for x in ['brokerIp', 'brokerPort', 'naoIp', 'naoPort']): warnings.warn('''brokerIp, brokerPort, naoIp and naoPort arguments are respectively replaced by broker_ip, broker_port, nao_id and nao_port''', DeprecationWarning) broker_ip = kwargs.pop('brokerIp', broker_ip) broker_port = kwargs.pop('brokerPort', broker_port) nao_id = kwargs.pop('naoIp', nao_id) nao_port = kwargs.pop('naoPort', nao_port) if kwargs: raise TypeError('Unexpected arguments for Broker(): %s' % ', '.join(kwargs.keys())) nao_ip, nao_port = _resolve_ip_port(nao_id, nao_port) # Information concerning our new python broker if broker_ip is None: broker_ip = _get_local_ip(nao_ip) ALBroker.__init__(self, broker_name, broker_ip, broker_port, nao_ip, nao_port) self.broker_name = broker_name self.broker_ip = broker_ip self.broker_port = broker_port self.nao_id = nao_id self.nao_port = nao_port
def main(): # A dechiffrer... Mais permet d'employer des parametres # reseau par defaut au sein des declarations d'objet dans # le reste du programme... parser = OptionParser() parser.set_defaults(pip=IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport myBroker = ALBroker("myBroker", "0.0.0.0", 0, pip, pport) # ######################################################## # Variable d'instance. global TouchMeToSpeak # Instanciation de l'objet TouchMeToSpeak. TouchMeToSpeak = TouchMeToSpeakModule("TouchMeToSpeak") # Tourne indefiniement... try: while True: time.sleep(1) # ...Jusqu'a la production de l'exception interruption clavier. except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(ip, port): """ Main entry point """ # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists global IP1, PORT1 IP1 = ip PORT1 = port myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global ReactToTouch ReactToTouch = ReactToTouch("ReactToTouch") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def __init__(self, ip, port, simulation_mode=True): self.ip = ip self.port = port self.camProxy = ALProxy("ALVideoDevice", self.ip, self.port) self.postureProxy = ALProxy("ALRobotPosture", self.ip, self.port) self.motionProxy = ALProxy("ALMotion", self.ip, self.port) self.memoryProxy = ALProxy("ALMemory", self.ip, self.port) self.blobProxy = ALProxy("ALColorBlobDetection", self.ip, self.port) self.trackerProxy = ALProxy("ALTracker", self.ip, self.port) self.ttsProxy = ALProxy("ALTextToSpeech", self.ip, self.port) self.broker = ALBroker("pythonMotionBroker", "0.0.0.0", 0, self.ip, self.port) if simulation_mode == False: self.autolifeProxy = ALProxy("ALAutonomousLife", self.ip, self.port) self.autolifeProxy.setState("disabled") self.topCamera = self.camProxy.subscribeCamera( "topCamera_pycli", 0, vision_definitions.kVGA, vision_definitions.kBGRColorSpace, framerate) self.bottomCamera = self.camProxy.subscribeCamera( "bottomCamera_pycli", 1, vision_definitions.kQQVGA, vision_definitions.kBGRColorSpace, framerate) self.motionProxy.wakeUp() self.enableExternalCollisionProtection() self.postureProxy.goToPosture("StandInit", 1.0)
def initialize_broker(self): self.myBroker = ALBroker("myBroker", "0.0.0.0", 0, "", 9559) self.tts = ALProxy("ALTextToSpeech") self.power = ALProxy("ALBattery") self.system = ALProxy("ALSystem") global REACT_TO_TOUCH REACT_TO_TOUCH = ReactToTouch("REACT_TO_TOUCH")
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip="10.0.1.3", pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port asr = ALProxy("ALSpeechRecognition", "10.0.1.3", 9559) asr.setLanguage("English") # Example: Adds "yes", "no" and "please" to the vocabulary (without wordspotting) vocabulary = ["yes", "no", "please"] asr.setVocabulary(vocabulary, False) # Start the speech recognition engine with user Test_ASR asr.subscribe("Test_ASR") # Warning: HumanGreeter must be a global variable # The name given to the constructor must be the name of the # variable global SpeechDetector SpeechDetector = SpeechDetectorModule("SpeechDetector") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" asr.unsubscribe("Test_ASR") myBroker.shutdown() sys.exit(0)
def initialize(robot_ip, robot_port, topf_path, csvf): # creates the speech recognition proxy and a csv file print "Have reached adialog main method" createSpeechRecogProxy(robot_ip, robot_port) createFile(csvf) # creates dialog and posture proxies dialog_p = ALProxy('ALDialog', robot_ip, robot_port) postureProxy = ALProxy("ALRobotPosture", robot_ip, robot_port) dialog_p.setLanguage("English") tts = ALProxy('ALTextToSpeech', robot_ip, robot_port) tts.say("starting") postureProxy.goToPosture("StandInit", 0.5) # brings robot to standing pos. # Load topic - absolute path is required # TOPIC MUST BE ON ROBOT topic = dialog_p.loadTopic(topf_path) # Start dialog dialog_p.subscribe('myModule') # Activate dialog dialog_p.activateTopic(topic) # create broker myBroker = ALBroker("myBroker", "0.0.0.0", 0, robot_ip, robot_port) '''# creates a module called "Move" global Move Move = TestModule("Move")''' # pressing key will unsubscribe from the topic raw_input(u"Press 'Enter to exit.") #speech recognition unsubscribing from test_asr wtf?: asr.unsubscribe("Test_ASR") # until interrupted, keep broker running try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() # Deactivate topic dialog_p.deactivateTopic(topic) # Unload topic dialog_p.unloadTopic(topic) # Stop dialog dialog_p.unsubscribe('myModule') # close file f.close() # exit sys.exit(0)
def main(): """ Main entry point """ global AudioRecognition global RedBall parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Create proxy to ALTextToSpeech for later use # tts = ALProxy("ALTextToSpeech") # Warning: AudioRecognition must be a global variable # The name given to the constructor must be the name of the # variable AudioRecognition = AudioRecognitionModule("AudioRecognition") AudioRecognition.connect(AudioRecognition) TactileHead = TactileHeadModule("TactileHead",AudioRecognition) try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() AudioRecognition.disconnect(AudioRecognition) AudioRecognition = None sys.exit(0)
def main(robot_ip, robot_port, topf_path): # creates the speech recognition proxy and a csv file createSpeechRecogProxy(robot_ip, robot_port) createFile(csvf) # creates dialog and posture proxies dialog_p = ALProxy('ALDialog', robot_ip, robot_port) postureProxy = ALProxy("ALRobotPosture", robot_ip, robot_port) dialog_p.setLanguage("English") postureProxy.goToPosture("StandInit", 0.5) # brings robot to standing pos. # Load topic - absolute path is required # TOPIC MUST BE ON ROBOT topic = dialog_p.loadTopic(topf_path) # Start dialog dialog_p.subscribe('myModule') # Activate dialog dialog_p.activateTopic(topic) # create broker myBroker = ALBroker("myBroker", "0.0.0.0", 0, robot_ip, robot_port) # creates a module called "Move" global Move Move = TestModule("Move") # pressing key will unsubscribe from the topic raw_input(u"Press 'Enter to exit.") asr.unsubscribe("Test_ASR") # until interrupted, keep broker running try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() # Deactivate topic dialog_p.deactivateTopic(topic) # Unload topic dialog_p.unloadTopic(topic) # Stop dialog dialog_p.unsubscribe('myModule') # close file f.close() # exit sys.exit(0)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address of your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists global myBroker myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: Objects must be a global variable # The name given to the constructor must be the name of the # variable global HandTouch HandTouch = HandTouchModule("HandTouch") print "Running, hit CTRL+C to stop script" while True: time.sleep(1) try: while True: time.sleep(1) except KeyboardInterrupt: print "Interrupted by user, shutting down" # stop any post tasks # eg void ALModule::stop(const int& id) try: myBroker.shutdown() except Exception, e: print "Error shutting down broker: ", e try: sys.exit(0) except Exception, e: print "Error exiting system: ", e
def main(): """ Main entry point (cette partie du code (ALBroker, OptionParser, a ete reprise d'ici : https://community.aldebaran-robotics.com/doc/1-14/dev/python/reacting_to_events.html ) """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: HumanGreeter must be a global variable # The name given to the constructor must be the name of the # variable global HumanGreeter HumanGreeter = HumanGreeterModule("HumanGreeter") motion = ALProxy("ALMotion", pip, pport) posture = ALProxy("ALRobotPosture", pip, pport) tts = ALProxy("ALTextToSpeech", pip, pport) motion.wakeUp() posture.goToPosture("StandInit", 0.5) try: while True: time.sleep(1) tts.say("Rien") except KeyboardInterrupt: #Quand on fait un ctrl+c print print "Interrupted by user, shutting down" myBroker.shutdown() posture.goToPosture( "LyingBack", 0.5) #on se couche sur le dos avant de couper les moteurs motion.rest() sys.exit(0)
def mainProcess(robotIP, robotPort=9559, hostIP, hostPort=8000): #HOST_IP = "192.168.1.13" #HOST_IP = "192.168.1.100" HOST_IP = hostIP #HOST_PORT = 8000 HOST_PORT = hostPort #ROBOT_IP = "192.168.1.27" #ROBOT_IP = "192.168.1.103" ROBOT_IP = robotIP #ROBOT_PORT = 9559 ROBOT_PORT = robotPort global tts tts = ALProxy("ALTextToSpeech", ROBOT_IP, ROBOT_PORT) global player player = ALProxy("ALAudioPlayer", ROBOT_IP, ROBOT_PORT) global videoStream videoStream = OpenCVModule(ROBOT_IP, ROBOT_PORT, CameraID=0, X=240, Y=320) global motionProxy motionProxy = ALProxy("ALMotion", ROBOT_IP, ROBOT_PORT) motionProxy.wakeUp() global memory memory = ALProxy("ALMemory", ROBOT_IP, ROBOT_PORT) global audio audio = ALProxy("ALAudioDevice", ROBOT_IP, ROBOT_PORT) myBroker = ALBroker("myBroker", "0.0.0.0", 0, ROBOT_IP, ROBOT_PORT) global reactToTouch reactToTouch = reactToTouchModule("reactToTouch") global SoundReceiver SoundReceiver = SoundReceiverModule("SoundReceiver") SoundReceiver.start() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind((HOST_IP, HOST_PORT)) sock.listen(10) print "listening" index = 0 try: while True: connection, address = sock.accept() index += 1 thread.start_new_thread(child_connection, (index, sock, connection)) except KeyboardInterrupt: sock.close() videoStream.unregisterImageClient() myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport myBroker = ALBroker("myBroker", "0.0.0.0", 0, pip, pport) global emotional_demo global memory emotional_demo = emotional_demo_module("emotional_demo") # # set some ALMemory values # emotional_dictionary = {"happiness" : (1.00, 0.75), # "sadness" : (-0.75, -0.75), # "anger" : (-0.75, 0.75), # "fear" : (-1.00, 0.00), # "surprise" : (0.00, 0.50), # "disgust" : (-0.4, 0.25), # "thinking" : (0.25, 0.00) # } try: valence_old = 0 arousal_old = 0 while True: current_emotion = memory.getData("Emotion/Current") valence = current_emotion[0][0] arousal = current_emotion[0][1] if abs(valence - valence_old) > 1e-10 or abs(arousal - arousal_old) > 1e-10: memory.raiseEvent("VAChanged", 1) print "Current emotion in memory: ", current_emotion time.sleep(0.1) valence_old = valence arousal_old = arousal except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
class ToMarkovChoiceBadInput(unittest.TestCase): """ Markov choice should give error if bad input. """ def setUp(self): self.myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) self.MarkovTickle = MarkovTickleModule("MarkovTickle") def tearDown(self): self.MarkovTickle = None self.myBroker.shutdown() def testSmallMatrix(self): testValue = [2] self.assertRaises(ValueError, self.MarkovTickle.markovChoice, testValue) def testLargeMatrix(self): """ Test larger matrix, not a p matrix. """ testValue = [0.9, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] self.assertRaises(ValueError, self.MarkovTickle.markovChoice, testValue) def testBadMatrixFormat1(self): """ Matrix not properly formed e.g. comma not decimal point. """ testValue = [0,1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] self.assertRaises(ValueError, self.MarkovTickle.markovChoice, testValue) def testBadMatrixFormat2(self): """ Matrix not properly formed e.g. decimal point not comma. """ # testValue = [0.1. 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] # self.assertRaises(ValueError, self.MarkovTickle.markovChoice, testValue) # not a valid test as would need to pass a string to create a number like '0.1.' pass def testMultiRowMatrix(self): """ More than a single row passed as argument. """ testValue = [[0.5, 0.5], [0.5, 0.5]] self.assertRaises(ValueError, self.MarkovTickle.markovChoice, testValue) def testWhatHappensIfPEquals1(self): """ What happens if p = 1? """ testValue = self.MarkovTickle.markovChoice([0, 0, 1]) result = 2 self.assertEquals(testValue, result) def testIsRandomRandom(self): """ Is choice function returning a randomly distributed result across many runs? """ numRuns = 100000 transitionMatrix = np.array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]) # Run choice function many times. list = [self.MarkovTickle.markovChoice(transitionMatrix) for i in range(numRuns)] listHistogram, listBins = np.histogram(list) listPercentage = [(x / float(numRuns))*100 for x in listHistogram] testValue = np.sum(listPercentage) result = 100.0 self.assertAlmostEqual(testValue, result)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip="10.0.1.3", pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port asr = ALProxy("ALSpeechRecognition", "10.0.1.3", 9559) asr.setLanguage("English") # Example: Adds "yes", "no" and "please" to the vocabulary (without wordspotting) vocabulary = ["yes", "no", "please"] asr.setVocabulary(vocabulary, False) # Start the speech recognition engine with user Test_ASR asr.subscribe("Test_ASR") # Warning: HumanGreeter must be a global variable # The name given to the constructor must be the name of the # variable global SpeechDetector SpeechDetector = SpeechDetectorModule("SpeechDetector") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" asr.unsubscribe("Test_ASR") myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option( "--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults(pip=NAO_IP, pport=NAO_PORT) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: HumanGreeter must be a global variable # The name given to the constructor must be the name of the # variable topf_path = '/home/nao/naoqi/topic_pack/approach_key_words/app_mots_clefs_v4.top' global HumanGreeter HumanGreeter = HumanGreeterModule("HumanGreeter", topf_path) HumanGreeter.set_dialogue() log_file_name = "TEST_" + "NAME_OF_THE_TEST" + time.strftime( "%Y%m%d-%H%M%S") + ".txt" log_file = open(log_file_name, 'w') # Print the history of the dialog with the robot and save it into a log file print "_________HISTORIQUE DE LA DISCUSSION___________" i = 1 for question, answer in zip(HumanGreeter.questions, HumanGreeter.answers): print "Last thing understood by pepper was : " + question log_file.write("Input number %d : %s \n" % (i, question)) print "Output of the robot : " + answer log_file.write("Output number %d : %s : \n" % (i, answer)) i += 1 print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(robotIp): myBroker = ALBroker("GolfBroker", "0.0.0.0", 0, robotIp, 9559) global GolfGreeter GolfGreeter = GolfGreeterModule("GolfGreeter") try: while True: time.sleep(1) except KeyboardInterrupt: print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(ip, port): global SpeechRecognition # Setup the data broker. myBroker = ALBroker("myBroker", "0.0.0.0", 0, ip, port) SpeechRecognition = SpeechRecognition("SpeechRecognition") try: while True: sleep(0.1) except KeyboardInterrupt: SpeechRecognition.onEnd() myBroker.shutdown()
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=9559) # Start Google cloud stt global stt credentials_json = '/home/cbarobotics/job/nao/tcs-stt.json' stt = GoogleSTTClient(48000, credentials_json, transcription_cb) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exits myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: audioStreamer must be a global variable # The name given to the constructor must be the name of the # variable global audioStreamer, audio_buffer audioStreamer = AudioStreamerModule("audioStreamer", audio_buffer) audioStreamer.start() try: for raw_audio_data in data_generator(audio_buffer): # Do whatever you want with the data # print ("got data - {}, {} ...".format(len(raw_audio_data), raw_audio_data[:10])) stt.data_to_stream(raw_audio_data) except KeyboardInterrupt: print ("Interrupted by user, shutting down") audioStreamer.stop() myBroker.shutdown() stt.shutdown() sys.exit(0)
def main(): myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) global Speller Speller = SpellerModule("Speller") Speller.beginSpelling(additionalStopCommand="connect") try: while True: time.sleep(1) except KeyboardInterrupt: Speller.stop() myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=NAO_PORT) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: Watson must be a global variable # The name given to the constructor must be the name of the # variable global ALWatson ALWatson = ALWatson("ALWatson") beh = ALProxy("ALBehaviorManager") try: while True: time.sleep(5) command = ALWatson.heartbeat() if "wave" in str(command): beh.runBehavior("animations/Stand/Gestures/Hey_1") continue except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(ip, port): broker = ALBroker('pythonBroker', '0.0.0.0', 9999, ip, port) global memory memory = ALProxy('ALMemory', ip, port) global kehaola kehaola = Kehaola('kehaola', ip, port) kehaola.sub_all() time.sleep(600) kehaola.unsub_all() broker.shutdown()
def main(): import time myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) global PictureFramer PictureFramer = PictureFramerModule("PictureFramer") PictureFramer.start() try: while True: time.sleep(1) except KeyboardInterrupt: PictureFramer.stop() myBroker.shutdown()
def main(): import time myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) global Template Template = TemplateModule("Template") Template.start() try: while True: time.sleep(1) except KeyboardInterrupt: Template.stop() myBroker.shutdown()
def main(): import time myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) global HeadMove HeadMove = HeadMoveModule("HeadMove") HeadMove.start() try: while True: time.sleep(1) except KeyboardInterrupt: HeadMove.stop() myBroker.shutdown()
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport myBroker = ALBroker("myBroker", "0.0.0.0", 0, pip, pport) global emotional_speech global memory emotional_speech = emotional_speech_module("emotional_speech") # set some ALMemory values valence = 1.0 arousal = 1.0 current_emotion = [(valence, arousal), ("valence_mood", "arousal_mood"), ("personality"), ("param1", "param2")] memory.insertData("Emotion/Current", current_emotion) try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def __init__(self, ip, port, simulation_mode=True): self.ip = ip self.port = port self.camProxy = ALProxy("ALVideoDevice", self.ip, self.port) self.postureProxy = ALProxy("ALRobotPosture", self.ip, self.port) self.motionProxy = ALProxy("ALMotion", self.ip, self.port) self.memoryProxy = ALProxy("ALMemory", self.ip, self.port) self.blobProxy = ALProxy("ALColorBlobDetection", self.ip, self.port) self.trackerProxy = ALProxy("ALTracker", self.ip, self.port) self.ttsProxy = ALProxy("ALTextToSpeech", self.ip, self.port) self.broker = ALBroker("pythonMotionBroker", "0.0.0.0", 0, self.ip, self.port) if simulation_mode == False: self.autolifeProxy = ALProxy("ALAutonomousLife", self.ip, self.port) self.autolifeProxy.setState("disabled") self.topCamera = self.camProxy.subscribeCamera("topCamera_pycli", 0, vision_definitions.kVGA, vision_definitions.kBGRColorSpace, framerate) self.bottomCamera = self.camProxy.subscribeCamera( "bottomCamera_pycli", 1, vision_definitions.kQQVGA, vision_definitions.kBGRColorSpace, framerate) self.motionProxy.wakeUp() self.enableExternalCollisionProtection() self.postureProxy.goToPosture("StandInit", 1.0)
def main(): myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, 9559) # Initialize the node and name it. rospy.init_node("action_manager", anonymous=True) # Go to the main loop. action_manager() try: pass except KeyboardInterrupt: print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): myBroker = ALBroker("myBroker", "0.0.0.0", 0, NAO_IP, NAO_PORT) global PictureTaker PictureTaker = PictureTakerModule("PictureTaker") try: PictureTaker.start() try: while True: time.sleep(1) except KeyboardInterrupt: pass except Exception as e: print e finally: PictureTaker.stop() myBroker.shutdown()
def main(ip, port): # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it ip, # parent broker IP port) # parent broker port global tts, memory, aup, leds tts = ALProxy("ALTextToSpeech", ip, port) memory = ALProxy("ALMemory", ip, port) leds = ALProxy("ALLeds", ip, port) aup = ALProxy("ALAudioPlayer", ip, port) # 启动后需要提前加载第一个音乐文件 global PlayFileID scan_mp3() # 先扫描文件夹 filename = MusicList[MusicPoint] PlayFileID = aup.loadFile(filename) global FrontTouch, MiddleTouch, RearTouch global LeftFootTouch, RightFootTouch global LeftHandLeftTouch, RightHandRightTouch FrontTouch = FrontTouch("FrontTouch") MiddleTouch = MiddleTouch("MiddleTouch") RearTouch = RearTouch("RearTouch") LeftFootTouch = LeftFootTouch("LeftFootTouch") RightFootTouch = RightFootTouch("RightFootTouch") LeftHandLeftTouch = LeftHandLeftTouch("LeftHandLeftTouch") RightHandRightTouch = RightHandRightTouch("RightHandRightTouch") # 创建一个线程,监听播放进度, 实现播放歌曲结束后自动切换下一首歌曲; thread.start_new_thread(timer, ()) try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" aup.stopAll() print "Stop All Music" myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ parser = OptionParser() parser.add_option("--pip", help="Parent broker port. The IP address or your robot", dest="pip") parser.add_option("--pport", help="Parent broker port. The port NAOqi is listening to", dest="pport", type="int") parser.set_defaults( pip=NAO_IP, pport=9559) (opts, args_) = parser.parse_args() pip = opts.pip pport = opts.pport # We need this broker to be able to construct # NAOqi modules and subscribe to other modules # The broker must stay alive until the program exists myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it pip, # parent broker IP pport) # parent broker port # Warning: NaoDetection must be a global variable # The name given to the constructor must be the name of the # variable global NaoDetection NaoDetection = PyNaoDetection("NaoDetection") #, 320, 240, 72.6) try: while True: time.sleep(1) #MarkerTracking.visual() if cv2.waitKey(1) & 0xFF == ord('q')\ or NaoDetection.requested_to_exit: break except KeyboardInterrupt: print "Interrupted by user, shutting down" NaoDetection.exit() myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ # It is needed to use a broker to be able to construct NAOQI # modules and subscribe to other modules. The broker must stay # alive until the program exists try: signal.signal(signal.SIGINT, signal_handler) print "[Camera server] - Press Ctrl + C to exit system correctly" myBroker = ALBroker("myBroker", "0.0.0.0", 0, Constants.NAO_IP,Constants.PORT) CameraServer = CameraModule("CameraServer") rospy.spin() except AttributeError: print "[Camera server] - - AttributeError" #unsubscribe from camera CameraServer.prox_camera.unsubscribe(self.nameId);#CameraServer.nameId); myBroker.shutdown() sys.exit(0) except (KeyboardInterrupt, SystemExit): print "[Camera server] - SystemExit Exception caught" #unsubscribe from camera CameraServer.prox_camera.unsubscribe(self.nameId);#CameraServer.nameId); myBroker.shutdown() sys.exit(0) except Exception, ex: print "[Camera server] - Exception caught %s" % str(ex) #unsubscribe from camera CameraServer.prox_camera.unsubscribe(self.nameId);#CameraServer.nameId); myBroker.shutdown() sys.exit(0)
def main(): """ Main entry point """ # It is needed to use a broker to be able to construct NAOQI # modules and subscribe to other modules. The broker must stay # alive until the program exists try: signal.signal(signal.SIGINT, signal_handler) print "[Core agent server] - Press Ctrl + C to exit system correctly" myBroker = ALBroker("myBroker", "0.0.0.0", 0, Constants.NAO_IP,Constants.PORT) global EmailRecognition EmailRecognition = EmailRecognitionModule("EmailRecognition") rospy.spin() except AttributeError: print "[Core agent server] - AttributeError" EmailRecognition.unsubscribe() myBroker.shutdown() sys.exit(0) except (KeyboardInterrupt, SystemExit): print "[Core agent server] - SystemExit Exception caught" EmailRecognition.unsubscribe() myBroker.shutdown() sys.exit(0) except Exception, ex: print "[Core agent server] - Exception caught %s" % str(ex) EmailRecognition.unsubscribe() myBroker.shutdown() sys.exit(0)
def main(): myBroker = ALBroker("SimpleRedBallDetectionBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it NAO_IP, # parent broker IP NAO_PORT) # parent broker port global RedBallDetection RedBallDetection = RedBallDetectionModule("RedBallDetection") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): myBroker = ALBroker( "myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it NAO_IP, # parent broker IP NAO_PORT # parent broker port ) text_analyzer = TextAnalyzerModule("TextAnalyzer") try: while True: text_analyzer.say(input("Say something to Nao: ")) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)
def main(): myBroker = ALBroker("myBroker", "0.0.0.0", # listen to anyone 0, # find a free port and use it NAO_IP, # parent broker IP NAO_PORT) # parent broker port global Personal Personal = PersonalModule("Personal") try: while True: time.sleep(1) except KeyboardInterrupt: print print "Interrupted by user, shutting down" myBroker.shutdown() sys.exit(0)