今天自己读了公司的代码,自己仿着写了一边,然后自己写了一遍感受很大。写程序不能有太大的依赖性,那样对思维逻辑的训练没有任何的好处。从适用公司的编码风格到自己随心所欲的写东西,期间得有多少路要走啊。
这部分程序就是让机器人检测naomark并输出信息的。代码看着很简单,但是自己能写出来就不太容易了。好了,废话少说,详见代码注释。
#this coding destronate how to make nao detect naomark
#import time for using time.sleep
import time
#run the naoqi
from naoqi import ALProxy
IP="192.168.1.155"
PORT=9559
#create a proxy for get the module ALLandMarkDetection
try:
landMarkProxy=ALProxy("ALLandMarkDetection",IP,PORT)
except Exception,e:
print"error occur when you create the proxy"
print str(e)
exit(1)
#subcribe to the ALLandMarkDetectionProxy to write this module into ALMemory
period=500
landMarkProxy.subcribe("Text_LandMark",period,0.0)
#almemory will output this value
memValue="LandMarkDetected!"
#create a proxy to ALMemory
try:
memoryProxy=ALPr