《NAO机器人程序设计》—第四章 运动控制
Nao机器人—Choregraphe

关节名

机器人边走边说话

moveInit():运动进程的初始化,检查机器人的当前状态,并选择一个正确的姿势,阻塞调用。
moveTo():移动到指定坐标位置,阻塞调用。
【moveInit()为阻塞调用方法,完成机器人行走前的准备动作。例如,如果机器人初始状态为休息状态,调用moveInit方法后,机器人进入准备行走状态(站立、屈膝)。moveInit方法的最长执行时间会超过1s,方法执行完成后,才会执行moveTo()方法。】
【moveTo()为阻塞调用方法,使用post对象调用moveTo()方法,将创建新的并行线程,在新线程中调用moveTo()方法,原线程继续调用后面的say()方法。】
程序执行结果:机器人一边向前走,一边说I’m walking ,在0.5m处停止。

ALRobotPosture模块

ALMotion模块–刚度

#刚度设置1
import time
class MyClass(GeneratedClass):def __init__(self):GeneratedClass.__init__(self)#代表ALMotion模块self.motion=ALProxy("ALMotion")def onLoad(self):#put initialization code herepassdef onUnload(self):#put clean-up code herepassdef onInput_onStart(self):#唤醒机器人,各关节关节刚度设置为1self.motion.wakeUp()jointName="Body"#获取body的刚度包括26个元素的列表stiffnesses=self.motion.getStiffnesses(jointName)self.logger.info(stiffnesses)self.motion.rest()stiffnesses=self.motion.getStiffnesses(jointName)self.logger.info(stiffnesses)names="Head"stiffness=0.5self.motion.setStiffnesses(names,stiffness)time.sleep(1.0)stiffnesseses=self.motion.getStiffnesses(jointName)self.logger.info(stiffnesses)passdef onInput_onStop(self):self.onUnload() #it is recommended to reuse the clean-up as the box is stoppedself.onStopped() #activate the output of the box

结果

#####---刚度设置2
import time
class MyClass(GeneratedClass):def __init__(self):GeneratedClass.__init__(self)#代表ALMotion模块self.motion=ALProxy("ALMotion")self.posture=ALProxy("ALRobotPosture")def onLoad(self):#put initialization code herepassdef onUnload(self):#put clean-up code herepassdef onInput_onStart(self):#self.onStopped() #activate the output of the boxself.posture.goToPosture("Crouch",1.0)jointName="Head"names=['HeadYaw']stiffnessLists=[0.25,0.5,1.0,0.0]timeLists=[1.0,2.0,3.0,4.0]self.motion.post.stiffnessInterpolation(names,stiffnessLists,timeLists)      for i in range(5):stiffnesses = self.motion.getStiffnesses(jointName)self.logger.info(stiffnesses)time.sleep(1.0)passdef onInput_onStop(self):self.onUnload() #it is recommended to reuse the clean-up as the box is stoppedself.onStopped() #activate the output of the box

结果:

NAO使用刚度控制电机最大电流。电机的转矩(驱动力)与电流相关,设置关节的刚度相当于设置电机的转矩限制。

刚度为0.0,关节位置不受电机控制,关节是自由的。
刚度为1.0,关节使用最大转矩功率转到指定位置。
刚度为0.0~1.0,关节电机的转矩介于0与最大值之间(如果关节移动到目标位置所需要的转矩高于刚度的限制,关节不会到达目标位置)。

ALMotion模块–关节
关节控制方法:
(1)插值法,阻塞调用
(2)反应式法,非阻塞调用

#########---控制关节(头部左转30°)
import time
import almath
class MyClass(GeneratedClass):def __init__(self):GeneratedClass.__init__(self)self.motion = ALProxy("ALMotion")def onLoad(self):#put initialization code herepassdef onUnload(self):#put clean-up code herepassdef onInput_onStart(self):#self.onStopped() #activate the output of the boxself.motion.setStiffnesses("Head",1.0)names="HeadYaw"angles=30.0*almath.TO_RADfractionMaxSpeed=0.1self.motion.setAngles(names,angles,fractionMaxSpeed)time.sleep(3.0)self.motion,setStiffnesses("Head",0.0)passdef onInput_onStop(self):self.onUnload() #it is recommended to reuse the clean-up as the box is stoppedself.onStopped() #activate the output of the box

