使用Wonder Workshop机器人的PythonAPI
Wonder的Python项目详细描述
奇妙的
这是一个alpha状态项目,将wonderworkshop机器人的实时控制带到python中。
为了充分利用这一点,您应该已经对python和命令行有了初步的熟悉。
项目状态
在“alpha”版本中。它已经准备好供那些愿意忍受比人们所希望的更粗糙边缘的人试用,理想情况下,他们可以提供建设性的批评。
请参阅"Issues" in github以获取已知错误和待办事项的最新列表。
设置
先决条件
- MacOS
- 熟悉python和命令行工具
创建新的python虚拟环境
virtualenv --python=/usr/bin/python2.7 --no-site-packages venv
source venv/bin/activate
安装依赖项
不幸的是,adafruit btle包没有托管在pypi上,这使得通过pip安装此包时很难自动安装。另外,这个项目需要WonderWorkshop提供的一个项目分支,截至本文撰写时,它还没有合并回主项目中。
pip install git+git://github.com/playi/Adafruit_Python_BluefruitLE@928669a#egg=Adafruit_BluefruitLE
安装Wonderpy
pip install WonderPy
文档
文档还处于alpha阶段。
入门
以上步骤安装核心库。
在github存储库中有许多单独使用它的例子playi/WonderPyExamples。
it是highly建议查看这些示例。
要测试基本功能,请在命令行中,在新鲜的virtualenv中运行这些命令:
下载“01\u hello\u world.py”教程示例:curl -o 01_hello_world.py https://raw.githubusercontent.com/playi/WonderPyExamples/master/tutorial/01_hello_world.py
运行:python 01_hello_world.py
它应该连接到附近的任何机器人并打招呼!
机器人连接选项
一旦启动任何一个例子,应用程序将扫描机器人至少5秒,最多20秒。扫描后,将连接信号强度(rssi)最高的机器人。这是连接最接近机器人的合理近似值。
连接选项:
[--connect-type cue | dot | dash]
filter for robots of the specified type/s
[--connect-name MY_ROBOT | MY_OTHER_ROBOT | ...]
filter for robots with the specified name/s
[--connect-eager]
connect as soon as a qualified robot is discovered.
do not wait the full scanning period.
if there are more than one robot with matching criteria,
the one with the best signal is still selected
[--connect-ask]
show a list of available robots, and interactively ask for input.
indicates which has the highest signal strength.
连接示例:
花5秒钟寻找所有名为“sammy”或“sally”的提示和冲刺机器人,并连接到信号强度最好的机器人:
python demos/roboFun.py --connect-type cue dash --connect-name sammy blippy sally
尽快连接到任何名为“猎户座机器人”的机器人,无论它是哪种类型的机器人。
python demos/roboFun.py --connect-eager --connect-name "orions robot"
已知问题和待办事项
有关已知错误和待办事项的最新列表,请参见"Issues" in github。
在撰写本文时,尚未解决的问题是:
- 只适用于单个机器人。
- 仅适用于python2.7。
这里的限制因素是让adafruit btle包在python3下运行。有证据表明这是可能的。 - 在python3下,更新并发模型。
- 充实内联文档。
- 使pip安装更加标准。 目前,这需要手动安装adafruit包中基于github的fork。
- 到Windows、Linux的端口
贡献
欢迎拉取请求!
请查看WonderPy repository on github上的问题和待办事项列表。
WonderPyExamples repository中的其他示例也很好:
- 与其他酷炫软件包的集成
- 物联网集成
- 使用草图工具包附件演示
api的功能请求应该作为new Issues in github发送。
获取帮助
报告错误
如果api有一个特定的bug或问题,请检查outstanding issues in github,如果它还没有被覆盖,请创建一个新的。
征求意见
如果你有一个更一般的问题,比如“我该怎么做……”或者你有一个你想分享的提示,请访问stackoverflow,并确保用won标记你的帖子DerWorkshop。
请求功能
api的功能请求应该作为new Issues in github发送。
分享你的工作?
做了点酷的东西?我们很想看!
将照片、视频和链接发送到developers@makewonder.com。
(注意,我们不能保证回复所有电子邮件)