python控制nao機(jī)器人身體動(dòng)作實(shí)例詳解
本文實(shí)例為大家分享了python控制nao機(jī)器人身體動(dòng)作的具體代碼,供大家參考,具體內(nèi)容如下
今天讀的代碼,順便寫(xiě)了出來(lái),與文檔的對(duì)比,差不多。
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)
實(shí)例二,控制左右胳膊
#-*-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視圖中測(cè)試得到,當(dāng)然還有一種可能就是將choregraph與實(shí)體機(jī)連接,將機(jī)器人置于practice狀態(tài),這樣操作來(lái)獲得數(shù)據(jù)。后者操作性更強(qiáng),但由于實(shí)際原因,用前者的可能性是最大的。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Python實(shí)現(xiàn)企業(yè)微信機(jī)器人每天定時(shí)發(fā)消息實(shí)例
- Python調(diào)用釘釘自定義機(jī)器人的實(shí)現(xiàn)
- Python使用微信接入圖靈機(jī)器人過(guò)程解析
- 基于python的itchat庫(kù)實(shí)現(xiàn)微信聊天機(jī)器人(推薦)
- python實(shí)現(xiàn)機(jī)器人卡牌
- Python實(shí)現(xiàn)微信機(jī)器人的方法
- Python3從零開(kāi)始搭建一個(gè)語(yǔ)音對(duì)話(huà)機(jī)器人的實(shí)現(xiàn)
- 基于Python的微信機(jī)器人開(kāi)發(fā) 微信登錄和獲取好友列表實(shí)現(xiàn)解析
- Python實(shí)現(xiàn)微信翻譯機(jī)器人的方法
- Python qqbot 實(shí)現(xiàn)qq機(jī)器人的示例代碼
- python實(shí)現(xiàn)微信自動(dòng)回復(fù)機(jī)器人功能
- 如何用Python做一個(gè)微信機(jī)器人自動(dòng)拉群
- Python QQBot庫(kù)的QQ聊天機(jī)器人
- 使用python接入微信聊天機(jī)器人
- itchat-python搭建微信機(jī)器人(附示例)
- python實(shí)現(xiàn)微信機(jī)器人: 登錄微信、消息接收、自動(dòng)回復(fù)功能
- 手把手教你使用Python創(chuàng)建微信機(jī)器人
- Python開(kāi)發(fā)企業(yè)微信機(jī)器人每天定時(shí)發(fā)消息實(shí)例
相關(guān)文章
Matplotlib animation模塊實(shí)現(xiàn)動(dòng)態(tài)圖
這篇文章主要介紹了Matplotlib animation模塊實(shí)現(xiàn)動(dòng)態(tài)圖,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02
Python爬蟲(chóng)爬取ts碎片視頻+驗(yàn)證碼登錄功能
這篇文章主要介紹了Python爬蟲(chóng)爬取ts碎片視頻+驗(yàn)證碼登錄功能,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02
Python實(shí)現(xiàn)發(fā)送QQ郵件的封裝
這篇文章主要為大家詳細(xì)介紹了Python實(shí)現(xiàn)發(fā)送QQ郵件的具體代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
Python 找出出現(xiàn)次數(shù)超過(guò)數(shù)組長(zhǎng)度一半的元素實(shí)例
這篇文章主要介紹了Python 找出出現(xiàn)次數(shù)超過(guò)數(shù)組長(zhǎng)度一半的元素實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-05-05
Python利用lxml庫(kù)實(shí)現(xiàn)XML處理
lxml庫(kù)是Python中處理XML和HTML文檔的強(qiáng)大庫(kù),提供了豐富的API以進(jìn)行各種操作,本文將討論如何使用lxml庫(kù),包括如何創(chuàng)建XML文檔,如何使用XPath查詢(xún),以及如何解析大型XML文檔,需要的可以參考下2023-08-08
Windows下安裝python2.7及科學(xué)計(jì)算套裝
這篇文章主要向大家介紹的是在windows系統(tǒng)下安裝python 2.7以及numpy安裝、six安裝、dateutil安裝、pyparsing安裝、matplotlib安裝和scipy安裝的方法,分享給大家,需要的小伙伴可以參考下,相對(duì)來(lái)說(shuō),windows下的安裝還是比較簡(jiǎn)單的。2015-03-03
Python無(wú)參裝飾器的實(shí)現(xiàn)方案及優(yōu)化
裝飾器(Decorators)是 Python 的一個(gè)重要部分,所謂裝飾器就是閉包函數(shù)的一種應(yīng)用場(chǎng)景,這篇文章主要給大家介紹了關(guān)于Python無(wú)參裝飾器的相關(guān)資料,需要的朋友可以參考下2021-08-08
Python面向?qū)ο笤砼c基礎(chǔ)語(yǔ)法詳解
這篇文章主要介紹了Pyhton面向?qū)ο笤砼c基礎(chǔ)語(yǔ)法,結(jié)合實(shí)例形式分析了Python面向?qū)ο蟪绦蛟O(shè)計(jì)中的基本原理、概念、語(yǔ)法與相關(guān)使用技巧,需要的朋友可以參考下2020-01-01

