当前位置: 首页>>代码示例>>Python>>正文


Python ALBroker.shutdown方法代码示例

本文整理汇总了Python中naoqi.ALBroker.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python ALBroker.shutdown方法的具体用法?Python ALBroker.shutdown怎么用?Python ALBroker.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在naoqi.ALBroker的用法示例。


在下文中一共展示了ALBroker.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)		
开发者ID:Satantarkov,项目名称:NaoPFC,代码行数:37,代码来源:ball_position.py

示例2: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:29,代码来源:Markov_tickles.py

示例3: ToMarkovChoiceGoodInput

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:34,代码来源:Markov_tickles_unittest.py

示例4: play

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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
开发者ID:Angeall,项目名称:pyConnect4NAO,代码行数:36,代码来源:connect4nao.py

示例5: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:axmtec0eric,项目名称:Nao-Robot,代码行数:36,代码来源:touch_passwd.py

示例6: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:axmtec0eric,项目名称:Nao-Robot,代码行数:29,代码来源:touch_password.py

示例7: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:rapp-project,项目名称:rapp-robot-nao,代码行数:27,代码来源:acore_execution_server.py

示例8: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:pieterwolfert,项目名称:HRI,代码行数:60,代码来源:speechDetectModule.py

示例9: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:FallingTree,项目名称:PrehensionNao,代码行数:60,代码来源:main.py

示例10: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:59,代码来源:stop_by_holding_both_hands.py

示例11: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:icrl,项目名称:nico,代码行数:59,代码来源:adialog.py

示例12: ToMarkovChoiceBadInput

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:58,代码来源:Markov_tickles_unittest.py

示例13: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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)
开发者ID:zaheerm,项目名称:naowificonnector,代码行数:15,代码来源:speller.py

示例14: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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()
开发者ID:zaheerm,项目名称:naophotographer,代码行数:16,代码来源:template.py

示例15: main

# 需要导入模块: from naoqi import ALBroker [as 别名]
# 或者: from naoqi.ALBroker import shutdown [as 别名]
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()
开发者ID:zaheerm,项目名称:naophotographer,代码行数:16,代码来源:headmove.py


注:本文中的naoqi.ALBroker.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。