Skip to content

RickDnamps/AstromechOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

243 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AstromechOS

The open control platform for astromech builders.

License: GPL v3 Python Platform Android Sounds Sequences API

Two Raspberry Pi 4B ยท UART through slip ring ยท Full web dashboard ยท Android app ยท Bluetooth gamepad ยท 317 authentic sounds ยท 48 expressive sequences ยท Choreography timeline editor


Why this and nothing else?

Most astromech builders end up with a pile of shell scripts, a half-working web interface, and a robot that does one thing at a time. This isn't that.

This system was built from the ground up to make your astromech feel alive โ€” not just remote-controlled. A single button press triggers coordinated sound + dome rotation + panel choreography + light sequence simultaneously. The safety system has three independent watchdog layers so the robot cannot run away. Kids Lock limits speed for young pilots. Child Lock blocks all motion when the robot is on display. Everything deploys itself from a single button press on the dome.

If you're building a full-scale astromech (R2-D2, R5-D4, BB-8, custom unitโ€ฆ) and you want a control system actually worthy of the build โ€” this is it.


What is this?

A complete, production-grade control system for a 1:1 scale astromech droid replica. Two Raspberry Pi 4B communicate over a physical UART through the dome slip ring, with layered safety watchdogs, a REST API, an Android app, Bluetooth gamepad support, and 48 expressive behavioral sequences that give your droid a real personality.

  • Master Pi 4B 4GB (dome, rotates) โ€” Flask REST API, web dashboard, dome servos & panels, LED logics, visual editors, BT gamepad. 4GB headroom for future local AI (face detection, voice recognition โ€” all on-device, no cloud)
  • Slave Pi 4B 2GB (body, fixed) โ€” Drive motors (dual VESC), body servo panels, dome rotation motor, 317-sound audio system, RP2040 diagnostic LCD. Kept deliberately lightweight โ€” only real-time I/O, no AI workloads
  • If the UART link drops for more than 500ms, drive motors cut immediately โ€” no runaway robot, ever

Screenshots

Captured live on the dashboard at Xiaomi Pad 6 resolution (2880 ร— 1800), in the R2-D2 Light theme. Audio, Sequences and the Choreography editor are shown in both user and admin mode โ€” a single password unlocks the editing/upload controls that stay hidden for guests.

๐Ÿ•น๏ธ Drive

Dual virtual joysticks (propulsion + dome) ยท WASD / arrow keys ยท live MJPEG camera feed ยท speed arc + direction HUD ยท always-visible E-STOP ยท the per-axis Shortcuts overlay (up to 16 macro buttons) ยท and a fully customizable layout (see below).

Drive interface

๐Ÿ“Š Cockpit Status

One-tap real-time snapshot from any tab โ€” heartbeat & UART health, both VESCs, every servo/motor HAT, the RP2040 screen, Pi temps/CPU/disk, IP addresses, and active safety alerts (here: bench mode engaged).

Cockpit status panel

๐ŸŽจ Custom Drive Layout โ€” "Roblox-style" editor

Drag the joysticks, every shortcut button, and the camera anywhere. A live 5 % snap grid (adjustable 1โ€“20 %, or free pixel mode), a resizable + movable camera panel, transparent joysticks so the feed shows through, and a floating Save / Reset / Cancel banner. Saved per device (tablet โ‰  PC โ‰  phone) and included in your backups.

Custom Drive Layout editor

๐ŸŽฏ Neon alignment guides

Grab any element and a theme-coloured laser crosshair + live %-position badge locks to its edges (shortcut) or its center (joystick) for pixel-perfect alignment, then fades on release. Buttons dragged over the video auto-switch to a dark high-contrast fill; off the video they keep the theme styling.

Neon alignment guides

๐ŸŸก Kids Lock

Drive speed capped at a configurable % (amber KIDS pill) โ€” ideal for young pilots at a show. The dome and sounds stay fully free.

Kids lock mode

๐Ÿ”ด Child Lock

Propulsion blocked (left joystick disabled, red CHILD LOCK pill) while the dome, lights and sounds keep working โ€” hand the tablet to a small child with the droid on display.

