python控制nao机器人身体动作实例详解


Posted in Python onApril 29, 2019

本文实例为大家分享了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中的数据了。这些数据是怎么获得的?最大的可能就是在choregraph中3D视图中测试得到,当然还有一种可能就是将choregraph与实体机连接,将机器人置于practice状态,这样操作来获得数据。后者操作性更强,但由于实际原因,用前者的可能性是最大的。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python中使用Tkinter模块创建GUI程序实例
Jan 14 Python
在Python下使用Txt2Html实现网页过滤代理的教程
Apr 11 Python
Django中对通过测试的用户进行限制访问的方法
Jul 23 Python
python中OrderedDict的使用方法详解
May 05 Python
python获取代理IP的实例分享
May 07 Python
python使用turtle绘制分形树
Jun 22 Python
python内置数据类型之列表操作
Nov 12 Python
运用Python的webbrowser实现定时打开特定网页
Feb 21 Python
Python大数据之使用lxml库解析html网页文件示例
Nov 16 Python
Django创建一个后台的基本步骤记录
Oct 02 Python
matplotlib制作雷达图报错ValueError的实现
Jan 05 Python
python中用Scrapy实现定时爬虫的实例讲解
Jan 18 Python
python实现nao机器人身体躯干和腿部动作操作
Apr 29 #Python
解决Python找不到ssl模块问题 No module named _ssl的方法
Apr 29 #Python
GitHub 热门:Python 算法大全,Star 超过 2 万
Apr 29 #Python
python实现nao机器人手臂动作控制
Apr 29 #Python
python机器人运动范围问题的解答
Apr 29 #Python
浅谈Python3中strip()、lstrip()、rstrip()用法详解
Apr 29 #Python
Python 实现微信防撤回功能
Apr 29 #Python
You might like
php生成缩略图填充白边(等比缩略图方案)
2013/12/25 PHP
PHP实现在数据库百万条数据中随机获取20条记录的方法
2017/04/19 PHP
使用JQuery和s3captche实现一个水果名字的验证
2009/08/14 Javascript
js 获取radio按钮值的实例
2013/08/17 Javascript
js 动态修改css文件用到了cssRule
2014/08/20 Javascript
jQuery中:nth-child选择器用法实例
2014/12/31 Javascript
jQuery实现在列表的首行添加数据
2015/05/19 Javascript
JavaScript通过事件代理高亮显示表格行的方法
2015/05/27 Javascript
JavaScript File API实现文件上传预览
2016/02/02 Javascript
jQuery实现的表格展开伸缩效果实例
2016/09/07 Javascript
node.js报错:Cannot find module 'ejs'的解决办法
2016/12/14 Javascript
js实现本地图片文件拖拽效果
2017/07/18 Javascript
vue-cli启动本地服务局域网不能访问的原因分析
2018/01/22 Javascript
jQuery实现日历效果
2020/09/11 jQuery
python 判断自定义对象类型
2009/03/21 Python
跟老齐学Python之模块的加载
2014/10/24 Python
python内存管理分析
2015/04/08 Python
python操作redis的方法
2015/07/07 Python
PyQt5每天必学之进度条效果
2018/04/19 Python
Django + Uwsgi + Nginx 实现生产环境部署的方法
2018/06/20 Python
python 实现得到当前时间偏移day天后的日期方法
2018/12/31 Python
pyqt实现.ui文件批量转换为对应.py文件脚本
2019/06/19 Python
Python  Django 母版和继承解析
2019/08/09 Python
python3 xpath和requests应用详解
2020/03/06 Python
pytorch 计算ConvTranspose1d输出特征大小方式
2020/06/23 Python
德国珠宝和手表在线商店:VALMANO
2019/03/24 全球购物
Schecker荷兰:狗狗用品和配件
2019/06/06 全球购物
绢花、人造花和人造花卉:BLOOM
2019/08/07 全球购物
司机岗位职责
2013/11/15 职场文书
小学生感恩老师演讲稿
2014/08/28 职场文书
安全生产工作汇报
2014/10/28 职场文书
2014年信用社工作总结
2014/11/25 职场文书
熟背这些句子,让您的英语口语突飞猛进(135句)
2019/09/06 职场文书
python中pandas对多列进行分组统计的实现
2021/06/18 Python
为什么MySQL 删除表数据 磁盘空间还一直被占用
2021/10/16 MySQL
css清除浮动clearfix:after的用法详解(附完整代码)
2023/05/21 HTML / CSS