当前位置: 移动技术网 > IT编程>脚本编程>Python > python程序控制NAO机器人行走

python程序控制NAO机器人行走

2019年06月06日  | 移动技术网IT编程  | 我要评论

mc石头宝贝我爱你,巨型至高岭鲑鱼,智能座便

最近重新学习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) 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网