AIR

整理之前的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
#在#!/usr/bin/env中找到python的安装路径,然后去执行它,这个可执行的python路径不管是不是在/usr/bin下

#-*- coding:utf-8 -*- 解决中文输出问题
from naoqi import ALProxy
import threading
IP="192.168.1.109"
port=9559
#构建代理
motionPrx=ALProxy("ALMotion",IP,port)
touchProxy=ALProxy("ALTouch",IP,port)
memory=ALProxy("ALMemory",IP,port)

config=[
["MaxStepX",0.04],
["MaxStpY",0.02],
["StepHeight",0.02],
["MaxStepFrequency",0.3] ]
#定义一个行走的函数
def move():
while True:
motionPrx.moveTo(0.5,0.0,0.0,config)
if Front==1:
break
#定义一个触摸的函数
def touch():
while True:
global Front
Front=memory.getData("FrontTactilTouched")
if Front==1:
motionPrx.rest()
break

if __name__=='__main__':
motionPrx.wakeUp() #让机器人醒来
t1=threading.Thread(target=touch)
t2=threading.Thread(target=move)
t1.start()
t2.start()
t1.join()
t2.join()

 Comments


Blog content follows the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License

Use Material X as theme , total visits times .
载入天数...载入时分秒...