robot - 如何从 Choregraphe 项目中打开/关闭自主生活
问题描述
自主生活可以从 Choregraphe 的 UI 中控制,也可以通过按机器人上的胸部按钮两次来控制,但是,如何从 Choregraphe 项目中做到这一点?在浏览了 Box Library 中的工具列表后,不清楚可以使用哪个工具。
当自主生命开启时,机器人为了看起来还活着,会用头部、手臂和腿做一些小动作。我正在发展的行为是微妙的,很难与自主生命运动区分开来,所以我试图让机器人在我的行为运行之前保持静止。
解决方案
ALAutonomousLife API 提供方法setState
在 Choregraph 中,您可以使用以下内容制作一个 python 框:
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
self.al = ALProxy("ALAutonomousLife")
def onLoad(self):
#put initialization code here
pass
def onUnload(self):
#put clean-up code here
pass
def onInput_onStart(self):
self.al.setState("disabled")
#self.onStopped() #activate the output of the box
pass
def onInput_onStop(self):
self.onUnload() #it is recommended to reuse the clean-up as the box is stopped
self.onStopped() #activate the output of the box
然后激活此框以禁用 AutonomousLife。
你也可以像这样在 python 控制台中测试它:
import naoqi
from naoqi import ALProxy
al = ALProxy("ALAutonomousLife", "pepper.local", 9559)
al.setState("diabled")
这将与按下胸部按钮两次具有相同的效果。
要仅禁用微妙的自主运动,请查看自主能力
setEnabled
提供了一种方法
推荐阅读
- react-native - 如何控制异步方法 react-native
- python - 如何在多索引熊猫的前几行上应用交集?
- java - 弹簧数据 | 使用排序生成错误的查询
- angular - 选择复选框时出错,包含多个图像
- wordpress - 根据运输类别和商品数量添加 Woocommerce 费用
- python - 有效地连接列表中元组中的两个字符串?
- swift - 如何将此 api 中的所有数据获取到 UITableView 中的 UILabels 中?
- python - 如何在 Python 中清除屏幕?
- google-chrome - 是否可以在 Google Chrome 开发者工具中更改标尺线的颜色?
- mongodb - 按时间、日期和月份对 mongodb 聚合进行排序