服务器之家

服务器之家 > 正文

python程序控制NAO机器人行走

时间:2021-06-21 00:28     来源/作者:Earl_Martin

最近重新学习nao的官方文档,写点简单的程序回顾一下。主要是用python调用api,写下来保存着。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'''walk:small example to make nao walk'''
import sys
import motion
import time
from naoqi import alproxy
def stiffnesson(proxy):
 #we use the 'body' to signify the collection of all joints
 pname="body"
 pstiffnesslists=1.0
 ptimelists=1.0
 proxy.stiffnessinterpolation(pname,pstiffnesslists,ptimelists)
 
 def main(robotip):
  #init proxies
  try:
   motionproxy=alproxy("almotion",robotip,9559)
  except exception,e:
   print "could not create proxy to almotion"
   print"error was",e
 
  try:
   postureproxy=alproxy("alrobotposture",robotip,9559)
  except exception,e:
   print"could not create proxy to alrobotposture"
   print "error is ",e
 
   #set nao in stiffness on
   stiffnesson(motionproxy)
 
   #send nao to pose init
   postureproxy.gotoposture("standinit",0.5);
 
   #eable arms control by walk algorithm
   motionproxy.setwalkarmseable(true,true)
   #foot contact protection
   motionproxy.setmotionconfig([["enable_foot_contact_protection",true]])
 
   #target velocity
   x=-0.5 #backward
   y=0.0
   theta=0.0
   frequency=0.0#low speed
   motionproxy.setwalktargetvelocity(x,y.theta,frequency)
   time.sleep(4.0)
 
   #target velocity
   x=0.9
   y=0.0
   theta=0.0
   frenqency=1.0#max speed
   motionproxy.setwalktargetvelocity(x,y,theta,frenquency)
   time.sleep(2.0)
 
   #arms user motion
   #arms motion from user have alwalys priority than walk arms motion
   joinnames=["lshouderpitch","lshouderroll","lelbowyaw","lelbowroll"]
   arm1=[-40,25,0,-40]
   arm1=[x*motion.to_rad for x in aram1]
   
   arm2=[-40,50,0,-80]
   arm2=[x*motion.to_rad for x in aram2]
 
   pfractionmaxspeed=0.6
 
   motionproxy.angleinterpolationwithspeed(joinnames,arms1,pfractionmaxspeed)
   motionproxy.angleinterpolationwithspeed(joinnames,arms2,pfractionmaxspeed)
   motionproxy.angleinterpolationwithspeed(joinnames,arms1,pfractionmaxspeed)
 
   #end walk
   x=0.0
   y=0.0
   theta=0.0
   motionproxy.setwalktargetvelocity(x,y,theta,frequency)
 
if __name__=="__main__":
 robotip="192.168.1.155"
 if len(sys.argv)<=1:
  print "useage pyhton motion_walk.py robotip,default is 127.0.0.1"
 else:
   robotip=sys.argv[1]
 main(robotip)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/u011181878/article/details/21048959

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
2021德云社封箱演出完整版 2021年德云社封箱演出在线看
2021德云社封箱演出完整版 2021年德云社封箱演出在线看 2021-03-15
返回顶部