python程序控制NAO机器人行走
程序员文章站
2023-01-09 22:54:35
最近重新学习nao的官方文档,写点简单的程序回顾一下。主要是用python调用api,写下来保存着。
'''walk:small example to make...
最近重新学习nao的官方文档,写点简单的程序回顾一下。主要是用python调用api,写下来保存着。
'''walk:small example to make nao walk''' import sys import motion import time from naoqi import alproxy def stiffnesson(proxy): #we use the 'body' to signify the collection of all joints pname="body" pstiffnesslists=1.0 ptimelists=1.0 proxy.stiffnessinterpolation(pname,pstiffnesslists,ptimelists) def main(robotip): #init proxies try: motionproxy=alproxy("almotion",robotip,9559) except exception,e: print "could not create proxy to almotion" print"error was",e try: postureproxy=alproxy("alrobotposture",robotip,9559) except exception,e: print"could not create proxy to alrobotposture" print "error is ",e #set nao in stiffness on stiffnesson(motionproxy) #send nao to pose init postureproxy.gotoposture("standinit",0.5); #eable arms control by walk algorithm motionproxy.setwalkarmseable(true,true) #foot contact protection motionproxy.setmotionconfig([["enable_foot_contact_protection",true]]) #target velocity x=-0.5 #backward y=0.0 theta=0.0 frequency=0.0#low speed motionproxy.setwalktargetvelocity(x,y.theta,frequency) time.sleep(4.0) #target velocity x=0.9 y=0.0 theta=0.0 frenqency=1.0#max speed motionproxy.setwalktargetvelocity(x,y,theta,frenquency) time.sleep(2.0) #arms user motion #arms motion from user have alwalys priority than walk arms motion joinnames=["lshouderpitch","lshouderroll","lelbowyaw","lelbowroll"] arm1=[-40,25,0,-40] arm1=[x*motion.to_rad for x in aram1] arm2=[-40,50,0,-80] arm2=[x*motion.to_rad for x in aram2] pfractionmaxspeed=0.6 motionproxy.angleinterpolationwithspeed(joinnames,arms1,pfractionmaxspeed) motionproxy.angleinterpolationwithspeed(joinnames,arms2,pfractionmaxspeed) motionproxy.angleinterpolationwithspeed(joinnames,arms1,pfractionmaxspeed) #end walk x=0.0 y=0.0 theta=0.0 motionproxy.setwalktargetvelocity(x,y,theta,frequency) if __name__=="__main__": robotip="192.168.1.155" if len(sys.argv)<=1: print "useage pyhton motion_walk.py robotip,default is 127.0.0.1" else: robotip=sys.argv[1] main(robotip)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: 如何愉快地迁移到 Python 3
下一篇: Python实现Linux监控的方法