Add puppet passthrough example for dashboard robot control#102
Open
SaintSampo wants to merge 3 commits into
Open
Add puppet passthrough example for dashboard robot control#102SaintSampo wants to merge 3 commits into
SaintSampo wants to merge 3 commits into
Conversation
wheel_diam and wheel_track default to 0.0, used as a sentinel meaning "pick the board's built-in dimensions." Assign the provided value when it is non-zero. The encoder-based heading calculation in the straight-line and turn routines divided by self.track_width. Use self.wheel_track, the actual track-width attribute set in the constructor.
Terminate the file with a newline so it follows POSIX text-file convention and stops tools from flagging "no newline at end of file".
Adds XRPExamples/puppet_passthrough.py: a Puppet passthrough program exposing servos, encoded motors, LED, button and drivetrain controls to the XRPWeb dashboard. Auto-detects available actuators and defines appropriate XPP variables, handles blocking drivetrain commands with effort sanitization and timeouts, reports board type, and implements a keepalive watchdog that stops motors on lost connection. Button reporting uses an IRQ and drivetrain busy state is provided to the browser.
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.
What
Adds
XRPExamples/puppet_passthrough.py: a program that hands direct control of therobot's actuators to the XRPWeb dashboard over the puppet protocol (XPP). The dashboard's
Robot Control widget starts it exactly like the Run button starts any user program, so it
requires zero changes to
puppet.py,main.py, or the normal edit/upload workflow —it's just an example file that ships with the library.
How it works
On startup the program probes which actuators the board actually has (the
get_default_*helpers return
Exceptionobjects for missing ports — e.g. servo 3/4 and motor 4 on someboards) and defines a puppet variable per available channel. The auto-sent
VAR_DEFsdouble as the handshake: the browser learns the channel list and enables matching
controls, so boards with fewer ports simply show fewer controls.
$servo.1–$servo.4$motor.left/right/3/4$led$drivetrain.straight/$drivetrain.turn$drivetrain.straight.effort/.turn.effort$drivetrain.busy$button$board.type$puppet.keepaliveA 50 Hz main loop applies values on change only, so starting the passthrough never
snaps servos or spins motors.
Safety / robustness notes
motors stop, and the stale effort is cleared from the puppet registry so a reconnecting
browser can't resurrect it. Servos and LED are deliberately left as-is.
straight()/turn()block the loop, so$drivetrain.busyisthe browser's only feedback during a run. Every motion gets an effort-scaled timeout
(a jammed or lifted robot can't freeze the program forever), commands that arrive
mid-motion are discarded, and cleanup runs in a
finallyso IDE-Stop mid-motion stillreports not-busy. Motions end with motors stopped, and the registry is zeroed to match
so pre-motion slider values can't silently re-apply.
BLE/USB writes from IRQ context); the main loop reads the pin and pushes the update,
which also coalesces contact bounce.
while it owns the USB stream, and the run harness's
resetbotfrees the actuators.