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


Python ALProxy.unsubscribe方法代码示例

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


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

示例1: SpeechDetectionModule

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
class SpeechDetectionModule(ALModule):
	""" A module that handles NAO recognition app commands. """
	
	def __init__(self, name):
		ALModule.__init__(self, name)
		self.name = name
		self.memory = ALProxy("ALMemory")
		self.asr = ALProxy("ALSpeechRecognition")
		self.asr.setLanguage("English")
		vocabulary = ["color", "text", "gesture", "phone"]
		self.asr.setVocabulary(vocabulary, False)
		self.asr.subscribe(self.getName())
		self.memory.subscribeToEvent("WordRecognized", self.getName(), "onWordRecognized")
	
	def onWordRecognized(self, key, value, message):	
		""" A method that handles command recognition. """
		global NaoWorkingMode
		if(len(value) > 1 and value[1] >= 0.5):
			print 'recognized the word :', value[0]
			NaoWorkingMode = value[0]
		else:
			print 'unsifficient threshold'
			NaoWorkingMode = None
			
	def disconnect(self):
		try:
			self.memory.unsubscribeToEvent("WordRecognized", self.getName())
			self.asr.unsubscribe(self.getName())
		except BaseException, err:
			print "Error while disconnecting from speech module: " + str(err)
开发者ID:knawrot,项目名称:nao-objects-recognition,代码行数:32,代码来源:app.py

示例2: init

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def init(IP,PORT):
	global motionProxy
	global tts
	global post
	global sonarProxy
	global memoryProxy
	global cameraProxy
	global videoClient


	post = ALProxy("ALRobotPosture", IP, PORT)
	tts = ALProxy("ALTextToSpeech", IP, PORT)
	motionProxy = ALProxy("ALMotion", IP, PORT)
	cameraProxy = ALProxy("ALVideoDevice", IP, PORT)
	# init video
	resolution = 0    # 0 : QQVGA, 1 : QVGA, 2 : VGA
	colorSpace = 11   # RGB
	camNum = 0 # 0:top cam, 1: bottom cam
	fps = 1; # frame Per Second
	cameraProxy.setParam(18, camNum)
	try:
		videoClient = cameraProxy.subscribe("python_client", 
														resolution, colorSpace, fps)
	except:
		cameraProxy.unsubscribe("python_client")
		videoClient = cameraProxy.subscribe("python_client", 
														resolution, colorSpace, fps)
	print "Start videoClient: ",videoClient
	sonarProxy = ALProxy("ALSonar", IP, PORT)
	sonarProxy.subscribe("myApplication")
	memoryProxy = ALProxy("ALMemory", IP, PORT)

	post.goToPosture("Crouch", 1.0)
	time.sleep(2)
开发者ID:benefije,项目名称:DHE,代码行数:36,代码来源:eye_finder_standalone.py

示例3: NAOVoiceRec

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
class NAOVoiceRec(ALModule):
    def __init__(self, id, ip, port, wordList, callBack, wordSpotting=True, visualExpression=True, audioExpression=False):
        super(NAOVoiceRec, self).__init__(id)
        self.id = id
        self.wordCallBack = callBack;

        #create the speech recognition proxy
        self.speechRec = ALProxy("ALSpeechRecognition", ip, port)

        #set the language
        self.speechRec.setLanguage("English")
        #load the vocabulary
        self.speechRec.setVocabulary(wordList, wordSpotting)
        self.speechRec.subscribe(id)
        # configure expressions
        self.speechRec.setVisualExpression(visualExpression)
        self.speechRec.setAudioExpression(audioExpression)

        #get the ALMemory Proxy and subscribe to the events
        self.memProx = ALProxy("ALMemory")
        self.memProx.subscribeToEvent("WordRecognized", self.id, "wordRecognized")

    def __del__(self):
        self.speechRec.unsubscribe(self.id)
        self.memProx.unsubscribeToEvent("WordRecognized", self.id)

    def wordRecognized(self, event, words, id):
        self.wordCallBack(words)
开发者ID:afranka69,项目名称:ShowRobbie,代码行数:30,代码来源:VoiceRec.py

