Skip to content

yashdoke7/robocon26

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

212 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ABU Robocon 2026 β€” Team Vulcans

Software stack for the R2 autonomous robot competing in ABU Robocon 2026.


Overview

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.


Repository Structure

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

Zone 2 β€” Navigation & Step Climbing

Time-Aware Hybrid A*

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_exit to 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

Isaac Sim Simulation

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

Step Climbing

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)

Zone 3 β€” Tic-Tac-Toe RL Agent

Architecture

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
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Game Rules Encoded

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.

Deployment & Monitoring

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 β€” Weapon Assembly

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)

System Architecture (R2)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  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:


Getting Started

Zone 3 RL Training

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.pt

Zone 2 Isaac Sim

Requires NVIDIA Isaac Sim (2023.1+).

  1. Open Isaac Sim and load Zone2/Navigation/IsaacSimulation/isaac/AreanaLayout_2026.usd
  2. Run scripts from Zone2/Navigation/IsaacSimulation/scripts/ within the Isaac Sim script editor

Zone 2 A* (Standalone)

python Zone2/Navigation/time_aware_hybrid_astar.py

R2 Deployment (Zone 1 & Zone 2)

# 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 -v

On 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.


Implementation Status

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

Documentation

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

GGs

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.


License

This project is licensed under the MIT License β€” see LICENSE for details.

About

πŸš€ Software stack for R2, Team Vulcans' autonomous robot for ABU Robocon 2026 β€” competition complete.

Resources

Stars

Watchers

Forks

Contributors

Languages