Skip to content

imorlxs/sumo-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sumo Bot

An autonomous sumo wrestling robot for AVR microcontrollers featuring pluggable strategies and hardware abstraction for motors, distance sensing, and line detection.

Overview

Target: AVR (e.g., ATmega328P) at 16 MHz Behavior: Selectable autonomous strategies via a strategy pattern Core sensors: HC-SR04 ultrasonic for opponent detection; CNY70 reflective for arena boundary Actuators: Dual DC motors via L298N driver with differential drive

Hardware

Component Driver Pins (Arduino) Notes
HC-SR04 (ultrasonic) hcsr04.h/c TRIG: PB4 (12); ECHO: PD2 (2) Interrupt-driven pulse timing via INT0 and Timer1
L298N (motor driver) l298n.h/c Left: IN1=PB3(11), IN2=PD3(3), EN=PB2(10); Right: IN1=PD7(7), IN2=PB0(8), EN=PB1(9) Differential drive; PWM enable pins
CNY70 (line sensor) cny70.h PD4 (4) Digital black/white detection

Software Architecture

  • Strategy Pattern: Runtime selection of robot behaviors via function pointers. See include/core/strategy.h and src/core/strategy.c.
  • Strategies:
    • basic_seek_and_attack: Rotate until opponent ≤10 cm, then charge .
    • line_seek_and_attack: Adds boundary evasion using CNY70 .
  • Main Application: Initializes hardware, selects a strategy, and runs it indefinitely.

Building and Running

This project uses PlatformIO. Ensure platformio.ini is configured for the AVR target. Build and flash with:

pio run --target upload

The robot will wait 3 seconds after power-on before starting the selected strategy.

Adding a New Strategy

  1. Create src/strategies/my_strategy.c with my_strategy_init() and my_strategy_run() (infinite loop).
  2. Add enum value to strategy_t in include/core/strategy.h.
  3. Add function declarations to include/core/strategy.h.
  4. Add a case in src/core/strategy.c to assign function pointers.
  5. Select in main.c via strategy_init(STRATEGY_MY_STRATEGY).

Notes

  • The strategy manager uses static function pointers for runtime dispatch with minimal RAM overhead (4 bytes) .
  • Distance sensing includes robust error handling and retries.
  • Motor control includes safety delays between direction changes.

About

An autonomous sumo wrestling robot for AVR microcontrollers featuring pluggable strategies and hardware abstraction for motors, distance sensing, and line detection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages