How robotarium/gternal works
1. This repository is the deployment and firmware stack for a GTernal robot, not a single app. The system is split into three runtime domains: a host computer used for provisioning, a Raspberry Pi running the robot-side software, and a Teensy microcontroller running the low-level embedded firmware.
2. The host-side tooling lives in setup/ and interfacing/. These scripts discover robots on the LAN, map MAC addresses to robot IDs, push configuration over SSH/SCP, and trigger setup or shutdown actions. The key identity file is config/mac_list.json, which is the source of truth for “which physical robot is which ID” during setup.
3. config/env_variables.sh is the deployment configuration boundary. It likely holds registry/repo names, image tags, and environment values used by the Docker build/run scripts. Architecture-wise, this file controls how the same code is packaged for base-image provisioning versus runtime execution.
4. Docker is a first-class subsystem. docker/base_image/ builds and publishes the Raspberry Pi base image, while docker/ builds and publishes the runtime firmware image and runs a local registry if needed. The repo is designed so robots pull prebuilt images instead of compiling on-device, which is important for scaling setup across multiple robots.
5. The base-image workflow exists to create a reusable SD-card image for Raspberry Pi OS. The host creates the image once, clones it to multiple SD cards, and then uses the robot provisioning scripts to specialize each robot. This is a provisioning layer, separate from the runtime firmware layer.
6. On the Raspberry Pi, the runtime is containerized. The Pi boots from the base SD image, then the setup scripts install or launch the firmware container. The README also references v2tec/watchtower, indicating that the Pi can automatically refresh to the newest firmware image from Docker Hub or a local registry.
7. The Pi-side firmware code is in firmware/RPi/ and is Python-based. pi_firmware.py, gritsbotserial.py, and detect_serial.py form the bridge between the Pi and the Teensy over serial/UART. Architecturally, this layer is the robot’s runtime coordinator: it is the boundary between network-facing control and embedded hardware control.
8. The Teensy-side firmware is in firmware/Teensy/. defaultOperation/defaultOperation.ino is the main embedded program, with debug/debug.ino as a secondary diagnostic entry point. This is the lowest-level control plane for the robot, handling hardware behavior directly on the microcontroller.
9. The Teensy firmware depends on a large vendored library set under firmware/Teensy/libraries/. These include sensor and device libraries such as Adafruit GFX, BNO055, INA260, NeoPixel, VL53L0X, ArduinoJson, and several SparkFun/ST sensor libraries. That means the embedded boundary includes display, sensor, and peripheral drivers, not just a single custom sketch.
10. The main data flow is: host computer discovers robot MACs, assigns IDs, and provisions the Pi; the Pi container runs robot software and communicates upward to the network and downward to the Teensy over serial; the Teensy drives sensors/actuators. The Pi is the bridge between Wi‑Fi/network control and deterministic embedded control.
11. External services are part of the architecture. The README’s test flow uses an MQTT broker and the vizier client to query robot status and publish motor commands. So the operational control path is network client → MQTT broker → robot-side software, with the Pi/Teensy chain executing the command locally.
12. GTernal_design_files/ is not runtime code, but it matters to system identity: it contains mechanical/laser-cut assets for robot marking such as Vicon hats and ArUco-related ID assignment. In an architecture diagram, this is a supporting physical-design artifact tied to robot identity management.
13. The important boundaries to draw are: provisioning host vs. robot runtime; Raspberry Pi Linux/container layer vs. Teensy embedded layer; local serial link vs. network/MQTT link; and image build/publish infrastructure vs. on-robot execution. Those are the core seams in this repository.
Main entry points: pi_firmware.py Pi firmware · setup Setup tools · docker Runtime image · defaultOperation.ino Main sketch
Components 17
Host provisioning
Discovery, identity mapping, and setup workflows on the provisioning computer.
- Setup tools · Host-side scripts that prepare robots, push config, and coordinate provisioning.
setup - Robot ops · Scripts for robot discovery, restart, and shutdown over the network.
interfacing - MAC map · Authoritative mapping from physical robot MAC addresses to robot IDs.
config/mac_list.json - Env config · Deployment boundary for image names, tags, registry, and runtime values.
config/env_variables.sh
Container build
Image build, publish, and registry support for robot runtime and base images.
- Base image · Workflow that builds a reusable Raspberry Pi base SD-card image.
docker/base_image - Runtime image · Build and publish flow for the robot firmware container image.
docker - Registry ops · Local registry and push/pull helpers used during deployment.
docker/docker_registry.sh
Robot runtime
Raspberry Pi software layer that bridges network control to embedded hardware.
- Pi firmware · Main Raspberry Pi-side runtime that coordinates robot behavior and serial control.
firmware/RPi/pi_firmware.py - Serial bridge · Bridge code between Pi software and the Teensy over serial/UART.
firmware/RPi/gritsbotserial.py - Serial detect · Detects the active serial device for the attached Teensy.
firmware/RPi/detect_serial.py
Embedded firmware
Teensy sketches and supporting libraries for low-level robot control.
- Main sketch · Primary Teensy firmware entry point for default robot operation.
firmware/Teensy/defaultOperation/defaultOperation.ino - Debug sketch · Secondary Teensy entry point for diagnostics and bring-up.
firmware/Teensy/debug/debug.ino - Sensor libs · Vendored device libraries for sensors, display, JSON, and peripherals.
firmware/Teensy/libraries
External systems
Runtime dependencies outside the repository.
- Watchtower · Container updater used to refresh the Pi runtime from an image registry.
- MQTT broker · External message broker used for operational control and status queries.
- Vizier client · Client used in tests and operations to query status and publish motor commands.
Physical assets
Design files tied to robot identity and marking.
- Design files · Mechanical and marking assets tied to robot identity and fabrication.
GTernal_design_files
Connections 20
- Setup tools → MAC map: reads IDs · Uses the MAC-to-robot mapping as the source of truth during provisioning.
- Setup tools → Env config: loads config · Reads deployment settings that parameterize image and runtime setup.
- Setup tools → Base image: prepares SD · Starts or coordinates the Raspberry Pi base-image workflow.
- Setup tools → Runtime image: deploys runtime · Installs or launches the robot container on the Pi.
- Robot ops → Pi firmware: controls robots · Discovery and operational scripts target the robot-side software.
- Robot ops → MQTT broker: publishes cmds · Operational control flows through the network message bus.
- Base image → Env config: uses settings · Image build and provisioning are parameterized by deployment variables.
- Runtime image → Env config: uses settings · Runtime image build, push, and run behavior are driven by deployment variables.
- Runtime image → Registry ops: push/pull · Builds are published to or retrieved from a registry.
- Pi firmware → Serial bridge: uses · Pi runtime delegates Teensy communication to the serial bridge layer.
- Pi firmware → Serial detect: finds device · Locates the correct serial device before opening the bridge.
- Pi firmware → MQTT broker: subscribes · Receives network-facing commands and status traffic via MQTT.
- Pi firmware → Watchtower: updates via · Can be refreshed automatically by the container update agent.
- Vizier client → MQTT broker: talks to · The operator/test client interacts with robots through MQTT.
- MQTT broker → Pi firmware: delivers · Network commands reach the Pi runtime through the broker.
- Pi firmware → Main sketch: serial cmds · Robot coordination is forwarded from Pi to embedded firmware over serial.
- Main sketch → Sensor libs: depends on · Main firmware is built on top of vendored device and utility libraries.
- Debug sketch → Sensor libs: depends on · Diagnostic sketch also relies on the shared embedded library set.
- Design files → MAC map: supports ID · Physical identity/marking assets support robot labeling and identification.
- Design files → Main sketch: hardware context · Mechanical artifacts relate to the robot form factor controlled by the embedded firmware.