Choregraphe 中的 python 代码错误
Error in python code in Choregraphe
今天我在我的新笔记本上启动了 Choregraphe,我发现了一个我还没有看到的错误。该代码完美运行。
代码如下:
import sys
import time
from naoqi import ALProxy
def main(robotIP):
PORT = 5058
try:
motionProxy = ALProxy("ALMotion",robotIP,PORT)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: "
sys.exit(1)
motionProxy.setStiffnesses("Head", 1.0)
names = "HeadPitch"
angleLists = 0.349
timeLists = 1.0
isAbsolute = True
motionProxy.angleInterpolation(names,angleLists,timeLists,isAbsolute)
time.sleep(1.0)
motionProxy.setStiffnesses("Head",0.0)
if __name__ == "__main__":
robotIP = "192.168.0.20"
main(robotIP)
此代码应按角度移动头部俯仰。是的,它奏效了。问题是:为什么代码向我显示此错误?
User class evaluation failed with the error:1
我尝试重新输入代码或尝试在代码开头点击 "ENTER"(在 C# 上有时可以)但没有任何效果。
有人可以告诉我该怎么做吗?
你可以改成9559端口。另外,naoqi有一个新密码我给你举个例子:
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
import qi
import sys
import argparse
def main(session):
motionProxy = session.service("ALMotion")
motionProxy.setStiffnesses("Head", 1.0)
names = "HeadPitch"
angleLists = 0.349
timeLists = 1.0
isAbsolute = True
motionProxy.angleInterpolation(names,angleLists,timeLists,isAbsolute)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)
今天我在我的新笔记本上启动了 Choregraphe,我发现了一个我还没有看到的错误。该代码完美运行。
代码如下:
import sys
import time
from naoqi import ALProxy
def main(robotIP):
PORT = 5058
try:
motionProxy = ALProxy("ALMotion",robotIP,PORT)
except Exception,e:
print "Could not create proxy to ALMotion"
print "Error was: "
sys.exit(1)
motionProxy.setStiffnesses("Head", 1.0)
names = "HeadPitch"
angleLists = 0.349
timeLists = 1.0
isAbsolute = True
motionProxy.angleInterpolation(names,angleLists,timeLists,isAbsolute)
time.sleep(1.0)
motionProxy.setStiffnesses("Head",0.0)
if __name__ == "__main__":
robotIP = "192.168.0.20"
main(robotIP)
此代码应按角度移动头部俯仰。是的,它奏效了。问题是:为什么代码向我显示此错误?
User class evaluation failed with the error:1
我尝试重新输入代码或尝试在代码开头点击 "ENTER"(在 C# 上有时可以)但没有任何效果。
有人可以告诉我该怎么做吗?
你可以改成9559端口。另外,naoqi有一个新密码我给你举个例子:
#! /usr/bin/env python
# -*- encoding: UTF-8 -*-
import qi
import sys
import argparse
def main(session):
motionProxy = session.service("ALMotion")
motionProxy.setStiffnesses("Head", 1.0)
names = "HeadPitch"
angleLists = 0.349
timeLists = 1.0
isAbsolute = True
motionProxy.angleInterpolation(names,angleLists,timeLists,isAbsolute)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="127.0.0.1",
help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.")
parser.add_argument("--port", type=int, default=9559,
help="Naoqi port number")
args = parser.parse_args()
session = qi.Session()
try:
session.connect("tcp://" + args.ip + ":" + str(args.port))
except RuntimeError:
print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
"Please check your script arguments. Run with -h option for help.")
sys.exit(1)
main(session)