Python-based NAO Robot Development 01: Installing python and naoqi library and wired and wireless connections

A, NAOqi APIs

  NAOqi OS is the core operating system NAO robot, NAOqi API offers a variety of sensor devices interface to access the robot and application interface. By the NAOqi, you can pass information between each motion, visual, audio, etc. different modules, programming can also implement various functions.

Second, install and python libraries NAOqi

  Windows environment, NAO supported python version 32 of python2, may python official website to download. Select Windows x86 MSI installerand configure python2 environment variable, C:Python27and C:Python27Scriptsadded to the PATH. Then the robot community Softbank SoftBank Robotics Community download NAOqi library, select Resources in the Software, to find the Python 2.7 SDK 2.1.4 Win 32 Setupdownload.
  Download Link: NAOqi Python SDK
  Download python
  naoqi Download
  to check pythonwhether installed correctly: Press win+R, and enter cmdinto the command line program, input python, if any message is correctly installed, otherwise check the environment variable is added correctly.
  Checks naoqiare installed correctly: take the above command line (entered pythonunder the premise), continue to enter import naoqi, without any display is installed correctly.

Third, the installation Choregraphe

  Choregraphe是一个图形化的多平台软件,编写完程序后可以在模拟机器人上测试,也可以运行在真实的机器人上。在软银机器人社区SoftBank Robotics Community中可以下载。选择Resources中的Software,找到Choregraphe 2.1.4 Win 32 Setup下载安装即可。
  注:安装路径不要出现在中文。
  下载链接:Choregraphe
  Choregraphe

四、NAO机器人的有线连接

4.1 连接步骤

  首先将NAO和计算机通过网线连接,将计算机的网络设置为有线连接,然后打开浏览器,按下NAO机器人的胸部按钮,在浏览器中输入NAO报的IP地址。
  Landed
  输入用户名nao,密码nao(默认)即可登陆至nao机器人网页,在网络设置里面可以看到已经连接至有线。
  wired

4.2 测试

  打开Choregraph,选择连接->连接至,在弹出的对话框中选择IP为刚才的NAO机器人,并选择连接。
  connection
  在Choregraph界面的左下角的指令盒内依次选择Motions中的Wake UpStand UpRest,并用信号线将其连接,即可实现简单的站立、休息的动作。在Choregraph界面的最上面单击绿色三角箭头按钮即可运行程序。
  program
   当然也可以通过python编译器在里面输入相应的代码实现此功能。 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
大专栏   基于python的NAO机器人开发01:安装python和naoqi库及有线和无线连接an class="line">19
20
21
22
23
24
25
26
27
28


import argparse
from naoqi import ALProxy

def (robotIP, PORT=9559):

motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)

# Wake up robot
motionProxy.wakeUp()

# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)

# Go to rest position
motionProxy.rest()

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default="169.254.67.213",
help="Robot ip address")
parser.add_argument("--port", type=int, default=9559,
help="Robot port number")

args = parser.parse_args()
main(args.ip, args.port)

  注意,IP和端口号(port)一定要对,IP为按NAO胸口按钮后报出的IP,真实NAO的port默认为9559。
  最终效果如图所示:
  effect

五、NAO机器人的无线连接及测试

5.1 连接步骤

  Turn on the computer connected to a wireless network, a wireless network connection, and then select a wireless computer network in the same network settings NAO web interface, and unplug the cable, a wireless connection can be realized. Press the button NAO chest, then it will report the IP address of the wireless network. At this point need to re-enter the IP address into the NAO web interface.
  Wireless connections

5.2 Testing

  In this case, Choregraph of connectivity options, select the NAO robot IP address of the wireless network, and just execute programs. Similarly change the appropriate IP address and port number at the python code.
  Wi-Fi

Sixth, the NAO robot connections and virtual testing

6.2 connecting step

  Choregraph software provides a set can be connected to the virtual robot can also realize the function of some real robots. First disconnect all the real robots, select the connection to connect to the virtual robot in a virtual robot connection options. At the same time you can see its IP address and port number. (Virtual robots are the default IP address 127.0.0.1) check on the robot view in the View option to view the virtual robot.
  virtual
  Robot View

6.3 Test

  Similarly change the appropriate IP address and port number at the python code. 
  effect

Guess you like

Origin www.cnblogs.com/liuzhongrong/p/12371525.html
Recommended