项目演示
材料
- CodeLab Adapter
- 插件
- Jupyterlab插件
- 插件
项目解释
在 Jupyterlab 里控制Overdrive。
打开 Adapter Jupyter。
在 Jupyterlab 中使用 node_overdrive.py。
注意蓝牙驱动是一个异步库。
import asyncio
from bleak import BleakScanner
from codelab_adapter_client.utils import is_win
from codelab_adapter.ble_overdrive import CarProxy
if is_win():
device_flag = "link manager protocol" # lmp
else:
device_flag = "drive"
devices = await BleakScanner.discover()
overdrive_devices = [d for d in devices if device_flag in str(d).lower()]
async with BleakClient(overdrive_devices[0]) as client:
car0 = CarProxy(client, None)
await car0.turnOnSdkMode()
await car0.changeSpeed(500, 1000)
await asyncio.sleep(3)
await car0.changeSpeed(0, 1000) # stop