almath是NAOqi系统提供的数学函数库,almath.TO__RAD为1度所对应的弧度数,在关节控制方法中,目标角度都以弧度为单位,本例及以后示例中,目标角度都用角度X1度对应弧度数形式表示。setAngles()方法为非阻塞调用方法,本例中转头动作后面的语句将头部刚度设置为0,因此调用setAngles()方法时需要使用延时。

小插曲:
almath有1.6.6, 1.6.7, 1.6.8, 1.6.12, 1.6.13, 1.6.14, 1.6.15, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.8.3这几个版本
经实测 pip install almath==1.6.8 -i https://pypi.tuna.tsinghua.edu.cn/simple

#######-----头部插值运动
import time
import almath
class MyClass(GeneratedClass):def __init__(self):GeneratedClass.__init__(self)self.motion = ALProxy("ALMotion")def onLoad(self):#put initialization code herepassdef onUnload(self):#put clean-up code herepassdef onInput_onStart(self):#self.onStopped() #activate the output of the boxself.motion.setStiffnesses("Head",1.0)names="HeadYaw"angleLists=50.0*almath.TO_RADtimeLists=1.0isAbsolute=Trueself.motion.angleInterpolation(names,angleLists,timeLists,isAbsolute)timeLists.sleep(1.0)names="HeadYaw"angleLists=[30.0*almath.TO_RAD,0.0]timeLists=[1.0,2.0]isAbsolute=Trueself.motion.angleInterpolation(names,angleLists,timeLists,isAbsolute)time.sleep(1.0)names=["HeadYaw","HeadPitch"]angleLists=[30.0*almath.TO_RAD,30.0*almath.TO_RAD]timeLists=[1.0,1.2]isAbsolute=Trueself.motion.angleInterpolation(names,angleLists,timeLists,isAbsolute)angleLists=[[50.0*almath.TO_RAD,0.0],[-30.0*almath.TO_RAD,30.0*almath.TO_RAD,0.0]]timeLists=[1.0,1.2]isAbsolute=Trueself.motion.angleInterpolation(names,angleLists,timeLists,isAbsolute)self.motion.setStiffnesses("Head",1.0)passdef onInput_onStop(self):self.onUnload() #it is recommended to reuse the clean-up as the box is stoppedself.onStopped() #activate the output of the box

angleInterpolation()方法为阻塞调用方法,在完成当前语句后,才执行下一条语句。程序执行结果为:
1.头部左转50°,延时1s ;
2.右转20°(绝对30°),右转30°(绝对0°);
3.左转30°低头30°(两个关节同时运动);
4.左转20°仰头60°(绝对左转50°,仰头30°,两个关节同时运动),
右转50°低头60°(绝对右转0°,低头 30°,两个关节同时运动),
仰头30°(绝对0°)。

《NAO机器人程序设计》---第四章 运动控制相关推荐

  1. JavaScript 高级程序设计第四章解读,总结。

    第四章 变量,作用域与内存 通过变量使用原始值 - 1. 原始值与引用值+ 原始值: 最简单的数据+ 引用值: 多个值构成的对象 - 2. 原始值有哪些+ Undefined Null Boolean ...

  2. JavaScript高级程序设计 第四章---变量 作用域 内存

    第四章-变量 作用域 内存 关键字:变量 作用域 内存 本章内容 通过变量使用原始值与引用值 理解执行上下文 理解垃圾回收 4.1 原始值与引用值 ECMAScript 变量可以包含两种不同类型的数据 ...

  3. PL/SQL程序设计 第四章 游标的使用

    在 PL/SQL 程序中,对于处理多行记录的事务经常使用游标来实现. §4.1 游标概念 为了处理 SQL 语句,ORACLE 必须分配一片叫上下文( context area )的区域来处理所必需的 ...

  4. c语言程序设计 第四章 总结

      分支结构程序设计 输入三角形的三边,判断能否构成三角形,如果能构成三角形,计算三角形的面积.不能则不能构成三角形. 例[4.1] #include<stdio.h> #include& ...

  5. 读书笔记 - js高级程序设计 - 第四章 变量 作用域 和 内存问题

    5种基本数据类型 可以直接对值操作 判断引用类型 var result = instanceof Array 执行环境 每个执行环境都有一个与之关联的变量对象,环境中定义的所有变量和函数都保存在这个对 ...

  6. 谭浩强《C++程序设计》书后习题 第十三章-第十四章

    2019独角兽企业重金招聘Python工程师标准>>> 最近要复习一下C和C++的基础知识,于是计划把之前学过的谭浩强的<C程序设计>和<C++程序设计>习题 ...

  7. c语言第四章循环程序设计,C语言程序设计教程第4章-循环结构程序设计

    <C语言程序设计教程第4章-循环结构程序设计>由会员分享,可在线阅读,更多相关<C语言程序设计教程第4章-循环结构程序设计(42页珍藏版)>请在人人文库网上搜索. 1.C语言程 ...

  8. c语言程序构造数据类型问题,C语言程序设计课程课件之第四章简单构造数据类型.ppt...

    C语言程序设计课程课件之第四章简单构造数据类型 第四章 简单构造数据类型 目录 4.1 一维数组 4.2 二维数组 4.3 字符数组 4.4 数组与指针 4.5 数组及指针作为函数参数 4.1 一维数 ...

  9. 04737 c++ 自学考试2019版 第四章课后练习 程序设计题 2

    /* * 04737 c++ 自学考试2019版 第四章课后练习 * 程序设计题 2 * 需求:为第二章习题设计中的二维坐标系下的类point,重载<< >> */ //标准流 ...

最新文章

  1. ExecutorService(任务调度器)详解
  2. 巧用组策略技术禁用办公室QQ聊天
  3. Python3序列解包
  4. 343. Integer Break
  5. 一个用于 Angular 开发的 Chrome 扩展 - Angular Dev Tools
  6. oracle编写备份数据库代码,oracle_oracle数据库创建备份与恢复脚本整理,1:创建用户 复制代码 代码如 - phpStudy...
  7. Linux 系统服务管理器(初始化系统/init system) -- systemd 及命令 systemctl 的详细介绍
  8. 服务器pg信号指的是什么信号,关于atx电源PG信号检测和分析
  9. 学术 | 基于深度学习的图像边缘和轮廓提取方法介绍
  10. 正则表达式的使用,python正则匹配一个话题标签
  11. 测试一下Windows Live Writer能否正常使用。
  12. activity中获取fragment布局_安卓开发入门教程Fragment
  13. ami编码设计流程图_专用设备转向系统电控单元设计
  14. 计算机组成原理—高速缓冲存储器
  15. 机器学习 什么是Cross Entropy 交叉熵
  16. python剔除异常值的方法_二维d异常值的剔除方法
  17. ADO.NET 连接MySQL 8.0.23
  18. C语言程序_更改文件名后缀
  19. 搜索引擎原理第二阶段之预处理
  20. VBA--LBound函数与UBound函数用法详解

热门文章

  1. [从头读历史] 第281节 始制文字 世界上的语系及语言
  2. 〖Python 数据库开发实战 - MongoDB篇②〗- Mac环境下的MongoDB数据库安装
  3. vue中循环图片不显示问题
  4. linux开机卡在usb,UUI v1.9.7.3 轻松制作 Linux 版 USB 开机随身碟、记忆卡(Universal USB Installer)...
  5. Bootstrap CSS Layout (1) - Breakpoint
  6. 如何解锁CourseHero文档
  7. C语言中函数参数传递的方式:值传递,地址传递
  8. OPC 、OPC DA、OPC UA介绍
  9. 最新博客地址转移https://bravoing.github.io/
  10. vue 符号..._如何在Windows 8.1上输入和使用表情符号