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 相关文章推荐
phpsir 开发 一个检测百度关键字网站排名的python 程序
Sep 17 Python
使用Python中的cookielib模拟登录网站
Apr 09 Python
pandas多级分组实现排序的方法
Apr 20 Python
python顺序的读取文件夹下名称有序的文件方法
Jul 11 Python
python正则表达式去除两个特殊字符间的内容方法
Dec 24 Python
详解Python使用Plotly绘图工具,绘制甘特图
Apr 02 Python
python面向对象法实现图书管理系统
Apr 19 Python
python实现在多维数组中挑选符合条件的全部元素
Nov 26 Python
使用jupyter notebook直接打开.md格式的文件
Apr 10 Python
python实现腾讯滑块验证码识别
Apr 27 Python
解决numpy和torch数据类型转化的问题
May 23 Python
Python+Pillow+Pytesseract实现验证码识别
May 11 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
世界第一个无线广播电台 KDKA
2021/03/01 无线电
一个连接两个不同MYSQL数据库的PHP程序
2006/10/09 PHP
PHP的面试题集,附我的答案和分析(一)
2006/11/19 PHP
php防注
2007/01/15 PHP
追求程序速度,而不是编程的速度
2008/04/23 PHP
关于mysql字符集设置了character_set_client=binary 在gbk情况下会出现表描述是乱码的情况
2013/01/06 PHP
Nodejs实现的一个简单udp广播服务器、客户端
2014/09/25 NodeJs
javascript实现点击提交按钮后显示loading的方法
2015/07/03 Javascript
BACKBONE.JS 简单入门范例
2017/10/17 Javascript
element ui 表格动态列显示空白bug 修复方法
2018/09/04 Javascript
vue 项目地址去掉 #的方法
2018/10/20 Javascript
JavaScript中Dom操作实例详解
2019/07/08 Javascript
JavaScript中var的重要性实例分析
2019/07/09 Javascript
Jquery Datatables的使用详解
2020/01/30 jQuery
Python中类型关系和继承关系实例详解
2015/05/25 Python
python检查指定文件是否存在的方法
2015/07/06 Python
Python中属性和描述符的正确使用
2016/08/23 Python
Python排序算法之选择排序定义与用法示例
2018/04/29 Python
利用Python进行数据可视化常见的9种方法!超实用!
2018/07/11 Python
Python3实现的判断回文链表算法示例
2019/03/08 Python
Python批量生成幻影坦克图片实例代码
2019/06/04 Python
python实现while循环打印星星的四种形状
2019/11/23 Python
使用tensorboard可视化loss和acc的实例
2020/01/21 Python
matlab中二维插值函数interp2的使用详解
2020/04/22 Python
html5-websocket基于远程方法调用的数据交互实现
2012/12/04 HTML / CSS
亚瑟士美国官网:ASICS美国
2017/02/01 全球购物
璀璨的珍珠、密钉和个性化珠宝:Lily & Roo
2021/01/21 全球购物
元旦获奖感言
2014/03/08 职场文书
小学语文教学经验交流材料
2014/06/02 职场文书
三八活动策划方案
2014/08/17 职场文书
政法干警核心价值观心得体会
2014/09/11 职场文书
教师求职自荐信范文
2015/03/04 职场文书
专家推荐信范文
2015/03/26 职场文书
信息技术国培研修日志
2015/11/13 职场文书
python实现黄金分割法的示例代码
2021/04/28 Python
windows安装 redis 6.2.6最新步骤详解
2022/04/26 Redis