最近重新学习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
#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=[_rad for x in aram1]
arm2=[-40,50,0,-80]
arm2=[_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)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持萬仟网。
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
本文发布于:2024-02-01 05:24:20,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170673626034195.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |