Skip to content

Dashboard robot control over the puppet protocol#278

Open
SaintSampo wants to merge 2 commits into
mainfrom
JacobsDev
Open

Dashboard robot control over the puppet protocol#278
SaintSampo wants to merge 2 commits into
mainfrom
JacobsDev

Conversation

@SaintSampo

Copy link
Copy Markdown
Collaborator

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).

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 kcq888 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my review

* @param data
*/
public async writeToDataDevice(data: Uint8Array) {
await this.writeToDevice(data);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you might break the joystick functionality because you are not returning a promise. Look at the call to the writeToDataDevice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants