A Python-based game controller for a Dash robot that combines real-time robotics control with a tile-based game interface.
See https://robopenguins.com/dash-turtle-game/ for blog post on the making of this project.
This project enables a Dash robot to navigate a grid-based game environment. Players can queue movement commands via keyboard, controller, or NFC cards, and the robot executes them while the game tracks progress toward a goal tile.
The positioning relies on the Dash's inertial navigation, so it needs to have its initial conditions set manually, and can drift over time, from the wheels slipping, from collisions, or by being picked up.
Basic Demo:
More comprehensive demo:
This is built on top of the Dash Python interface that I reverse engineered in https://github.com/axlan/WonderPy.
-
Bot can be controlled with the keyboard, the toy controller, or the NFC cards.
-
Control software does coordinate transforms and movement commands to try to keep the robot centered in the grid tiles.
-
GUI shows positioning estimate and can queue up a sequence of commands to execute when connected.
-
Simulation mode allows for testing without a Dash bot connected.
-
IR distance sensors do basic collision detection
-
The front, right, and left LEDs are set to match the colors of the buttons on the controller to help the player understand how the clockwise and counterclockwise turns correspond to the bot's relative position.
-
The light on top of the bot indicates if it's busy. When sending commands in realtime, it will sigh if a new command is sent while it's still executing the previous one.
-
Map Display (map.py): Pygame-based GUI showing the game board with the turtle's position, observed/unobserved tiles, obstacles, and goal location. Supports drag-and-drop for repositioning the turtle and goal.
-
Card Queue Widget (card_gui.py): Visual queue of queued movement commands (LEFT, RIGHT, UP) with scrolling and active card highlighting.
-
Main Controller (main.py): Orchestrates the game loop, connects to the robot, processes sensor data, and updates the map based on obstacle detection.
-
Real Robot (bot_interface.py): Controls a real Dash robot via WonderPy library, handling pose transformations between virtual game coordinates and robot coordinates. Implements forward/backward movement and rotation with RGB LED and sound feedback.
-
Simulated Robot (sim_bot_interface.py): Virtual robot for testing without hardware, simulating movement and limited sensor data.
- MQTT Client (mqtt_client.py): Subscribes to card reader and controller topics for remote command input.
Setting this up is beyond the scope of this README, but the basic idea is that it connects to a broker server to get events from IoT devices.
The controller is https://github.com/axlan/toy_controller, though it would be easy to add real controller support through PyGame.
The reader is a quick and dirty ESP32 firmware in the reader_firmware directory. This is just an ESP32 connected to a PN532 NFC reader.
The project manages three coordinate systems:
- Pygame: Pixel-based screen coordinates (standard Pygame orientation with origin at top left)
- Virtual Game: Unit-less tile coordinates where each tile is 1×1 with origin at bottom left
- Robot: Centimeter-based coordinates with orientation offset from virtual space
The virtual game is the main system used by the controller. The robot and map classes do the transformations to their respective coordinates.
With uv:
uv sync
uv run dash-turtle-gameWith pip:
pip install .
python -m src.dash_turtle_game.main- Customize the
SETTINGSat the top ofsrc/dash_turtle_game/main.py - When run, the GUI lets you set the turtle start position and orientation and the goal location with the mouse
- [Optional] Queue movement commands via keyboard (arrow keys), NFC cards, or controller
- Press connect to start controlling the robot
- If not running a simulation the PC will attempt to do a BLE scan for a Dash robot. See WonderPy/core/wwBTLEMgr.py for command line parameters to control this process.
- Robot executes queued commands. It will stop if any command would make it run into an obstacle or off the map.
- Further commands can be used to drive the robot around in realtime.
- Reaching the goal makes the robot do a little dance
- Disconnecting goes back to step 2

