python实现nao机器人手臂动作控制
2014-03-17 15:58
676 查看
这些天依然在看nao公司文档的东西,把读过的代码顺手敲了出来。代码依然很简单,但是为什么我要写博客呢?这其中有很大的原因在于,代码是死的,可是读着读着就感觉代码活了,而且,每次读都会有不同的感受。咱就直接看正题吧。
接下来是另一个:
#-*-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)
#-*-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)
相关文章推荐
- python控制nao机器人身体动作实例
- python简单实现nao机器人身体躯干和腿部的动作
- Python简单实现控制电脑的方法
- linux下CPU利用率的控制(Python实现)
- ros controller控制diy手臂抓手开合,利用service实现角位距离相互转换的思路,实现真实抓取放置 sevice源码
- python实现键盘控制鼠标移动
- python实现远程通过网络邮件控制计算机重启或关机
- 手机控制电脑的一种思路(Python实现)
- 在安卓下控制基于树莓派的小车 皆用python实现
- 用Python实现nao机器人与RoboCup裁判盒间的通信
- Ubuntu安装pyenv实现python多版本控制
- python 用本地git来保存文件或者博客,实现版本控制
- python实现简单的用户密码登录控制(输入三次就锁定用户)
- 用树莓派实现RGB LED的颜色控制——Python版本
- Python实现利用socket连接adb控制android设备
- Python实现控制台中的进度条
- Python实现控制台中的进度条
- 使用python实现用微信远程控制电脑
- 在IE和MF中实现控制Enter键触发指定click动作
- Python设置Socket代理及实现远程摄像头控制的例子