Competition robowar firmware — differential drive mixing, weapon arming and hard failsafe
Control firmware for the RC robowar bots campaigned across the 8 kg, 15 kg and 30 kg classes. One control architecture serves all three weight classes — only the drive motors, ESC current rating and battery scale up with the robot.
This is combat hardware, so the engineering priority is not features but deterministic failure behaviour. A 15 kg robot with a spinning weapon that loses radio link is a safety problem, and the failsafe path below is the part of this firmware that matters most.
Rebuilt after the original project files were lost to a hard disk failure.
| Layer | Implementation |
|---|---|
| Signal Capture | Interrupt-driven pulse-width measurement of the RC receiver's steering, throttle and weapon channels — no blocking pulseIn() in the control loop |
| Drive Mixing | Steering and throttle mixed into differential left/right velocities, emitted as PWM + DIR pairs to the motor driver |
| Weapon Arming | The spinner ESC arms only above a 1700 µs threshold on a dedicated channel, never sharing a channel with drive |
| Failsafe | Loss of a valid RC pulse for 300 ms — out of range, transmitter off, wiring fault — cuts drive and disarms the weapon automatically |
| Status Feedback | A single LED distinguishes healthy link (solid) from failsafe (blinking), readable from outside the arena |
RC receiver
| steering / throttle / weapon channels
v
[ interrupt-driven pulse width capture ]
|
+--> valid pulse within 300 ms? ---- NO ----> FAILSAFE
| - drive motors cut
| - weapon disarmed
YES - status LED blinks
|
+--> [ differential mixing ] --> L/R PWM + DIR --> motor driver
|
+--> [ weapon channel > 1700 us ] --> ESC arm --> spinner
| Signal | ESP32 Pin | Notes |
|---|---|---|
| Steering channel (RC in) | GPIO 34 | Input-only pin |
| Throttle channel (RC in) | GPIO 35 | Input-only pin |
| Weapon arm channel (RC in) | GPIO 32 | Input-only pin |
| Left motor PWM | GPIO 25 | To motor driver |
| Left motor DIR | GPIO 26 | To motor driver |
| Right motor PWM | GPIO 27 | To motor driver |
| Right motor DIR | GPIO 14 | To motor driver |
| Weapon ESC signal | GPIO 33 | Standard 1000-2000us servo pulse |
| Status LED | GPIO 2 | Solid = signal OK, blinking = failsafe |
Drive motor driver: any PWM+DIR style dual motor driver rated for the weight class (e.g. Cytron MDD10A for 8kg, higher-current driver for 15kg/30kg).
- ESP32Servo library (for weapon ESC control)
- Weapon only arms above a clear RC pulse threshold (1700us) on a dedicated channel — never on the same channel as drive.
- Failsafe disarms the weapon and stops drive on any signal loss.
- Always test with the weapon motor disconnected first when bringing up a new build.
| Path | Purpose |
|---|---|
CombatRobotController.ino |
Full firmware — capture, mixing, arming, failsafe state machine |
Implemented: interrupt-driven RC capture, differential drive mixing, dedicated-channel weapon arming, 300 ms link-loss failsafe, status indication.
Competition record: this control architecture placed across Robowars events at IIT Delhi, IIT Madras, DTU, MNIT, COEP, PEC and others — see the full competition record.
Roadmap: current-sense telemetry on the weapon ESC to detect stall/jam conditions, and a brownout-aware restart path.
90+ national & international competition wins · IIT / NIT / IIIT podiums