python控制nao機器人身體動作實例詳解
本文實例為大家分享了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中的數(shù)據(jù)了。這些數(shù)據(jù)是怎么獲得的?最大的可能就是在choregraph中3D視圖中測試得到,當然還有一種可能就是將choregraph與實體機連接,將機器人置于practice狀態(tài),這樣操作來獲得數(shù)據(jù)。后者操作性更強,但由于實際原因,用前者的可能性是最大的。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- Python實現(xiàn)企業(yè)微信機器人每天定時發(fā)消息實例
- Python調用釘釘自定義機器人的實現(xiàn)
- Python使用微信接入圖靈機器人過程解析
- 基于python的itchat庫實現(xiàn)微信聊天機器人(推薦)
- python實現(xiàn)機器人卡牌
- Python實現(xiàn)微信機器人的方法
- Python3從零開始搭建一個語音對話機器人的實現(xiàn)
- 基于Python的微信機器人開發(fā) 微信登錄和獲取好友列表實現(xiàn)解析
- Python實現(xiàn)微信翻譯機器人的方法
- Python qqbot 實現(xiàn)qq機器人的示例代碼
- python實現(xiàn)微信自動回復機器人功能
- 如何用Python做一個微信機器人自動拉群
- Python QQBot庫的QQ聊天機器人
- 使用python接入微信聊天機器人
- itchat-python搭建微信機器人(附示例)
- python實現(xiàn)微信機器人: 登錄微信、消息接收、自動回復功能
- 手把手教你使用Python創(chuàng)建微信機器人
- Python開發(fā)企業(yè)微信機器人每天定時發(fā)消息實例
相關文章
Matplotlib animation模塊實現(xiàn)動態(tài)圖
這篇文章主要介紹了Matplotlib animation模塊實現(xiàn)動態(tài)圖,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-02-02
Python 找出出現(xiàn)次數(shù)超過數(shù)組長度一半的元素實例
這篇文章主要介紹了Python 找出出現(xiàn)次數(shù)超過數(shù)組長度一半的元素實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
Python無參裝飾器的實現(xiàn)方案及優(yōu)化
裝飾器(Decorators)是 Python 的一個重要部分,所謂裝飾器就是閉包函數(shù)的一種應用場景,這篇文章主要給大家介紹了關于Python無參裝飾器的相關資料,需要的朋友可以參考下2021-08-08

