Dashboard robot control over the puppet protocol#278
Open
SaintSampo wants to merge 2 commits into
Open
Conversation
Over BLE the robot's puppet protocol only receives XPP packets from the dedicated DATA GATT characteristic; the REPL characteristic is dupterm'd into stdin, so binary packets written there are consumed as keystrokes and never reach the protocol (stray 0x03 payload bytes even act as Ctrl-C). sendVariableUpdate wrote to the REPL channel, so dashboard variable writes did nothing over BLE while working fine over USB's single stream. Add Connection.writeToDataDevice, defaulting to the normal device stream (correct for USB), and route sendVariableUpdate through it. The existing BluetoothConnection.writeToDataDevice override now chains on the shared GATT queue: Web Bluetooth allows one operation at a time per device, so an unqueued data write would race REPL traffic and be dropped.
Add a Robot Control widget to the dashboard's Add menu. Its Start button runs /XRPExamples/puppet_passthrough.py on the robot through the same stopProgram/updateMainFile/executeLines machinery as the editor's Run button, so the normal edit/upload workflow is untouched. The robot answers by defining its puppet variables, and the widget renders one control per channel the board actually has: - servo angle sliders and motor effort sliders, sent through a self-pacing pump that always transmits the newest setpoint and drops intermediates instead of queueing them on slow links (BLE GATT writes backlog easily) - LED toggle, plus read-only user button state and board type pushed by the robot - blocking drivetrain straight/turn commands with distance/degrees and max-effort parameters; all controls are disabled while $drivetrain.busy reports a motion in progress, and commands are sent directly rather than through the pump so they can never be coalesced away - a 500 ms keepalive that feeds the robot-side watchdog so motors stop when the browser goes away
kcq888
reviewed
Jul 14, 2026
| * @param data | ||
| */ | ||
| public async writeToDataDevice(data: Uint8Array) { | ||
| await this.writeToDevice(data); |
Collaborator
There was a problem hiding this comment.
I think that you might break the joystick functionality because you are not returning a promise. Look at the call to the writeToDataDevice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
Route XPP variable writes over the BLE data channel. Over BLE, the robot's puppet protocol only receives XPP packets on the dedicated DATA GATT characteristic — the REPL characteristic is dupterm'd into stdin, so binary packets written there are consumed as keystrokes (stray 0x03 payload bytes even act as Ctrl-C). sendVariableUpdate was writing to the REPL channel, so dashboard variable writes silently did nothing over BLE while working over USB. Adds Connection.writeToDataDevice() (defaults to the normal stream, correct for USB) and routes XPP sends through it; the BLE override chains on the shared GATT queue so data writes can't race REPL traffic and get dropped.
Add Robot Control dashboard widget. A new dashboard widget that starts /XRPExamples/puppet_passthrough.py on the robot via the same stop/run machinery as the editor's Run button (normal edit/upload workflow untouched). The robot answers with its puppet variable definitions, and the widget renders one control per channel the board actually has: servo and motor sliders (self-pacing sender that drops stale intermediates instead of backlogging slow links), LED toggle, read-only button state and board type, blocking straight/turn commands with distance + max-effort parameters gated on $drivetrain.busy, and a 500 ms keepalive feeding the robot-side motor watchdog.
Testing
Verified over USB and BLE: servo/motor sliders track without lag, LED and button state work, straight/turn block with controls disabled until the robot reports done.
Requires puppet_passthrough.py from XRP_MicroPython on the robot; without it the widget just waits (robot prints a traceback to the shell).