pynaoqi库的安装
下载文件
下载完成后直接打开文件,运行安装即可
在Choregraphe上进行python编程
在主程序区新建python盒子
通过python让Nao说话
在Choregraphe中写入这样一段代码
def onInput_onStart(self):
#self.onStopped() #activate the output of the box
tts = ALProxy("ALTextToSpeech") # 创建ALProxy中“ALTextToSpeech”的代理
tts.say("Hello") # 通过调用其中的.say()方法使机器人说话
self.onStopped()
通过python让Nao行走
def onInput_onStart(self):
#self.onStopped() #activate the output of the box
motion = ALProxy("ALMotion") # 创建"ALMotion"的代理
motion.moveTo(0.1, 0, 0) # 调用moveTo()方法,传递三个参数,分别为前进的距离,向左的距离,身体转的角度
self.onStopped()
在Pycharm中对nao进行控制
在成功安装naoqi库以后,我们就可以在Pycharm中控制nao机器人
通过代理建立连接
# 通过调用naoqi中的ALProxy类 建立代理连接
from naoqi import ALProxy
ALExpression = ALProxy("模块名称", robot_IP, port)
模块名称通过查阅API文档获得: