您好,登錄后才能下訂單哦!
本文實例為大家分享了python控制nao機器人身體動作的具體代碼,供大家參考,具體內容如下
今天讀的代碼,順便寫了出來,與文檔的對比,差不多。
import sys import motion import almath import naoqi from ALProxy def StiffnessOn(proxy): pName="Body" pStiffnessLists pTime=1.0 proxy.stiffnessInterpolation(pName,pStiffnessLists,pTime) def main(robotIP): try: motionProxy=ALProxy("ALMotion",robotIP,9559) except Exception,e: print:"could not create a proxy!" print:"error is ",e try: postureProxy=ALProxy("ALRobotPosture",robotIP,9559) except Exception,e: print:"could not create a proxy!" print:"error is ",e StiffnessOn(motionProxy) postureProxy.goToPosture("StandInit",0.5) space=motion.FRAME_ROBOT coef=0.5 times=[coef,2.0*coef,3.0*coef,4.0*coef] isAbsolute=False dy=+0.06 dz=-0.03 dwx==+0.30 effector="Torso" path=[ [0.0,-dy,dz,-dwx,0.0,0.0], [0.0,0.0,0.0,0.0,0.0,0.0], [0.0,+dy,dz,+dwx,0.0,0.0], [0.0,0.0,0.0,0.0,0.0,0.0] ] axisMask=almath.AXIS_MASK_ALL motionProxy.post.postionInterpolation(effector,space,path,times,isAbsolute) #motion of arms with block process axisMask=almath.AXIS_MASK_VEL times=[1.0*coef,2.0*coef] dy=+0.03 effecor="RArm" path=[ [0.0,dy,0.0,0.0,0.0,0.0], [0.0,0.0,0.0,0.0,0.0,0.0] ] motionProxy.positionInterpolation(effector,space,path,axisMask,times,inAbsolute) if __name__=="__main__": robotIP="127.0.0.1" if len(sys.argv)<=1: print"useage default robotIP" else: robotIP=sys.arv[1] main(robotIP)
實例二,控制左右胳膊
#-*-encoding:UTF-8 -*- import sys import motion import almath form naoqi import ALProxy def StiffnessOn(proxy): pName="Body" pStiffnessLists=1.0 pTimeLists=1.0 proxy.stiffnessInterpolation(pName,pStiffnessLists,pTimeLists) def main(robotIP): #create a proxy to almtion try: motionProxy=ALProxy("ALMotion",robotIP,9559) except Exception,e: print "could not create a proxy" print "error is ",e #create a proxy to alrobotposture try: postureProxy=ALProxy("ALRobotPosture",robotIP,9559) except Exception,e: print "could not create a proxy" print "error is ",e StiffnessOn(motionProxy) postureProxy.goToPosture("StandInit",0.5) space=motion.FRAME_ROBOT isAbsolute=False effectorList=["LArm","RArm"] #motion of arms with block process axisMaskList=[almath.AXIS_MASK_VEL,almath.AXIS_MASK_VEL] timeLists=[[1.0],[1.0]] pathList=[ [ [0.0,-0.04,0.0,0.0,0.0,0.0]], [ [0.0,0.04,0.0,0.0,0.0,0.0]] ] motionProxy.positionInterpolation(effectorLists,space,pahtLists,axisMaskList,timeLists,isAbsolute) effectorLists=["LArm","RArm","Torso"] axisMaskLists=[ almath.AXIS_MASK_VEL, almath.AXIS_MASK_VEL, almath.AXIS_MASK_ALL ] timeLists=[ [[0.0,0.0,0.0,0.0,0.0,0.0]], [[0.0,0.0,0.0,0.0,0.0,0.0]], [0.0,+dy,0.0,0.0,0.0,0.0], [0.0,-dy,0.0,0.0,0.0,0.0], [0.0,0.0,0.0,0.0,0.0,0.0] ] motionProxy.positionInterpolations(effectorList,space,pathList,axisMaskList,timeList,isAbsolute) if __name__=="__main__": robotIP="127.0.0.1" if(sys.argv<1): print"usege default ip" else: robotIP=sys.arv[1] main(robotIP)
感受:
這些小的程序最不好處理的就是path中的數據了。這些數據是怎么獲得的?最大的可能就是在choregraph中3D視圖中測試得到,當然還有一種可能就是將choregraph與實體機連接,將機器人置于practice狀態,這樣操作來獲得數據。后者操作性更強,但由于實際原因,用前者的可能性是最大的。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。