示例4: getColour

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def getColour(IP, PORT):
    """
First get an image from Nao, then show it on the screen with PIL.
    :param IP:
    :param 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

    camProxy = ALProxy("ALVideoDevice", IP, PORT)
    resolution = 2 # VGA
    colorSpace = 11 # RGB


    videoClient = camProxy.subscribe("python_client", resolution, colorSpace, 5)

    t0 = time.time()

    # Get a camera image.
    # image[6] contains the image data passed as an array of ASCII chars.
    naoImage = camProxy.getImageRemote(videoClient)

    t1 = time.time()

    # Time the image transfer.
    #print "Runde: ", b

    camProxy.unsubscribe(videoClient)


    # Now we work with the image returned and save it as a PNG using ImageDraw
    # package.

    # Get the image size and pixel array.
    imageWidth = naoImage[0]
    imageHeight = naoImage[1]
    array = naoImage[6]

    #Create a PIL Image Instance from our pixel array.
    img0= Image.frombytes("RGB", (imageWidth, imageHeight), array)


    #frame=np.asarray(convert2pil(img0)[:,:])

    #object_rect2=detectColor(img0, RED_MIN,RED_MAX)
    frame=detectShape(img0, RED_MIN,RED_MAX)

    #frame=selectDetected(object_rect1,frame)

    #frame=selectDetected(object_rect2,frame)
    # currentImage = path+ "/camImage1cm.jpg"
    # cv2.imwrite(currentImage, frame)
    cv2.imshow('contour',frame)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
开发者ID:vbabushkin,项目名称:RoboticVisionLegoGame,代码行数:62,代码来源:shapeDetectionNAO.py

示例5: showNaoImage

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def showNaoImage(IP, PORT):
    camProxy = ALProxy("ALVideoDevice", IP, PORT)
    resolution = 2  # VGA
    colorSpace = 11  # RGB

    videoClient = camProxy.subscribe("python_client", resolution, colorSpace, 5)

    t0 = time.time()

    # Get a camera image.
    # image[6] contains the image data passed as an array of ASCII chars.
    naoImage = camProxy.getImageRemote(videoClient)

    t1 = time.time()

    # Time the image transfer.
    print "acquisition delay ", t1 - t0

    camProxy.unsubscribe(videoClient)

    # Now we work with the image returned and save it as a PNG  using ImageDraw
    # package.

    # Get the image size and pixel array.
    imageWidth = naoImage[0]
    imageHeight = naoImage[1]
    array = naoImage[6]

    # Create a PIL Image from our pixel array.
    im = Image.fromstring("RGB", (imageWidth, imageHeight), array)

    nomPhoto = time.strftime("%d-%m-%y_a_%H-%M-%S", time.localtime())
    print nomPhoto
    # Save the image.
    im.save("../public/imgNao/" + nomPhoto + ".jpeg", "JPEG")
开发者ID:Cydev2306,项目名称:Nao-App,代码行数:37,代码来源:prendrePhoto.py

示例6: ImageHandler

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
class ImageHandler():

	
	def __init__(self):
		self.video = ALProxy("ALVideoDevice", nao_ip, 9559)
		self.resolution = 2 #VGA
		self.colorSpace = 11 #RGB
		self.framerate = 30
		self.nameID = self.video.subscribe("NAOLearn", self.resolution, self.colorSpace, self.framerate)

	def __del__(self):
		self.video.unsubscribe("NAOLearn")


	def getLatestFrame(self):

		#try:

		alimage = self.video.getImageRemote(self.nameID)

		imageWidth = alimage[0]
		imageHeight = alimage[1]
		imageArray = alimage[6]

		image = Image.fromstring("RGB", (imageWidth, imageHeight), imageArray)

		output = StringIO.StringIO()

		image.save(output, format="JPEG",quality=80, optimize=True)

		outputString = output.getvalue()
		output.close()

		return outputString
开发者ID:StetsonG,项目名称:NAOLearn,代码行数:36,代码来源:ImageHandler.py

示例7: getNaoImage

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def getNaoImage(IP, PORT):
    
    camProxy = ALProxy("ALVideoDevice", IP, PORT)
    
    resolution = 2 # 640*480px http://doc.aldebaran.com/2-1/family/robots/video_robot.html#cameraresolution-mt9m114
    colorSpace = 11 # RGB colorspace http://doc.aldebaran.com/2-1/family/robots/video_robot.html#cameracolorspace-mt9m114
    fps = 5 # can be 0-30 fps

    videoClient = camProxy.subscribe("python_client", resolution, colorSpace, fps)
    t0 = time.time()
    naoImage = camProxy.getImageRemote(videoClient)
    t1 = time.time()
    
    camProxy.unsubscribe(videoClient)

    # Get the image size and pixel array.
    imageWidth = naoImage[0]
    imageHeight = naoImage[1]
    array = naoImage[6]

    # Create a PIL Image from our pixel array.
    im = Image.fromstring("RGB", (imageWidth, imageHeight), array)
    #grab image from PIL and convert to opencv image
    img = np.array(im)
    img = img[:, :, ::-1].copy()

    #im.save(name,"PNG")
    
    
    print "acquisition delay ", t1 - t0
    return img
开发者ID:davidlavy88,项目名称:nao_and_opencv-python-,代码行数:33,代码来源:capture_contour_cleaner2.py

示例8: VideoModule

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
class VideoModule():
    
    def __init__(self, resolution=2, colorSpace=11, fps=5):
        self.vd = ALProxy('ALVideoDevice')
        modules.append(self)
        self.vd.subscribe('videoModule', resolution, colorSpace, fps)


    def getImage(self):
        results = self.vd.getImageRemote('videoModule')
        image = NaoImage()
        image.width = results[0]
        image.height = results[1]
        image.layersNumber = results[2]
        image.colorSpace = results[3]
        image.timestamp = results[4]
        image.microtimestamp = results[5]
        image.pixels = np.frombuffer(
            results[6], dtype=np.uint8).reshape((image.height, image.width, 3))
        image.cameraID = results[7]
        image.leftAngle = results[8]
        image.rightAngle = results[9]
        image.topAngle = results[10]
        image.bottomAngle = results[11]
        return image
        
    def startRecord(self, filename):
        self.vd.recordVideo('videoModule', 100, 1)
        
    def stopRecord(self, filename):
        self.vd.stopVideo('videoModule')
        
    def close(self):
        self.vd.unsubscribe('videoModule')
开发者ID:ISNJeanMace,项目名称:NAO-play-poker,代码行数:36,代码来源:nao.py

示例9: showNaoImage

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def showNaoImage(IP, PORT):
  camProxy = ALProxy("ALVideoDevice", IP, PORT)
  resolution = 2    # VGA
  colorSpace = 11   # RGB

  videoClient = camProxy.subscribe("python_client", resolution, colorSpace, 5)

  # Get a camera image.
  # image[6] contains the image data passed as an array of ASCII chars.
  naoImage = camProxy.getImageRemote(videoClient)

  camProxy.unsubscribe(videoClient)


  # Now we work with the image returned and save it as a PNG  using ImageDraw
  # package.

  # Get the image size and pixel array.
  imageWidth = naoImage[0]
  imageHeight = naoImage[1]
  array = naoImage[6]

  # Create a PIL Image from our pixel array.
  im = Image.fromstring("RGB", (imageWidth, imageHeight), array)
  
  # Save the image.
  im.save("../public/imgNao/live.jpeg", "JPEG")
开发者ID:matth02100,项目名称:Nao,代码行数:29,代码来源:live.py

示例10: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def main(robotIp,robotPort):
    sonarProxy = ALProxy("ALSonar",robotIp,robotPort)
    sonarProxy.subscribe("Sensores")
    memoryProxy = ALProxy("ALMemory",robotIp,robotPort)
    while (1):
        left=memoryProxy.getData("Device/SubDeviceList/US/Left/Sensor/Value")
        right=memoryProxy.getData("Device/SubDeviceList/US/Right/Sensor/Value")
        val=[left,right]
        print val
        if left<0.3 and right<0.3:
            if left<right:
                talker("ObsL")
            else:
            	talker("ObsR")
            time.sleep(7)
            continue
        if left<0.3:
            talker("ObsL")
            time.sleep(7)
            continue
        if right<0.3:
            talker("ObsR")
            time.sleep(7)
            continue
    sonarProxy.unsubscribe("Sensores")
开发者ID:JesusViveros,项目名称:Proyectos,代码行数:27,代码来源:Sonar.py

示例11: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def main(IP, PORT):
	camProxy = ALProxy("ALVideoDevice", IP, PORT)
#	resolution = 2    # VGA 640x480
	resolution = 0    # kQQVGA, 160x120
#	colorSpace = 11   # RGB
#	colorSpace = 10   # YUV
	colorSpace = 9    # YUV422

	# 程序测试经常挂掉,导致subscriberID未被取消订阅,需要更换订阅号;这里加入随机;
	subscriberID = 'send_YUV422_' + str(random.randint(0,100))

	videoClient = camProxy.subscribe(subscriberID, resolution, colorSpace, 30)

	# ----------> 开启socket服务器监听端口 <----------
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	sock.bind((IP, LISTEN_PORT))
	sock.listen(10)

	naoImage = camProxy.getImageRemote(videoClient)
	array = naoImage[6]
#	print 'VIDEO#' + array + '\r'
	print 'image data length:', len(array) 
	print 'print test over.'
	print '---------------------------------------------'

	global connection
	try:
		while True: 		# 等待客户端连接,单线程监听单一客户端
			print 'Waiting for a connection'
			connection,address = sock.accept()
			print 'socket client connected.'
			CONNECT = True
			while CONNECT == True:
				# 发送YUV422图像至客户端
				naoImage = camProxy.getImageRemote(videoClient)
				array = naoImage[6]	

#				for i in range(len(array)):
#					connection.send(array[i])
#					if (i % 5 == 0):
#						connection.send('\r')
#				connection.send('\r')

				connection.send(bytes(array+'\n', 'utf-8'))

#				connection.send('VIDEO#' + array + '\r#OVER\r')
				print 'send image date successful.'
#				time.sleep(1)	
				CONNECT = False
			print 'socket client disconnect.'
	except KeyboardInterrupt: # CTRL+C, 关闭服务器端程序;
		print ""
		print "Interrupted by user, shutting down"
		camProxy.unsubscribe(videoClient)
		print 'unsubscribe nao video device'
		if connection != None:
			connection.close()	
			print 'socket connection closed.'
		sys.exit(0)
开发者ID:axmtec0eric,项目名称:Nao-Robot,代码行数:61,代码来源:send_YUV422_TCP.py

示例12: showNaoImage

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def showNaoImage(IP, PORT):
    """
  First get an image from Nao, then show it on the screen with PIL.
  """

    camProxy = ALProxy("ALVideoDevice", IP, PORT)
    resolution = 2  # VGA
    colorSpace = 11  # RGB

    videoClient = camProxy.subscribe("python_client", resolution, colorSpace, 5)

    t0 = time.time()

    # Get a camera image.
    # image[6] contains the image data passed as an array of ASCII chars.
    naoImage = camProxy.getImageRemote(videoClient)

    t1 = time.time()

    # Time the image transfer.
    print "acquisition delay ", t1 - t0

    camProxy.unsubscribe(videoClient)

    # Now we work with the image returned and save it as a PNG  using ImageDraw
    # package.

    # Get the image size and pixel array.
    imageWidth = naoImage[0]
    imageHeight = naoImage[1]
    numLayers = naoImage[2]
    array = naoImage[6]
    print "Type is", type(array)

    vec_im = []
    # Create a PIL Image from our pixel array.
    im = Image.fromstring("RGB", (imageWidth, imageHeight), array)
    print "Type of image is", type(im)
    vec_im.append(im)
    # nparr = np.fromstring(array, np.uint8).reshape( imageHeight, imageWidth, numLayers)
    # img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR)

    # cv2.imshow('np',img_np)

    # print type(img_np)
    # Save the image.
    im.save("garbage.png", "PNG")

    im.show()

    open_cv_image = np.array(im)
    # Convert RGB to BGR
    open_cv_image = open_cv_image[:, :, ::-1].copy()
    # cv2.startWindowThread()
    cv2.imshow("image", open_cv_image)
    k = cv2.waitKey(0)
    if k == 27:  # wait for ESC key to exit
        cv2.destroyAllWindows()
        cv2.waitKey(1)
开发者ID:davidlavy88,项目名称:nao_and_opencv-python-,代码行数:61,代码来源:vision_getandsaveimage.py

示例13: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [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

示例14: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [as 别名]
def main():
    global broker
    broker = ALBroker("myBroker", "0.0.0.0", 0, PEPPER_IP, PEPPER_PORT)

    # init camera
    video = ALProxy('ALVideoDevice')
    subscribers = video.getSubscribers()

    # init depth camera
    exists_camera_name = "{0}_0".format(DEPTH_CAMERA_NAME)
    if exists_camera_name in subscribers:
        depth_subscribe_id = exists_camera_name
    else:
        depth_subscribe_id = video.subscribeCamera(DEPTH_CAMERA_NAME, DEPTH_CAMERA_ID, RESOLUTION, DEPTH_COLOR_SPACE, FRAMERATE)
    print u"subscribe_id: {0}".format(depth_subscribe_id)

    # init rgb camera
    exists_camera_name = "{0}_0".format(RGB_CAMERA_NAME)
    if exists_camera_name in subscribers:
        rgb_subscribe_id = exists_camera_name
    else:
        rgb_subscribe_id = video.subscribeCamera(RGB_CAMERA_NAME, RGB_CAMERA_ID, RESOLUTION, RGB_COLOR_SPACE, FRAMERATE)
    print u"rgb_subscribe_id: {0}".format(rgb_subscribe_id)

    # get image
    for i in range(0, TIMES):
        print u"try: {0} {1}".format(i, datetime.now().strftime("%Y/%m/%d %H:%M:%S"))

        depth_ary = video.getImageRemote(depth_subscribe_id)
        rgb_ary = video.getImageRemote(rgb_subscribe_id)

        depth = QiImage(depth_ary)
        depth_binary = [struct.unpack('B', x)[0] for x in depth.binary]
        depth_save_path = DEPTH_FILE_PREFIX + "_" + str(i) + "_" + datetime.now().strftime("%Y%m%d_%H%M%S") + '.bmp'
        with Image.new("L", (depth.width, depth.height)) as im:
            im.putdata(depth_binary[::2])
            im.save(depth_save_path, format='bmp')
        print u"depth image file was created: {0}".format(depth_save_path)

        rgb = QiImage(rgb_ary)
        rgb_save_path = RGB_FILE_PREFIX + "_" + str(i) + "_" + datetime.now().strftime("%Y%m%d_%H%M%S") + '.bmp'
        rgb_binary = [struct.unpack('B', x)[0] for x in rgb.binary]
        with Image.new("RGB", (rgb.width, rgb.height)) as im:
            im.putdata(zip(*[iter(rgb_binary)] * 3))
            im.save(rgb_save_path, format='bmp')
        print u"rgb image file was created: {0}".format(rgb_save_path)

        both_save_path = BOTH_FILE_PREFIX + "_" + str(i) + "_" + datetime.now().strftime("%Y%m%d_%H%M%S") + '.bmp'
        with Image.new("RGB", (rgb.width, rgb.height * 2)) as im:
            im.putdata(zip(*[iter(rgb_binary)] * 3) + [(x, x, x) for x in depth_binary[::2]])
            im.save(both_save_path, format='bmp')
            im.show()
        print u"both image file was created: {0}".format(both_save_path)

        time.sleep(WAIT)

    video.unsubscribe(depth_subscribe_id)
    video.unsubscribe(rgb_subscribe_id)
开发者ID:swkoubou,项目名称:peppermill-test,代码行数:60,代码来源:capture_depth_and_rgb.py

示例15: main

# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import unsubscribe [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


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