我正在与NAO机器人和Choregraphe合作进行一个课堂项目。目标是让机器人使用Python转身行走。
程序运行到可以旋转的地步,但在即将前进之前就停止了。
我完全遵循了NAO教科书,甚至提供了代码和说明。我仍然遇到错误,程序无法运行。
我已经一遍又一遍地检查了代码,它与教科书中的内容完全匹配。
import math
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
pass
def onUnload(self):
#put clean-up code here
pass
def onInput_onStart(self):
x=self.getParameter("x")
y=self.getParameter("y")
amountToTurn=math.atan2(x,y)
amountToWalk=math.sqrt(x*x+y*y)
motionProxy=ALProxy("ALMotion")
motionProxy.walkTo(0,0,amountToTurn)
Motion.Proxy.walkTo(amountToWalk,0,0)
#self.onStopped() #activate the output of the box
pass
def onInput_onStop(self):
self.onUnload() #it is recommended to reuse the clean-up as the box is stopped
self.onStopped() #activate the output of the box
我得到的错误是:
[ERROR] behavior.box :_safeCallOfUserMethod:281 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11787750888__root__PythonTurnandWalk_4: Traceback (most recent call last):
File "C:\PROGRA~2\ALDEBA~1\CHOREG~1.1\lib\naoqi.py", line 271, in _safeCallOfUserMethod
func()
File "<string>", line 23, in onInput_onStart
NameError: global name 'Motion' is not defined