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内置的字符串处理函数整理
Jan 29 Python
Python计算三维矢量幅度的方法
Jun 15 Python
python 实时遍历日志文件
Apr 12 Python
Python调用ctypes使用C函数printf的方法
Aug 23 Python
微信小程序跳一跳游戏 python脚本跳一跳刷高分技巧
Jan 04 Python
python使用mysql的两种使用方式
Mar 07 Python
python3库numpy数组属性的查看方法
Apr 17 Python
python获取当前文件路径以及父文件路径的方法
Jul 10 Python
Django使用中间键实现csrf认证详解
Jul 22 Python
python 遍历pd.Series的index和value
Nov 26 Python
python ffmpeg任意提取视频帧的方法
Feb 21 Python
解决keras模型保存h5文件提示无此目录问题
Jul 01 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/08/08 PHP
PHP 如何利用phpexcel导入数据库
2013/08/24 PHP
Parse正式发布开源PHP SDK
2014/08/11 PHP
php实现改变图片直接打开为下载的方法
2015/04/14 PHP
form表单传递数组数据、php脚本接收的实例
2017/02/09 PHP
详解laravel passport OAuth2.0的4种模式
2019/11/04 PHP
PHP笛卡尔积实现原理及代码实例
2020/12/09 PHP
JavaScript中prototype为对象添加属性的误区介绍
2013/10/15 Javascript
JavaScript设计模式之观察者模式(发布者-订阅者模式)
2014/09/24 Javascript
2014年最火的Node.JS后端框架推荐
2014/10/27 Javascript
bootstrap改变按钮加载状态
2014/12/01 Javascript
JavaScript正则表达式替换字符串中图片地址(img src)的方法
2017/01/13 Javascript
lhgcalendar时间插件限制只能选择三个月的实现方法
2017/07/03 Javascript
angularjs利用directive实现移动端自定义软键盘的示例
2017/09/20 Javascript
vue.js开发实现全局调用的MessageBox组件实例代码
2017/11/22 Javascript
微信小程序实现分享到朋友圈功能
2018/07/19 Javascript
优雅的将ElementUI表格变身成树形表格的方法步骤
2019/04/11 Javascript
利用百度echarts实现图表功能简单入门示例【附源码下载】
2019/06/10 Javascript
node express使用HTML模板的方法示例
2019/08/22 Javascript
javascript实现点击星星小游戏
2019/12/24 Javascript
原生js canvas实现鼠标跟随效果
2020/08/02 Javascript
Vue自定义全局弹窗组件操作
2020/08/11 Javascript
[19:14]DOTA2 HEROS教学视频教你分分钟做大人-维萨吉
2014/06/24 DOTA
Python多线程编程(二):启动线程的两种方法
2015/04/05 Python
python中(str,list,tuple)基础知识汇总
2018/02/20 Python
Python随机函数库random的使用方法详解
2019/08/21 Python
Pytorch 计算误判率,计算准确率,计算召回率的例子
2020/01/18 Python
使用python matploblib库绘制准确率,损失率折线图
2020/06/16 Python
Python如何读写二进制数组数据
2020/08/01 Python
python批量生成条形码的示例
2020/10/10 Python
HTML5 Canvas 实现圆形进度条并显示数字百分比效果示例
2017/08/18 HTML / CSS
美国的Eastbay旗下的运动款子品牌:Final-Score
2018/01/01 全球购物
成人毕业生自我鉴定
2013/10/18 职场文书
2014年化验员工作总结
2014/11/18 职场文书
聚会通知怎么写
2015/04/23 职场文书
HTML+css盒子模型案例(圆,半圆等)“border-radius” 简单易上手
2021/05/10 HTML / CSS