codelabclub / codelab_adapter_extensions Goto Github PK
View Code? Open in Web Editor NEWcodelab_adapter extensions
License: GNU General Public License v3.0
codelab_adapter extensions
License: GNU General Public License v3.0
@陆春锐 给出了解决方案
正在開發一款Adapter Extension, 其中有一條command是利用while循環從opencv capture攝像頭的畫面數據。 問題是一旦執行到這段while指令, 這個extension下其他指令都無法工作了, 從scratch發過來的eim消息得不到响應,extension_message_handle 無法觸發(其他extension的消息可以正常地響應)。 不知是不是與run機制有關,又或者是while阻塞了當前extension綫程, 請教有沒有什麽方法可以解決這個問題?
购买了一个Toio,基于codelab使用,发现codelab adapter不启动,也可以连接toio进行使用,请问是直接基于WEB BLE连接么;toio官方的能力我看是通过scratch link连接的。
收到一封来自印度的邮件,之前始终没认真考虑接入Arduino,毕竟社区认为micro:bit/MicroPython/RPI更可能是未来,但由于低廉的价格,大量落后地区在使用Arduino,所以打算将pymata-aio内置到CodeLab Adapter,提供开箱可用的Arduino插件,不知是否有小伙伴愿意一起在这个分支上工作。
目前bilikyar已经完成了一部分工作:scratch3_arduino, 我们可以在这个基础上继续前进。
已经发布了内置pymata-aio的codelab-adapter版本: v0_8_3 。
请问大师,我用codelab adapter连接Arduino,连接时总显示none type obkect has no attribute flush,请问大师这个怎解决
另外codelab adapter v3的版本到哪下载
请求开放usbMicrobit相关资源,以便增加以下功能:
microbit与codelab-adapter握手,从codelab-adapter一侧确认microbit处于随时可以与Scratch3交互的状态(而不是仅仅检测连接到了硬件)
集成一键烧入codelab-adapter microbit插件所对应的usbMicrobit固件的功能。
谢谢您的辛苦付出,以及无私分享。
bilikyar在微信中提到:
希望后面adapter跟scratch link一样的小图标最好,否则用户很难感觉到他的存在
我把我的思考贴过来, 用这个issue跟进这块的工作
小图标也在规划中,这块可能需要用到系统相关的库,我比较慎重,你可以提个issue,我们在那儿讨论细节,我已经做了一些工作在这块
本仓库里面好像找不到Extension的定义
比对 项目的代码和下载版本的代码,结构差别挺大,zip版本是根据本项目拓展一些功能打包生成的吗
zip版本中除了增加的python环境以及一些依赖库以外
还有添加了以及其他什么吗?
Hi
I couldn´t find the Scratch extension code for physical blocks.
Could you help me?
Thank you
https://adapter.codelab.club/extension_guide/physical_blocks/
https://github.com/CodeLabClub/codelab_adapter_extensions/blob/master/nodes_v3/node_physical_blocks2.py
基于muse 2
目前的插件,只提取出非常简单的脑电波数据模式,更多的探索需要基于机器学习来做。
Hey, @wwj718
Firstoff: if this is not the right place to ask this question feel free to redirect me.
I was following this tutorial: https://adapter.codelab.club/extension_guide/vector/
To enable vector programming by SCRATCH but I cant find the extension for it,
Also i saw that it is missing in the extensions_v3 folder, is it possible to add this feature?
Thanks.
Hi,
You have done a really awesome job. FYI I've been playing Alpha Mini with python mini-sdk and tried the official Scratch programming for alphamini called uCode. But I really excited with your huge works.
I'm planning to add some other Alpha mini features.
So I'm looking for scratch extension for alphamini. Would you help me with that?
Thank you
2020-02-24 20:32:38.229 | INFO | extension_python_kernel:extension_message_handle:62 - python code: print('hello')
2020-02-24 20:32:38.229 | DEBUG | codelab_adapter_client.base:publish:276 - adapter/nodes/PythonKernelExtension publish: topic: adapter/extensions/data payload:{'extension_id': 'eim/python', 'content': "'NoneType' object is not subscriptable", 'message_id': 1, 'token': 'b54d29ae21294fc7', 'sender': 'from_scratch'}
RT
是否针对一些离线设备实现功能呢
由于最近adapter里内置了MQTT客户端,所以尝试在本地的Scratch-vm里安装了MQTT包,想尝试写一下Scratch和adapter的通讯插件. 可在VM里yarn run watch
的时候,就会报一下错误:
ERROR in ./node_modules/mqtt/mqtt.js
Module parse failed: Unexpected character '#' (1:0)
虽然这个并不会影响插件功能的正常运行,可我的强迫症对这种错误的发生是无法置之不理的,所以通过MQTT.js github 社区里面找到了问题原因.
主要原因是,在 ./node_modules/mqtt/mqtt.js
里的#!/usr/bin/env node
并不是有效的js代码,所以是无法被webpack打包程序所识别的.
可行的解决方案是,在webpack.config.js里面添加如下代码:
var webpack = require("webpack");
const base = {
// ... other webpack config ...
plugins: [
new webpack.NormalModuleReplacementPlugin(/^mqtt$/, "mqtt/dist/mqtt.js"),
],
};
这段代码告诉Webpack当看到require(“mtqq”)
用require(“mqtt / dist / mqtt.js”)
替换它,这是MQTT库的缩小版本,并且没有#!
的开始。
参考issue链接
参考wiki
Scratch Link 已经开源,计划基于dongle class(近期会看做一些案例)或pyqt5的 BT机制兼容Scratch Link。
Scratch3.0官方内置的语音识别插件在国内不够稳定。
最简单的替代方案是构建一个scratch extension接入国内的语音服务,如百度云、阿里云、 腾讯云。但可能存在浏览器跨域问题。考虑到这个插件的通用型,倾向于在codelab-adapter一侧构建插件。如此一来codelab-adapter可以把这种能力带给任何网站。
kittenbot在这块做了出色的工作,可供参考: https://kittenbot.readthedocs.io/zh_CN/latest/AI/%E7%99%BE%E5%BA%A6%E8%AF%AD%E9%9F%B3%E8%AF%86%E5%88%AB.html
@wwj718 Hi,在 adapter 中,目前缺少统一的蓝牙 Python 接口来和智能硬件通信,并且存在MacOS/Linux/Windows 的兼容性问题,而 PyQT5/Bluetooth 似乎能解决这个问题,我会尝试在 MacOS/Windows 上验证 Pando ,结果会更新在本 Issue。
是否有什么更好的方案呢?
目前的眼动仪插件将眼动仪用作HID设备。
利用message报告给Scratch Extension,各个插件在运行之后订阅各自硬件的连接状态。
可以模仿Scratch microbit的消息提醒UI。
由于公司业务的原因,正在探索新形式的硬件课程,从半个月前跳入树莓派这个大坑后,就发现这个板子的内容极其丰富,所以,尝试把这个作为硬件课程的核心内容。可当在做移动小车的时候,就发现了问题,树莓派的供电比较麻烦,移动电源上方案还不完善,虽然网上各种技术帖子都说5v 2A的电源就够了,可今天用了充电宝的5v 2A电源接上树莓派,并且树莓派因此变砖之后,有点心凉,心疼我宝贝板子。
这里的最大的原因是,树莓派本身没有过电保护,而且,不像Arduino那样的单片机,需要规范的关机和开机过程才能保证寿命。 所以,直接用树莓派来做硬件课程的挑战性和难度,相对较大,还需要认真探索一段时间。
基于ESP32低廉的成本以及micropython的通用性,希望将ESP32接入codelab.
参考了网站的相关文档,只找到这一篇,但没有复现。
https://adapter.codelab.club/extension_guide/SimplePyboard/
疑问:
1、ESP32所需刷入的固件是官方的micropython固件吗?
2、测试刷入了官方micropython固件,然后搭建了以下积木,反馈如下
2.1 连接到【COM3】
反馈:ok
2.2 【start】【extension_simple_pyboard】
反馈:running
2.3 exec(初始化导入)【import machine】
反馈:‘SimplePyboardHelper’ object has no attribute 'exec'
2.4 执行【import machine】
反馈 ('exception',b",b'Traceback(most recent call last): file:"",line1 SyntaxError: invalid syntax)
2.5 执行【led_onboard = machine.Pin(22,machine.Pin.OUT)】
反馈: NameError: name machine isn't defined
感觉导入模块部分无法进行,不知该如何解决。
另discuss.codelab.club论坛,注册过程的邮件服务估计坏掉了,分别使用两个邮箱注册,都没有收到注册邮件。
运行scratch-gui
我的开发环境为MacOS 10.13.5,确保你在本地按照了git和nodejs。
windows用户
有读者在邮件里反馈说,在Windows下遇到一些问题。我在Windows 10里做了测试,把注意事项补充进来。
安装nodejs.
使用cmder,而不是cmd。
@wangshub 完成了dongle class,我这两天会发布一个包含dongle class新版本。
大家可以先用于本地测试
import time
import pygatt
import tenacity
import binascii
# pygatt api doc : https://github.com/peplin/pygatt/blob/master/pygatt/device.py
class Dongle(object):
def __init__(self):
self.adapter = pygatt.BGAPIBackend()
self.device = None
self.is_running = True
@tenacity.retry(stop=tenacity.stop_after_attempt(3))
def bled_start(self):
self.adapter.start()
def bled_stop(self):
self.adapter.stop()
self.is_running = False
def bled_scan(self):
devices = self.adapter.scan()
return devices
def bled_rssi(self):
return self.device.get_rssi()
@tenacity.retry(stop=tenacity.stop_after_attempt(3))
def bled_connect(self, mac_addr):
self.device = self.adapter.connect(mac_addr, address_type=pygatt.BLEAddressType.random)
print('connect to {}'.format(mac_addr))
print("rssi : " + str(self.device.get_rssi()))
print("chars : " + str(self.device.discover_characteristics()))
time.sleep(1)
def bled_subscribe(self, uuid, callback=None, indication=False):
self.device.subscribe(uuid, callback=callback, indication=indication)
def bled_write(self, uuid, data):
self.device.char_write(uuid, bytearray(data))
def bled_read(self, uuid):
data = self.device.char_read(uuid)
return data
@staticmethod
def _ascii_to_hex(rawhex):
return binascii.unhexlify(rawhex)
if __name__ == '__main__':
def read_cb(handle, value):
bytes_str = binascii.hexlify(value)
print(bytes_str)
dongle = Dongle()
try:
dongle.bled_start()
devices = dongle.bled_scan()
for dev in devices:
print(dev.get('address'), dev.get('rssi'), dev.get('name'))
dongle.bled_connect('C1:68:4E:87:AD:70')
dongle.bled_subscribe('0000ffe4-0000-1000-8000-00805f9a34fb', callback=read_cb)
data = dongle.bled_read('0000ffe4-0000-1000-8000-00805f9a34fb')
print('data = ', data)
while True:
time.sleep(1)
finally:
dongle.bled_stop()
我之前已经完成了对microbit官方固件的分析:https://blog.just4fun.site/scratch3-microbit-analysis.html ,可以直接接入scratch microbit官方固件。read部分我测试已经没问题了。
Command '['/usr/local/bin/python3.7', '/Users/maweifeng/codelab_adapter/servers/cozmo_server.py']' returned non-zero exit status 1.
连接不上cozmo,配置了 user_settings.py python3的 path;
Pixy is a fast vision sensor for DIY robotics and similar applications. You can teach Pixy an object just by pressing a button. Use Pixy for lots of different applications! It’s capable of tracking hundreds of objects simultaneously and only provides the data you are interested in.
最新版本的codelab_adapter中似乎移除了树莓派插件 请问这个是基于什么考虑呢 还是用另外的插件替代了他的功能?
看了这篇文章https://codelab-adapter-docs.codelab.club/dev_guide/helloworld/
其中说插件需要两个部分:
scratch端的插件(内应)示例我只找到了EIM,请问其他的插件(比如Tello, Vector等)是开源的吗?
我本来是想看看怎么处理异步发送的消息如何等待它成功执行返回,比如下面的伪代码:
Scratch blocks:
<Vector drive_forward 100>
<Vector turn_left 90>
<drive_forward 100>代码块执行可能要几秒钟才返回,如何让它阻塞直到成功返回后在执行下一句呢?
另外请问codelab-adapter有开源吗?
谢谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.