Child lock mode

๐Ÿ”Š Audio โ€” user

317 authentic sounds across 14 mood categories ยท animated waveform ยท perceptual volume curve ยท one-tap random-by-mood.

Audio interface, user mode

๐Ÿ”Š Audio โ€” admin

Same tab unlocked: create / rename categories, drag-and-drop MP3 upload, and Verify sounds to reconcile the index against the files actually on the robot.

Audio interface, admin mode

๐ŸŽฌ Sequences โ€” user

48 behavioral sequences as emoji cards in pill categories. Tap to play, press-and-hold to loop. Lock badges warn which joystick a sequence will take over before you trigger it.

Sequences, user mode

๐ŸŽฌ Sequences โ€” admin

Unlocked: rename, set emoji, drag cards between categories, and delete โ€” all guarded by the admin password and cascaded to dependent shortcuts.

Sequences, admin mode

๐ŸŽผ Choreography editor โ€” user

Multi-track timeline โ€” up to 12 simultaneous audio channels ยท lights ยท dome keyframes ยท dome/body/arm servos ยท drive โ€” with a Digital-Twin dome preview. Here loaded with the "Yeah Show2" demo, packed across every track. Guests can browse and PLAY, but cannot alter a sequence.

Choreography editor, user mode

๐ŸŽผ Choreography editor โ€” admin

The same editor unlocked โ€” RENAME, SAVE, DELETE, EXPORT and IMPORT appear once the admin password is entered. Shown mid-playback: the playhead sweeps the timeline while the live dome monitor mirrors the show in real time.

Choreography editor, admin mode

๐ŸŽš๏ธ Inspector โ€” sound block

Click any block to edit it. A sound block exposes specific-file vs random-by-category, volume, priority, channel and timing โ€” synced to the millisecond against the rest of the timeline, so a dozen sounds layer cleanly.

Choreo sound block inspector

๐Ÿฆพ Inspector โ€” servo block

A servo block exposes the target panel, the open/close action, duration and easing โ€” so panels move in perfect sync with audio and lights.

Choreo servo block inspector

๐Ÿ’ก Lights BETA

Teeces32 or AstroPixels+ ยท 22 animations ยท FLD / RLD / BOTH text targets ยท PSI sequences ยท hot-swappable backend without a reboot.

๐Ÿšง Beta โ€” under active rework. A full AstroPixels rewrite is planned, plus a dedicated visual lights editor. Expect this tab and its API to change.

Lights interface

๐Ÿ” Admin mode

Tap the ADMIN icon from any tab to unlock editing/upload across Settings and the Audio / Sequence / Choreography editors โ€” one password, with a 5-minute inactivity auto-lock (shown throughout the user-vs-admin pairs above).

Admin access password prompt

โš™๏ธ Settings โ€” a whole tab of deep-dive sub-panels

Everything tunable lives in the Settings tab, organised into five nav sections โ€” Operator ยท Hardware ยท Connectivity ยท Appearance ยท System. As a taste, here's the Shortcuts editor: build up to 12 Drive-overlay macro buttons (toggle arms/panels, play a choreo/sound/random-by-mood), each auto-balanced half over the left propulsion joystick and half over the right dome joystick โ€” with a live preview of exactly where every button lands on the Drive tab.

๐Ÿงฌ Zero-config hardware (chantier G, 2026-05-28) โ€” the HATs sub-panel is now fully auto-discovered. The old generic 0x40..0x77 dropdowns are gone: every address selector lists only the addresses that scripts/detect_hats.py actually found on the bus during the last scan. Labels + calibrations are anchored to stable HAT identities (Body_HAT_A, Dome_HAT_A, ...) โ€” re-jumpering a PCA9685 from 0x41 to 0x42 is a 3-click re-map in the UI; every label and calibration follows automatically. Strict uniqueness rule, defense-in-depth: if you ever pick the same physical address for two identities, (a) both rows turn red instantly, (b) a pulsing red banner reads ยซ Collision d'adresse dรฉtectรฉe ยป, (c) the SAVE button is disabled, and (d) if anything bypasses the UI guards the backend POST /hats/remap refuses the write with HTTP 400 + "address 0xNN assigned to more than one HAT; each physical address must be unique". Full architecture, the 6 phases (G1โ†’G6), backup/restore semantics, 111 unit tests โ†’ docs/MAPPING.md.

