无法访问所有Naoqi方法

时间:2017-06-02 09:56:30

标签: nao-robot pepper choregraphe

我尝试使用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','退出',' __ pCall',' pCall',   '版本',' ping',getMethodList',' getMethodHelp',' getModuleHelp',   '等待',' isRunning','停止',' getBrokerName',' getUsage',' playFile& #39 ;,   ' playFileInLoop',' playFileFromPosition','暂停']

     

回溯(最近一次呼叫最后一次):文件" fggfgf.py",第27行,          currentPos = aup.getCurrentPosition(fileId)File" C:\ Python27 \ lib \ site-packages \ naoqi.py",301行, call       return self。 wrapped .method_missing(self。 method ,* args,** kwargs)File" C:\ Python27 \ lib \ site-packages \ naoqi。 py",第371行,在method_missing中       raise e RuntimeError:ALAudioPlayer :: getCurrentPosition           无法找到方法:getCurrentPosition(已解析为'(i)')

2 个答案:

答案 0 :(得分: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)

答案 1 :(得分:0)

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