0

我尝试使用http://doc.aldebaran.com/2-5/naoqi/audio/alaudioplayer-api.html的一些方法

但是终端告诉我,它们中的大多数都不起作用。

# -*- encoding: UTF-8 -*-

import sys
import time
from naoqi import *

IP = "127.0.0.1"
PORT = 9559

try:
    aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALAudioPlayer"
    print "Error was: ",e
    sys.exit(1)

#this line works. I can hear the music
fileId = aup.post.playFile("C:\VALIDPATH.wav")

#does not show most of the methods
print(aup.getMethodList())

time.sleep(1)

#this line does not work
currentPos = aup.getCurrentPosition(fileId)

输出 :

['isStatsEnabled','enableStats','stats','clearStats','isTraceEnabled','enableTrace','exit','__pCall','pCall','version','ping',getMethodList','getMethodHelp '、'getModuleHelp'、'wait'、'isRunning'、'stop'、'getBrokerName'、'getUsage'、'playFile'、'playFileInLoop'、'playFileFromPosition'、'pause']

回溯(最后一次调用):文件“fggfgf.py”,第 27 行,在 currentPos = aup.getCurrentPosition(fileId) 文件“C:\Python27\lib\site-packages\naoqi.py”,第 301 行,调用中 回归自我。Wrapped .method_missing(self.method , *args, **kwargs) File "C:\Python27\lib\site-packages\naoqi.py", line 371, in method_missing raise e RuntimeError: ALAudioPlayer::getCurrentPosition Can't find方法:getCurrentPosition(解析为'(i)')

4

2 回答 2

1

您链接的文档是 Naoqi 2.5 的文档,您使用的是 Naoqi 2.5 吗?

如果是这样,我会说 ALProxy 已被弃用,您的代码应该更像这样:

import qi

session = qi.Session()
try:
  session.connect(IP, PORT)
expect Exception e:
  print "Could not connect: %s" % e

try:
  audioplayer = session.service("ALAudioPlayer")
expect Exception e:
  print "Could not get service: %s" % e
  return

audioplayer.playFile(PATH) // synchrone
audioplayer.playFile(PATH, _async=True) // asynchrone

dir(audioplayer)
于 2017-08-18T08:16:13.937 回答
0

您需要指定机器人上的文件路径。例如 /data/home/nao/.local/share/PackageManager/apps/soundsetaldebaran/sfx_scanner.ogg"

于 2017-06-02T13:53:29.570 回答