Robotics#
One of the main reasons why WebTigerPython was created was to make it possible to program a lot of robots from the web. The device is selected in the options drawer. We support the following devices as of right now:
Device |
Connection |
Status |
|---|---|---|
micro:bit |
WebUSB |
stable |
Calliope mini 3 |
WebUSB |
stable |
Calliope mini 1/2 |
Export (download) |
stable |
Oxocard |
IoT |
beta |
Root Robot |
Web Bluetooth |
beta |
xBot |
Web Bluetooth |
beta |
ESP32 (MicroPython) |
Web Serial |
experimental (since 1.9.0) |
The micro:bit and the Calliope mini are programmed by flashing MicroPython code to the device. The ESP32 is programmed over the MicroPython REPL via Web Serial, without flashing new firmware. The Oxocard, the Root Robot and the xBot are controlled live: the program runs in WebTigerPython and single commands are sent to the device.
To make our tool extendable, we created a device interface, which makes it simple to add new devices. Every device has to implement the functions to register / disconnect the device and a cleanup function. All other functions are optional. If one of them is missing, the corresponding button is greyed out in the user interface when the device is selected.
export interface DeviceInterface {
connectIcon: string;
battery?: number;
// set only by devices that eventually set deviceStore().isReady
reportsReadiness?: boolean;
// these functions should be accessible for all devices
registerDevice: () => void;
disconnectDevice: () => void;
cleanUp(): void;
// these are not accessible for all devices
exportCode?: (code: string) => void;
flash?: (code: string) => void;
runCode?: (code: string) => void;
stopCode?: () => void;
handleCallback?: (data: any) => Promise<any>;
}
handleCallback is used by the live controlled devices: the Python library in the web worker sends a command via a callback to the main thread, where the device forwards it to the robot and returns the answer.
When WTP is embedded as an iframe, every device action (register_device, flash, run_code, …) is also reported to the parent page (see Embed WTP as an iframe).
Connection possibilities#
WebUSB#
WebUSB gives the user the ability to access devices which are connected with USB. The micro:bit and the Calliope mini 3 are programmed this way. However, not all browsers support WebUSB. It is currently only available in Chromium-based browsers such as Google Chrome and Microsoft Edge.
Web Bluetooth#
Web Bluetooth gives the user the ability to program a device wirelessly. The Root Robot and the xBot are controlled via Web Bluetooth (see Root Robot Integration). Like WebUSB, Web Bluetooth is only supported by Chromium-based browsers.
Web Serial#
Web Serial gives access to serial ports. It is used for boards that already run MicroPython, such as the ESP32: the code is sent to the running MicroPython REPL using the raw REPL protocol, so it works independently of the microcontroller underneath. Web Serial is only supported by Chromium-based browsers.
IoT#
The code execution stays within WebTigerPython, so all Python features can be used. To read sensors etc., single instructions are sent to the device over the internet and the return values are sent back. This is used for the Oxocard.
Devices#
Calliope mini (WebUSB)#
Calliope mini 1, 2 and 3 can be programmed with WebTigerPython. We additionally provide robotics libraries, e.g. for the Calli:bot. The Calliope mini 3 can be flashed directly with WebTigerPython, while for the Calliope mini 1/2, the script has to be exported and copied to the device via drag and drop.
Teaching Material
micro:bit (WebUSB)#
The micro:bit can be programmed with WebTigerPython. We additionally provide robotics libraries for robots like the Maqueen or the Maqueen Plus.
Teaching Material
Files on micro:bit and Calliope mini#
The micro:bit and the Calliope mini have a flat file system without folders. Therefore the workspace must not contain folders when one of these devices is selected. When flashing, every file of the workspace is copied to the device, and main.py is always the file that is run (see Multiple files).
Oxocard (IoT, beta)#
The Oxocard is controlled over the internet via the oxocard library.
Root Robot and xBot (Web Bluetooth, beta)#
The Root Robot is a drawing robot that is controlled with turtle-like commands; its movements are shown on the turtle canvas at the same time. The xBot uses the same protocol and library (xBot), with the pen down at the start. See Root Robot Integration.
ESP32 (Web Serial, experimental)#
ESP32 boards running MicroPython can be programmed since version 1.9.0. The device is experimental and only shown after calling experimental() in the browser console.
Simulator#
When the micro:bit or a Calliope mini is selected, a simulator is shown, which can also simulate robots such as the Maqueen, Maqueen Plus or the Calli:bot. See Simulator.
Robotics Libraries#
For multiple extension boards of the micro:bit and the Calliope mini we have developed libraries. All these libraries can be checked out here: