python自动计算机器人(python实现nao机器人手臂动作控制)
类别:脚本大全 浏览量:468
时间:2021-10-13 00:46:53 python自动计算机器人
python实现nao机器人手臂动作控制本文实例为大家分享了python实现nao机器人手臂动作的具体代码,供大家参考,具体内容如下
这些天依然在看nao公司文档的东西,把读过的代码顺手敲了出来。代码依然很简单,但是为什么我要写博客呢?这其中有很大的原因在于,代码是死的,可是读着读着就感觉代码活了,而且,每次读都会有不同的感受。咱就直接看正题吧。
|
#-*-encoding:utf-8-*- import sys import motion import almath from naoqi import alproxy def stiffnesson(proxy): #we use the body name to signify the collection of all jionts pname = "body" pstiffnesslists = 1.0 ptimelists = 1.0 proxy.stiffnessinterpolation(pname,pstiffnesslists,ptimelists) def main(robotip): ''' example showing a path of two position ''' try : motionproxy = alproxy( "almotion" ,robotip, 9559 ) except exception ,e: print "could not create a proxy to almotion" print str (e) try : postureproxy = alproxy( "alrobotposture" ,robotip, 9559 ) except exception ,e: print "could not create a proxy to alrobotposture" print str (e) #set the nao stiffness on stiffnesson(motionproxy) #set the nao to standinit postureproxy.gotoposture( "standinit" , 0.5 ) effector = "larm" space = motion.frame_robot # axis_mask_vel=7 axismask = almath.axis_mask_vel isabsolute = false #since we are in relative, the current position is zero currentpos = [ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ] #define the changes in relative to the current position dx = 0.03 #translation axis x dy = 0.03 #translation axis y dz = 0.00 #translation axis z dwx = 0.00 #rotation axis x dwy = 0.00 #rotation axis x dwz = 0.00 #rotation axis x targetpos = [dx,dy,dz,dwx,dwy,dwz] #go to the target and back again path = [targetpos,currentpos] times = [ 2.0 , 4.0 ] #seconds motionproxy.positioninterpolation(effector,space,path,axismask,times,isabsolute) if __name__ = = "__main()__" : robotip = "127.0.0.1" if len (sys.argv)< = 1 : print "use default :127.0.0.1" else : robotip = sys.argv[ 1 ] main(robotip) |
接下来是另一个:
|
#-*-encoding:utf-8-*- ''' cartesian control :arm trajectory example''' import sys import motion import almath from naoqi import alproxy def stiffnesson(proxy): pname = "body" pstiffnesslists = 1.0 ptimelists = 1.0 proxy.stiffnessinterpolation(pname,pstiffnesslists,ptimelists) def main(robotip): '''showing a hand ellipoid ''' try : motionproxy = alproxy( "alproxy" ,robotip, 9559 ) except exception,e: print "could not create a proxy " print "error was " ,e try : postureproxy = alproxy( "alrobotproxy" ,robotip, 9559 ) except exception ,e: print "could not create a proxy" print "error was" ,e #send nao in stiffness on setstiffnesson(motionproxy) #send nao to pose init postureproxy.gotoposture( "standinit" , 0.5 ) effector = "larm" space = motion.frame_robot path = [ [ 0.0 , - 0.05 , + 0.00 , 0.0 , 0.0 , 0.0 ], #pose1 [ 0.0 , + 0.00 , + 0.04 , 0.0 , 0.0 , 0.0 ], #pose2 [ 0.0 , + 0.04 , + 0.00 , 0.0 , 0.0 , 0.0 ], #pose3 [ 0.0 , + 0.00 , - 0.02 , 0.0 , 0.0 , 0.0 ], #pose4 [ 0.0 , - 0.05 , + 0.00 , 0.0 , 0.0 , 0.0 ], #pose5 [ 0.0 , + 0.00 , + 0.00 , 0.0 , 0.0 , 0.0 ] ] #pose6 axismask = 7 times = [ 0.5 , 1.0 , 2.0 , 3.0 , 4.0 , 4.5 ] #seconds isabsolute = false motionproxy.positioninterpolation(effector,space,path,axismask,times,isabsolute) if __name__ = = "__main__" : robotip = "127.0.0.1" if len (sys.argv)< = 1 : print "usage local ip " else : robotip = sys.argv[ 1 ] main(robotip) |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/u011181878/article/details/21392201
您可能感兴趣
- python爬取酷狗收费音乐(python爬取酷狗音乐排行榜)
- python一组数字求和(Python3数字求和的实例)
- python矩阵怎么生成(python实现矩阵打印)
- python微信窗口内容获取(python使用wxpy轻松实现微信防撤回的方法)
- python配合docker(Docker构建python Flask+ nginx+uwsgi容器)
- python爬虫并保存excel实例(Python实现爬取亚马逊数据并打印出Excel文件操作示例)
- python云服务技术(Python脚本修改阿里云的访问控制列表的方法)
- 如何对python中列表中的数据运算(Python3.5集合及其常见运算实例详解)
- python中生成字符串序列(python实现字符串加密 生成唯一固定长度字符串)
- python数字图像处理入门(python图像处理入门一)
- pythontime模块有哪些(Python3.5内置模块之time与datetime模块用法实例分析)
- python代码计算一个月多少天(Python计算时间间隔精确到微妙的代码实例)
- python format的用法(Python中format格式输出全解)
- python模块都是自己的语法(详解Python_shutil模块)
- 笨办法学python3目录(如何愉快地迁移到 Python 3)
- centos7上安装python(centos6.5安装python3.7.1之后无法使用pip的解决方案)
- 《小敏家》金波想要复婚 这只是他圈套的第1步,更可恶的在后面(小敏家金波想要复婚)
- 小敏家 剧情离谱一锅乱炖,但他们俩绝对是这部剧的一大 亮点(剧情离谱一锅乱炖)
- 《倚天屠龙记》再遭翻拍,关晓彤主演赵敏,蒋劲夫演张无忌,你怎么看(倚天屠龙记再遭翻拍)
- 吴启华与曾舜晞两代张无忌同框,戏里经典的他却没活出原著的潇洒(吴启华与曾舜晞两代张无忌同框)
- 经常发这三种 朋友圈 的人,要迅速屏蔽(经常发这三种朋友圈)
- 有种尴尬叫朋友圈忘屏蔽,大学生上演社死现场,父母亲自下场吐槽(有种尴尬叫朋友圈忘屏蔽)
热门推荐
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9