๐Ÿ›Ÿ Troubleshooting โ€” HATs panel โ€” click to expand
Symptom Cause Fix
Amber note ยซ โš  No HATs detected on this side. Click ๐Ÿ”„ RESCAN HARDWARE then return to re-map. ยป in a Re-Map section. The live hw_layout.json is empty for that side โ€” either the scan never ran or the wiring/power changed since the last scan. Click ๐Ÿ”„ RESCAN HARDWARE in the same panel. detect_hats.py re-runs in read-only mode, rewrites hw_layout.json, the dropdown re-populates with whatever the bus reports.
Red banner ยซ โš  Collision d'adresse dรฉtectรฉe ยป and the SAVE button is grey. Two HAT identities are pointing at the same physical address. The UI catches it client-side before any POST. Pick a different address in one of the two highlighted rows. The check re-runs on every dropdown change โ€” the banner disappears + SAVE re-enables the moment the conflict is gone.
Calibration row greyed out with HARDWARE NOT FOUND in the Calibration sub-panel. The HAT identity exists in config_mapping.json but its bound address is not in the live hw_layout.json detected set (e.g. operator re-jumpered but didn't re-map yet). Settings โ†’ HATs โ†’ ๐Ÿ”„ RESCAN HARDWARE, then in the same panel pick the new address from the dropdown for the affected identity and ๐Ÿ’พ SAVE MAPPING. Driver hot-reloads; calibration data is preserved by identity.
Backend returns HTTP 400 "address 0xNN assigned to more than one HAT" from a script / curl. Defense-in-depth โ€” the same uniqueness rule that the UI enforces also guards POST /hats/remap. Adjust the payload so every address is unique within the side, then retry.

Settings โ€” Shortcuts editor

โš™๏ธ See the 16 other Settings sub-panels โ€” click to expand
๐Ÿค– Behavior
Idle & startup behaviors ยท next-trigger countdown
๐Ÿ”’ Lock Mode
Normal / Kids / Child Lock + speed caps
โšก VESC
Telemetry ยท power ยท faults ยท invert ยท bench mode
๐ŸŽฉ HATs
Zero-config ยท auto-discovered ยท Re-Map identity โ†” address
๐Ÿฆพ Arms
Arm/panel mapping ยท per-arm open delays
๐Ÿ”ง Calibration
Per-servo label ยท open/close angle ยท speed
๐Ÿ’ก Lights
Backend select ยท dome light config
๐Ÿ”‹ Battery
Cell count + chemistry โ†’ live thresholds
๐ŸŽฎ BT Gamepad
Premium header ยท custom button actions ยท scan/pair
๐Ÿ“ท Camera
Resolution / bitrate with live preview
๐Ÿ“ก Network
Hotspot + home Wi-Fi ยท slave-first changes
๐ŸŽต Audio
Channels + per-channel volume profiles
๐ŸŽจ Interface
7 themes + custom colour/font editor
๐Ÿš€ Deploy
Commit card + one-button OTA update
๐Ÿ–ฅ๏ธ System
Reboot/shutdown ยท admin password ยท backup & restore
๐Ÿ” Diagnostics
Live logs ยท UART RTT calibration
๐ŸŒˆ Theme picker
7 built-in + custom ยท live preview ยท per-device persistence

Features

๐ŸŽจ Custom Drive Layout Operator-positionable Drive tab โ€” drag the joysticks, every shortcut button, and the camera anywhere ยท adjustable 5 % snap grid (1โ€“20 %, or free pixel placement) ยท resizable + movable camera panel ยท transparent joysticks so the feed shows through ยท neon, theme-coloured alignment guides + live %-position badge ยท saved per device โ€” keyed by your monitor resolution, so resizing the window or running two windows side-by-side never loses the arrangement, and it survives a browser-data wipe ยท Borrow-a-layout picker (Settings โ†’ Interface) reuses an arrangement from another screen, applied proportionally to yours ยท included in the backup ยท edit mode is admin-gated, auto-closes on lock/inactivity, and never fires an action while you arrange
๐ŸŽญ 48 behavioral sequences One-click coordinated performances โ€” sound ยท dome ยท panels ยท lights ยท loop mode
๐ŸŽผ Choreography timeline editor Multi-track ยท VESC ยท audio ยท servos ยท lights ยท SHOW track โ€” drop other choreographies onto the timeline to compose multi-act shows (nested .chor files expand inline at playback) ยท admin-guarded Save/Delete ยท full touch support (drag from palette to add, drag to move, drag-edge to resize โ€” all work on a tablet, not just mouse)
๐ŸŽฎ Bluetooth gamepad Xbox/PS4/8BitDo/NVIDIA Shield direct to Pi ยท zero lag ยท battery % ยท RSSI ยท 2ร—2 axis grouping (DRIVE / LOOK) ยท premium header card with status LED + MAC pill
๐ŸŽฏ BT Custom Button Actions Per-controller profiles keyed by MAC โ€” bind ANY button to play_choreo / play_sound / play_random_audio / arms_toggle / body_panel_toggle / dome_panel_toggle. Press-to-capture workflow: click ๐ŸŽฏ CAPTURE NEW BUTTON, press the physical button, it's bound. Two NVIDIA Shields plug in โ†’ each remembers its own bindings independently. MAC resolution falls back to bluetoothctl for controllers that don't expose evdev.uniq (NVIDIA Shield, several 8BitDo). Validation by action type at save AND at trigger (defense-in-depth)
๐Ÿ”Š 317 authentic astromech sounds 14 mood categories ยท random by mood ยท drag-and-drop MP3 upload (admin)
๐Ÿ“ฑ Android app Offline banner ยท IP auto-discovery ยท full-screen ยท APK included ยท tablet/touch-optimized (file picker for restore/upload, native backup download, touch drag-and-drop in the editor)
๐Ÿ›ก๏ธ Triple safety watchdog App 1.5s ยท Drive 800ms ยท UART 500ms ยท graceful decel ramp โ€” no abrupt stops
๐Ÿšจ VESC safety lock Blocks drive when ESC offline or faulted ยท bench mode bypass for bench testing
๐Ÿ“Š Cockpit Status Panel Real-time robot snapshot from any tab โ€” HAT health ยท VESC ยท RP2040 screen ยท Pi temps ยท IPs ยท E-STOP overlay
๐Ÿ”’ Admin mode Password-protected ยท unlocks editor/upload from any tab ยท 5-min inactivity lock
๐Ÿ”Œ Hot-swap light drivers Teeces32 โ†” AstroPixels+ without reboot
๐Ÿš€ One-button OTA deploy Dome button โ†’ git pull + rsync + reboot โ€” no SSH needed
๐Ÿ“ท USB camera autodetect MJPEG stream ยท hardware-compressed ยท auto-reconnect after restart
๐ŸŽจ Theme system 7 built-in themes โ€” R2-D2 Light (default), R2-D2, R5-D4, BB-8, Chopper, R2-Q5, Classic ยท up to 16 custom themes ยท live preview ยท 7 sci-fi fonts ยท persisted server-side โ€” and your active theme is remembered per device so each screen reopens on its own theme (survives reboots, device changes & browser-data wipes; included in backups)
๐ŸŽ›๏ธ Drive-tab Shortcuts Up to 16 operator-configurable macro buttons ยท toggle arms/panels ยท play choreo/sound/random ยท green pulse while playing ยท re-press kills ยท auto-fills icon+label from choreo emoji ยท per-axis motion lockout (drive choreo locks left, dome choreo locks dome rotation, sound-only stays free)
๐Ÿ’พ Backup & Restore One-click full backup of all robot state (configs ยท sounds ยท choreos ยท calibrations ยท custom themes) to a downloadable .bck ยท Restore = total replacement + auto-reboot, recovers a dead SD card "like before" ยท network config preserved so masterโ†”slave never lose each other ยท hardened (anti zip-slip + anti-RCE allow-list)
๐Ÿ”„ Self-healing audio index The sound index reconciles against the files actually on the robot (drops ghosts, files unknown ones under others) on boot + on demand โ€” a failed upload never leaves a phantom
๐Ÿ›œ Per-robot hotspot + safe network changes Each robot's hotspot gets a unique SSID (Astromech_Control_XXXX from the Pi serial) so multiple droids don't collide at expos ยท changing the hotspot SSID/password updates the Slave first and aborts if it's unreachable, so the Slave never gets stranded โ€” and UART keeps drive/safety alive across the WiFi micro-gap (live-tested)
๐Ÿ” Clear two-password model The admin password unlocks the web/app interface only (Settings + the Choreo/Audio/Sequence editors) and is changed in-app; the Linux/SSH login is completely separate and untouched ยท all UI text shows your real system username, never a hardcoded one

๐ŸŽญ Built-in Behavioral Sequences

48 .chor sequences in the SEQUENCES tab โ€” organised in pill categories, each with a custom emoji. One-click launch of coordinated emotional performances. Loop mode keeps sequences running continuously. (The .chor JSON timeline format superseded the legacy .scr script format inherited from r2_control โ€” see Credits.)

Sequence What the droid does
scared Panels tremble at 35ยฐ (speed 8) โ€” nervous micro-movements
excited Panels snap open/shut at speed 9, rapid alternating combos
curious Panels creep open (speed 2, ~50ยฐ) while dome turns
angry Panels slam at speed 10, aggressive clack-clack
celebrate Dramatic wave across panels, body + dome flowing in sequence
patrol Dome wanders randomly, panels peek, random sounds
leia Full Leia hologram mode โ€” Teeces + iconic audio
cantina Full Cantina Band routine
march Imperial March with lights and dome movements
malfunction Alarm animations + panic sounds + dome spins
+ 30 more evil, birthday, disco, dance, taunt, scan, startupโ€ฆ

๐Ÿ›ก๏ธ Safety โ€” Triple Watchdog + Universal VESC Lock + Kid-Safe Stow

No single point of failure can leave the robot moving uncontrolled:

Layer Timeout Triggers when
App watchdog 1.5 s Browser closed, phone screen off, Wi-Fi drop
Drive timeout 800 ms No drive command received while motors are spinning
UART watchdog 500 ms Master crash, slip ring disconnected, Slave offline

All three trigger a graceful decel ramp โ€” never an abrupt stop that could tip the robot.

E-STOP / Reset E-STOP โ€” strict separation:

  • E-STOP (red button, always visible) โ€” freezes the robot: cuts propulsion, dome rotation, aborts any running choreography. Every servo is frozen in place โ€” both the Master dome driver and the Slave body driver expose a _frozen flag that aborts any in-flight ramp and rejects new commands. The PWM signal keeps holding the last commanded angle, so panels stay exactly where they are with full torque (no shutdown() / SLEEP mode that would let servos go limp and droop under load).
  • Reset E-STOP โ€” runs an automated stow sequence at a slow slew rate (speed=3, ~1 s for a 90ยฐ travel) to safely close arms, then their panels (respecting the per-arm delay), then all remaining body and dome panels. Designed to be safe around children.

Universal VESC safety lock (master/vesc_safety.py) โ€” single source of truth used by every code path that can drive motors (web joystick, REST API, Bluetooth gamepad, choreography player). Drive is blocked if either VESC is offline, telemetry is stale (>2 s), or any fault code is active. Bench mode bypasses the check for benchtop development without VESC hardware.

Paired-side CAN liveness โ€” if the right VESC (CAN ID 2) goes silent while the left side keeps responding, the Slave detects the asymmetry, refuses further drive commands locally, and emits a synthetic fault code so the Master's safety gate trips immediately. Prevents one-wheel runaways.

Slave reboot config resync โ€” when the Slave reboots mid-session, it sends a BOOT:READY banner over UART. The Master reacts by re-pushing the persisted VESC scale, inversion AND bench-mode config so the Slave never resumes operating with stale defaults.

Per-axis choreo motion lockout โ€” when a choreography is playing, the operator's joysticks are veiled with a "๐ŸŽฌ CHOREO" overlay ONLY on the axes the playback actually drives:

  • Choreo uses tracks['propulsion'] โ†’ propulsion joystick locked (web + Android + Bluetooth gamepad + WASD all gated)
  • Choreo uses tracks['dome'] โ†’ dome rotation locked (right-joystick X clamped to 0; Y stays free for the planned camera tilt in v2)
  • Sound/light/panel-only choreographies โ†’ both joysticks stay free โ†’ operator can drive the droid around while it animates ("alive" effect โ€” e.g. launch an angry choreo and walk towards the visitor while it scolds)

Cascade integrity โ€” renaming or deleting a .chor propagates through every Drive-tab shortcut targeting it (cascade_rename / cascade_delete in shortcuts_bp). No stale shortcuts pointing at non-existent choreos.


Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐Ÿ“ฑ Phone / Tablet / PC  โ†โ”€โ”€ Wi-Fi (192.168.4.1:5000)             โ”‚
โ”‚  ๐Ÿค– Android App          โ†โ”€โ”€ IP auto-discovery                     โ”‚
โ”‚  ๐ŸŽฎ BT Gamepad           โ†โ”€โ”€ Bluetooth (evdev, direct to Pi)       โ”‚
โ”‚                                                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  MASTER (Dome)           โ”‚   โ”‚  SLAVE (Body)                 โ”‚  โ”‚
โ”‚  โ”‚  Pi 4B โ€” 4GB             โ”‚   โ”‚  Pi 4B โ€” 2GB                  โ”‚  โ”‚
โ”‚  โ”‚                          โ”‚   โ”‚                               โ”‚  โ”‚
โ”‚  โ”‚  Flask REST API :5000    โ”‚   โ”‚  UART listener + CRC          โ”‚  โ”‚
โ”‚  โ”‚  Web dashboard           โ”‚   โ”‚  Watchdog 500ms โ†’ VESCs       โ”‚  โ”‚
โ”‚  โ”‚  Choreography player     โ”‚   โ”‚  Body servos PCA9685 @0x41    โ”‚  โ”‚
โ”‚  โ”‚  Dome servos @0x40       โ”‚   โ”‚  Dome motor TB6612 @0x40      โ”‚  โ”‚
โ”‚  โ”‚  Lights plugin           โ”‚   โ”‚  Drive VESCs (USB+CAN, ERPM)  โ”‚  โ”‚
โ”‚  โ”‚  BT Controller (evdev)   โ”‚   โ”‚  Audio mpg123 (317 sounds)    โ”‚  โ”‚
โ”‚  โ”‚  Deploy controller       โ”‚   โ”‚  RP2040 GC9A01 LCD (USB)      โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚              โ”‚                               โ”‚                      โ”‚
โ”‚              โ””โ”€โ”€ UART 115200 baud โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚                      โ”‚
โ”‚                  through slip ring           โ”‚                      โ”‚
โ”‚                  heartbeat 200ms + CRC       โ”‚                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Master + Slave split is a deliberate design decision. Putting everything on one Pi means a Flask/Python GIL spike could delay motor watchdog responses. With two Pis, the Slave's 500ms UART watchdog runs independently โ€” even if the Master crashes, the Slave cuts the VESCs automatically.

The 4GB on the Master is headroom for future local AI: face tracking, gesture recognition, contextual behavioral responses โ€” all on-device, no cloud. The Slave stays on 2GB forever โ€” pure real-time I/O, no AI workloads.

๐Ÿ“ Full electronics diagrams, power wiring & I2C/GPIO reference โ†’ ๐Ÿ”ง UART protocol design, repository structure, sequence format โ†’


Hardware at a Glance

Master Pi 4B 4GB (Dome) Slave Pi 4B 2GB (Body)
Servos 11 dome panels โ€” MG90S 180ยฐ โ€” PCA9685 @ 0x40 11 body panels โ€” MG90S 180ยฐ โ€” PCA9685 @ 0x41
Motors โ€” 2ร— 250W hub motors via 2ร— FSESC Mini 6.7 PRO
Dome motor โ€” DC motor via TB6612 HAT @ I2C 0x40
LEDs Teeces32 or AstroPixels+ via USB โ€”
Audio โ€” 317 MP3 sounds ยท 3.5mm jack ยท mpg123
Display โ€” RP2040 Waveshare 1.28" 240ร—240 round LCD
Power 5V/10A Tobsun buck โ†’ GPIO 2&4 5V/10A + 12V/10A Tobsun bucks
Battery โ† 24V via slip ring (3 wires parallel) 6S LiPo 22.2V โ€” XT90-S anti-spark

Quick Start

Prerequisites

  • 2ร— Raspberry Pi 4B (username: artoo โ€” set in Raspberry Pi Imager)
  • Both running Raspberry Pi OS Trixie (64-bit)
  • USB Wi-Fi dongle on the Master Pi (internet on wlan1 while hosting hotspot on wlan0)

Installation โ€” Two Scripts, Fully Automated

Portable across any Pi username โ€” setup_master.sh / setup_slave.sh auto-capture via $SUDO_USER. The Master and Slave must share the same Linux user (same password too โ€” simplifies SSH + first-contact auth). ~ and $(slave_target) below resolve to your install dir and SSH target automatically; the AstromechOS Imager (coming) will inject the choices into /boot/astromech_init.cfg so no SSH login is needed at all.

# Step 1 โ€” Master Pi (SSH into it, then run:)
curl -fsSL https://raw.githubusercontent.com/RickDnamps/AstromechOS/main/scripts/setup_master.sh | sudo bash

# Step 2 โ€” Slave Pi (SSH into it, then run:)
curl -fsSL https://raw.githubusercontent.com/RickDnamps/AstromechOS/main/scripts/setup_slave.sh | sudo bash

# Step 3 โ€” First deploy (from Master, once:)
bash ~/astromechos/scripts/setup_ssh_keys.sh         # pushes Master pubkey to the Slave (target read from local.cfg)
bash ~/astromechos/scripts/deploy.sh --first-install

Done. Open http://192.168.4.1:5000 on any device connected to the robot hotspot (Astromech_Control_XXXX).

๐Ÿ›ก๏ธ Git DNA paternity check โ€” the Settings โ†’ Deploy panel (and the /api/deploy/save-config endpoint) now refuse to point origin at any repo that isn't a legitimate fork of RickDnamps/AstromechOS. A git merge-base --is-ancestor test against a frozen anchor commit blocks typos and malicious URLs before git pull can touch the working tree. Architecture detail โ†’ docs/DEPLOY_SECURITY.md.

โšก First-boot Imager workflow (in progress) โ€” a planned AstromechOS Imager PC tool will drop SSH keys, hostname, role + Wi-Fi credentials directly on the SD card's /boot partition. The robot's scripts/firstboot_setup.sh runs once at first boot, injects everything atomically, DNA-validates the configured remote, and self-destructs. Fully headless provisioning. Same doc โ†’ docs/DEPLOY_SECURITY.md.

๐Ÿ“– Full installation guide โ†’ (recommended โ€” covers reconnecting after reboot, network options, and daily use)

Updates

bash /home/artoo/astromechos/scripts/update.sh

Or press the physical dome button (short press). Updates itself over-the-air โ€” no SSH required.

๐Ÿงน Production-ready imaging (clean_for_imager.sh)

Before pulling the SD card to clone a distributable image, run the industrial cleanup script. It stops every astromech-* service, purges caches (pip / npm / .cache), wipes /tmp/ + shell history + the security snapshot, vacuums systemd journal + truncates active /var/log files (NEVER rm -rf โ€” daemons keep writing), apt-get clean + autoremove, and resets /etc/machine-id so every cloned Pi boots with its own unique identity. Before/after disk usage is reported so you see exactly how much was reclaimed.

# First time only โ€” copy the script to /usr/local/bin/ (so it lives on
# the imaged card and any future operator can run it without cd-ing
# to the repo first):
sudo bash /home/artoo/astromechos/scripts/clean_for_imager.sh --install

# Then, whenever you want to produce a clean image:
sudo clean_for_imager.sh           # interactive โ€” type 'yes' to confirm
sudo clean_for_imager.sh --yes     # scripted / CI mode (no prompt)
sudo shutdown now                   # pull the SD card and dd it.

Safety: the script refuses to run if you're not root, if /proc/device-tree/model is not a Raspberry Pi, or if no AstromechOS repo is found under /home/*/astromechos. No rm -rf /var/log/*, no recursive node_modules purge across $HOME โ€” destructive actions are bounded to the AstromechOS repo + known cache directories only.


Development Roadmap

Phase Description Status
1 UART + CRC ยท heartbeat watchdog ยท audio ยท Teeces32 ยท RP2040 display ยท auto-deploy โœ…
2 VESCs ยท dome motor ยท MG90S servo panels with speed ramp โœ…
3 Choreography engine โ€” 48 expressive behavioral sequences (.chor) โœ…
4 REST API + web dashboard + Android app + Choreography editor + BT gamepad + lights plugin + VESC diagnostic + camera stream + admin system + safety locks + Cockpit Status Panel + theme system + HAT/screen diagnostic โœ…
4+ Universal VESC safety helper ยท Slave boot banner config resync ยท paired-side CAN liveness ยท E-STOP/Reset E-STOP separation with kid-safe stow ยท event-driven choreo scheduler ยท UART RTT calibration tool with hot-swap ยท service worker cache versioned per deploy โœ…
4++ BT Gamepad Custom Button Actions (per-MAC profiles, press-to-capture) ยท MAC fallback via bluetoothctl for controllers without evdev.uniq (NVIDIA Shield) ยท premium header card refonte (icon + status LED + MAC pill + vitals) โœ…
5 Vision โ€” person tracking ยท face detection ยท contextual AI responses (on-device) ๐Ÿ”„

๐Ÿ”ฌ Built-in calibration tools

  • UART RTT calibration โ€” Settings โ†’ System โ†’ Hardware โ†’ MEASURE samples the heartbeat round-trip time over a 40-second rolling window and proposes a tuned body_servo_uart_lat based on the median latency (clamped 5โ€“50 ms). The APPLY & SAVE button persists the value and hot-swaps the running ChoreoPlayer in one click โ€” no reboot, no Slave restart. Re-measure and re-apply iteratively until body and dome panels open in perfect sync.
  • Manual override โ€” type any value into the latency field, hit Tab/Enter, the value auto-saves with a brief โœ“ saved indicator. Hot-swap takes effect at the next choreography play.
  • /diagnostics/uart_rtt REST endpoint exposes the same data (min/avg/max/p50/p95/p99 ms ยท current vs recommended) for scripted use.

Credits & Inspiration

  • r2_control by dpoulson โ€” Original .scr script format concept and R2-D2 sound library. The script thread idea that inspired this entire engine.

  • Michael Baddeley โ€” A special thank you to Michael for his absolutely incredible R2-D2 MK4 3D model. Without his extraordinary work and passion for the R2-D2 builder community, this project simply would not exist. His model is the physical soul of this build. ๐Ÿ™โญ

  • R2-D2 Builders Club โ€” Community knowledge on dome geometry, slip ring wiring, and hardware gotchas accumulated over decades of builder experience.


License

GNU GPL v3 โ€” see LICENSE. Free to use, modify and share โ€” keep it open source.


Built for builders who refuse to settle for half-measures.

May the Force be with you. ๐ŸŒŸ

โญ Star this repo ยท ๐Ÿ› Report an issue ยท ๐Ÿ“– Full guide โ†’ ยท ๐Ÿ”ง Technical reference โ†’

About

Astromech Control Software on Raspberrypi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors