Software stack for the R2 autonomous robot competing in ABU Robocon 2026.
This repository contains the perception, navigation, decision-making, and deployment software for Team Vulcans' entry in ABU Robocon 2026. The competition arena is divided into three zones, each requiring distinct capabilities:
| Zone | Task | Approach |
|---|---|---|
| Zone 1 | Weapon assembly (staff + spearhead) with R1βR2 collaboration | OpenCV detection, visual servoing, no-contact assembly verification |
| Zone 2 | Forest traversal on a 4Γ3 grid with 20/40/60 mm step blocks | Time-aware hybrid A*, belief-map perception, pneumatic step climbing |
| Zone 3 | Tic-tac-toe KFS placement on a 3Γ3 shared rack | PPO-trained RL agent, OpenCV rack scanning, elevator/conveyor control |
The codebase spans algorithm prototyping (MATLAB), simulation validation (NVIDIA Isaac Sim), RL training (PyTorch + Gymnasium), and robot deployment inference.
Robocon26/
βββ Deployment/ # β
R2 runtime "brain" (NEW unified tree)
β βββ common/ # shared HAL + perception + alignment
β β βββ config.py protocol.py serial_link.py kinematics.py drive.py
β β βββ gripper.py pneumatics.py sensors.py imu.py odometry.py
β β βββ perception.py alignment.py match.py robot.py
β βββ zone1/ # weapon assembly pipeline + FSM
β β βββ spearhead_perception.py assembly_fsm.py zone1.py config.py
β βββ zone2/ # forest traversal + step climbing
β β βββ astar_planner.py # proven time-aware hybrid A* (relocated)
β β βββ perception.py # grid belief (manual / camera / default)
β β βββ step_climber.py # NEW 2-piston (tilted front + back) up/down
β β βββ planner_bridge.py zone2.py config.py
β βββ firmware/esp32/ # r2_drive + r2_sensor + r2_manip (3 boards) + r1_manual
β β βββ IO_CONTRACT.md # boardβpinβcommandβtelemetry map (for embedded)
β βββ tests/ # hardware-free SIM unit/integration tests
β βββ README.md # full deployment layout + how to run
β
βββ Zone1/ # Weapon assembly assets (firmware β Deployment/firmware)
β βββ Spearhead_Detection_test/ # ROS2 YOLO-seg detection package
β βββ *.ino # original R1/R2 sketches (kept as reference)
β
βββ Zone2/ # Research & training assets (NOT runtime)
β βββ Navigation/ # A* prototype (Python/MATLAB) + Isaac Sim
β βββ Detection/ # YOLO KFS training + Jetson WebRTC server
β
βββ Zone3/ # Tic-tac-toe strategy & placement
β βββ RL/
β β βββ agents/ # MaskedActorCritic, PPO trainer, Opponent pool
β β βββ env/ # Gymnasium env (22D obs, 10 Discrete actions)
β β βββ game/ # Board logic, vertical/diagonal win rules
β β βββ training/ # Curriculum scheduler & main train loop
β β βββ inference/ # Zone3Controller for real-time robot deployment
β β βββ viz/ # Interactive Matplotlib UI for testing
β β βββ README.md # Detailed Zone 3 RL documentation
β βββ .gitignore # Excludes checkpoints/ and logs/
β
βββ requirements.txt # All Python dependencies
βββ R2_GSM_Refined.md # Global State Machine specification (all zones)
βββ R2_FSM_Refined.md # Finite State Machine specification (sub-states, protocols, I/O)
βββ ABU Robocon 2026 Rulebook V.0.pdf # Official competition rulebook
βββ .gitignore
βββ LICENSE # MIT License
βββ README.md
The core planner (time_aware_hybrid_astar.py) navigates R2 through a 4Γ3 grid of elevated blocks to collect KFS pieces and exit efficiently.
Key features:
- Belief-map perception β camera frames feed an OpenCV + ML pipeline that classifies each cell as
R2 | R1 | FAKE | EMPTY | UNKNOWN - Terrain-aware costs β step-up/step-down transitions are penalized proportionally to height difference (20/40/60 mm blocks)
- Dynamic priority weights β
Ξ±(collection priority) andΞ²(exit priority) shift based on current carry count - Round-trip optimization β each candidate KFS is scored by
Ξ±Β·cost_to_KFS + Ξ²Β·cost_to_exitto avoid stranding - R1 interaction handling β soft penalty in COLLECT mode, wait/reroute in EXIT mode
- Team mirroring β grid is flipped for RED vs BLUE team
The simulation environment validates the full pipeline before hardware deployment:
| Script | Purpose |
|---|---|
integration.py |
End-to-end orchestrator β step climbing, A* navigation, vision, decision loop |
navigation.py |
A* pathfinding with Isaac Sim robot articulation control |
robot_stepclimbing.py |
Pneumatic cylinder sequences (front/middle/back) for step-up and step-down |
STAR_kfs_camera_infer.py |
MobileNetV3 inference on simulated camera feed for KFS detection |
R2 uses three pneumatic cylinders (front, middle, back) for step traversal. The climb sequence is sensor-gated, not timer-based:
- Climb up: Extend middle+back β drive forward β front contacts higher surface β retract middle β advance β retract back
- Climb down: Drive till front hangs β extend front β advance β extend middle β advance β handle back (CG-dependent via IMU)
A high-performance PPO agent utilizing Action Masking and Curriculum Learning (Random β Heuristic β Self-Play) to master Tic-Tac-Toe placement and sabotage.
- Masked Discrete PPO: Ensures the agent only explores legal moves.
- Team-Agnostic Observation: A 22D normalized vector allowing play as RED or BLUE without retraining.
- Integrated Visualization: Real-time Matplotlib interface for human-vs-AI strategic validation.
Observation (22D) Masked Actor-Critic Action (Discrete 11)
βββββββββββββββββ βββββββββββββββββββββββββ ββββββββββββββββββββ
rack_matrix (9) βββ ββ Shared Layers (256x256) β 0-8: Place at (R,C)
game_stats (6) βββΌβββΆ β ReLU ββββΆ 9: Tactical Sabotage
threat_info (2) βββ€ β ββββββ΄βββββ β 10: Wait (Pass Turn)
column_state (3) βββ€ β Actor Critic β (Invalid moves are
time/weapon (2) βββ β (11 Logits) (1D V) β masked out before
ββββββββββββββββββββββββββββ
| Rule | Implementation |
|---|---|
| Placement order | Global row-based: Bottom must have β₯1 piece for Middle to open; Middle β₯1 for Top. |
| R2 Restrictions | Agent (R2) is strictly limited to Middle (Row 1) and Top (Row 2) placements. |
| Scoring | Bottom = 30 pts, Middle = 40 pts, Top = 80 pts. |
| Kung Fu Master | 3-in-a-row (Vertical or Diagonal ONLY) = 500 bonus & Instant Win. |
| Weapons | 1 per team, 90% success rate, removes any opponent piece. Used strategically. |
Zone3Controller provide the production-ready API for the Jetson:
from Zone3.RL.inference.controller import Zone3Controller
controller = Zone3Controller(checkpoint_path="model.pt", team="RED")
action = controller.decide(rack_matrix, time_remaining=60.0)
# Returns: {"action": "PLACE", "row": 2, "col": 1, "confidence": 0.98}- Metrics: JSON summaries of win rates are saved every 1,000 episodes in
logs/. - Episode Logs: Full textual replays of checkpoint episodes are dumped for strategy analysis.
Zone 1 requires R1 and R2 to collaboratively assemble a weapon (staff rod + spearhead) without the robots touching each other. One component is at the team's starting area, the other at the center of the arena (shared).
Status: Detection and assembly logic is planned (see R2_GSM_Refined.md and R2_FSM_Refined.md for the full state machine specification). Implementation is pending.
Planned approach:
- OpenCV + ML for component detection (staff = elongated contour, spearhead = pointed shape)
- Visual servoing for fine alignment during assembly
- Ultrasonic sensors for no-contact enforcement between robots
- ML-based assembly verification (geometric + classifier)
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β PERCEPTION β β DECISION β β ACTUATION β
β (Jetson) ββββββΆβ (Jetson) ββββββΆβ (STM32) β
β β β β β β
β Camera(s) β β A* Planner β β Motor PWM β
β OpenCV + ML β β RL Model β β Pneumatics β
β Encoders β β State Mgr β β Grippers β
β IMU β β β β Elevator β
β IR/Ultrasonicβ β β β Conveyor β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β² β β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
UART Feedback Loop
| Bus | Connection | Purpose |
|---|---|---|
| UART | Jetson β STM32 | Command packets + telemetry (binary, checksummed) |
| USB/CSI | Camera β Jetson | Video frames (640Γ480 @ 15-30 fps) |
| I2C | IMU β STM32 | 6-axis orientation at 100 Hz |
| GPIO/ADC | Sensors β STM32 | Encoders, IR, limit switches, pressure |
| PWM/Relay | STM32 β Actuators | Motors, solenoid valves, servos |
Full I/O specifications, serial protocol, sensor thresholds, and deployment checklists are documented in:
R2_GSM_Refined.mdβ Global State Machine (high-level zone states)R2_FSM_Refined.mdβ Finite State Machine (sub-states, pseudocode, actuator tables)
cd Zone3/RL
# Training with curriculum scheduler
python -m Zone3.RL.training.train --episodes 100000 --verbose
# Play against the trained AI
python -m Zone3.RL.viz.play_against_ai --checkpoint checkpoints/zone3_final.ptRequires NVIDIA Isaac Sim (2023.1+).
- Open Isaac Sim and load
Zone2/Navigation/IsaacSimulation/isaac/AreanaLayout_2026.usd - Run scripts from
Zone2/Navigation/IsaacSimulation/scripts/within the Isaac Sim script editor
python Zone2/Navigation/time_aware_hybrid_astar.py# Setup (from Robocon26/ root)
python -m venv .venv
.venv\Scripts\Activate.ps1 # Windows PowerShell
pip install -r requirements.txt
# Hardware-free dry run: keep SIM=True in Deployment/common/config.py
python -m Deployment.zone1.zone1 # weapon assembly pipeline
python -m Deployment.zone2.zone2 # forest traversal + step climbing
# Unit / integration tests (all SIM, no hardware)
python -m pytest Deployment/tests -vOn the real robot: set SIM=False and SERIAL_PORT in
Deployment/common/config.py, flash Deployment/firmware/esp32/r2_main, then
run the same commands. See Deployment/README.md for
the full layout, the serial protocol, and the per-zone config map.
Perception is pluggable (camera-ML / IR / manual) per zone β switch via
PERCEPTION_SOURCE in the zone config; no logic changes needed.
| Component | Status | Notes |
|---|---|---|
| Zone 2 A* planner | β Complete | Neighboring pickup, discovery bonus, cost-based 3rd carry, exit-cell priority |
| R2 Deployment tree | β Rebuilt | Unified Deployment/ (common HAL + zone1 + zone2 + firmware + tests); 3 ESP32 boards (drive / sensor / manip) on 3 USB links + Jetson Orin Nano brain, logical-subsystem routing |
| Zone 2 deployment | β Reworked | A* bridge + NEW 2-piston step climber + pluggable grid perception; SIM-verified end-to-end |
| Zone 2 Isaac Sim integration | β Implemented | Step climbing + navigation + vision pipeline |
| Zone 2 MobileNetV3 KFS detection | β Implemented | Trained model, simulated camera inference |
| Zone 3 RL environment | β Overhauled | New discrete 10 action space with masking |
| Zone 3 PPO training | β Overhauled | Curriculum-based: Random -> Heuristic -> Self-Play |
| Zone 3 deployment inference | β Complete | Zone3Controller implemented for hardware integration |
| Zone 1 weapon assembly | β Pipeline built | SEARCHβALIGNβPICKβTURNβPRESENTβWAITβRELEASEβEXIT FSM; camera/IR perception toggle; SIM-verified |
| R2 GSM/FSM specification | β Complete | Full I/O, protocols, sensor tables |
| Real robot firmware integration | π In progress | Sim β hardware transfer ongoing |
| Document | Description |
|---|---|
R2_GSM_Refined.md |
Global State Machine β zone-level states, transitions, data flows |
R2_FSM_Refined.md |
Finite State Machine β 20+ sub-states, serial protocol, sensor/actuator tables |
ABU Robocon 2026 Rulebook V.0.pdf |
Official competition rulebook |
ABU Robocon 2026 is a wrap. Thanks to everyone on Team Vulcans who put time into this stack β perception, navigation, RL, firmware, and everything in between. See you at the next one.
This project is licensed under the MIT License β see LICENSE for details.