python控制nao机器人身体动作实例详解
程序员文章站
2023-11-30 21:01:34
本文实例为大家分享了python控制nao机器人身体动作的具体代码,供大家参考,具体内容如下
今天读的代码,顺便写了出来,与文档的对比,差不多。
impor...
本文实例为大家分享了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状态,这样操作来获得数据。后者操作性更强,但由于实际原因,用前者的可能性是最大的。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: 说说我理解的SEO优化关键词安插密度
下一篇: 三个步骤 让你的网站关键词密度更合理