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中List.index()方法的使用教程
May 20 Python
python僵尸进程产生的原因
Jul 21 Python
python如何让类支持比较运算
Mar 20 Python
pytorch训练imagenet分类的方法
Jul 27 Python
windows7 32、64位下python爬虫框架scrapy环境的搭建方法
Nov 29 Python
分享Python切分字符串的一个不错方法
Dec 14 Python
Python Numpy 实现交换两行和两列的方法
Jun 26 Python
python列表每个元素同增同减和列表元素去空格的实例
Jul 20 Python
使用OpenCV-python3实现滑动条更新图像的Canny边缘检测功能
Dec 12 Python
python的slice notation的特殊用法详解
Dec 27 Python
pytorch中的上采样以及各种反操作,求逆操作详解
Jan 03 Python
keras 权重保存和权重载入方式
May 21 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
Zend Framework教程之Bootstrap类用法概述
2016/03/14 PHP
详解PHP编码转换函数应用技巧
2016/10/22 PHP
PHP解耦的三重境界(浅谈服务容器)
2017/03/13 PHP
PHP 99乘法表的几种实现代码
2020/10/13 PHP
arguments对象
2006/11/20 Javascript
Javascript 面向对象 命名空间
2010/05/13 Javascript
jQuery拖动图片删除示例
2013/05/10 Javascript
node.js中的fs.close方法使用说明
2014/12/17 Javascript
javascript实现checkBox的全选,反选与赋值
2015/03/12 Javascript
基于SpringMVC+Bootstrap+DataTables实现表格服务端分页、模糊查询
2016/10/30 Javascript
使用contextMenu插件实现Bootstrap table弹出右键菜单
2017/02/20 Javascript
Vue2.0父子组件传递函数的教程详解
2017/10/16 Javascript
javascript将非数值转换为数值
2018/09/13 Javascript
vue 实现锚点功能操作
2020/08/10 Javascript
[01:00:12]2018DOTA2亚洲邀请赛 4.7 淘汰赛 VP vs LGD 第一场
2018/04/09 DOTA
在Linux命令行终端中使用python的简单方法(推荐)
2017/01/23 Python
回调函数的意义以及python实现实例
2017/06/20 Python
python数据结构之链表的实例讲解
2017/07/25 Python
python3 unicode列表转换为中文的实例
2018/10/26 Python
pytorch中tensor张量数据类型的转化方式
2019/12/31 Python
Tensorflow中的dropout的使用方法
2020/03/13 Python
Python Tricks 使用 pywinrm 远程控制 Windows 主机的方法
2020/07/21 Python
学会迭代器设计模式,帮你大幅提升python性能
2021/01/03 Python
Python中正则表达式对单个字符,多个字符和匹配边界等使用
2021/01/27 Python
利用纯CSS3实现文字向右循环闪过效果实例(可用于移动端)
2017/06/15 HTML / CSS
英国Amara家居法国网站:家居装饰,现代装饰和豪华礼品
2016/12/15 全球购物
Perfume’s Club法国站:购买香水和化妆品
2019/05/02 全球购物
文明餐桌活动方案
2014/02/11 职场文书
社区服务活动总结
2014/05/07 职场文书
车辆委托书范本
2014/10/05 职场文书
党支部先进事迹材料
2014/12/24 职场文书
环境建议书
2015/02/04 职场文书
英语专业毕业论文答辩开场白
2015/05/27 职场文书
聘任合同书
2015/09/21 职场文书
总结一些Java常用的加密算法
2021/06/11 Java/Android
优化Mysql查询的示例
2022/04/26 MySQL