Skip to content

dtecx/hexabot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hexa-Bot ESP32 Firmware

Hexa-Bot is a six-legged walking robot controlled by an ESP32, two PCA9685 PWM servo drivers and a Bluetooth gamepad. The firmware implements inverse kinematics for all six legs, a tripod gait, body tilt demonstration mode and simple runtime adjustments for speed and body height.

The mechanical shell is based on an existing open 3D model, while the electronics, power system and firmware were built as a custom engineering project.

Main features

  • ESP32-based robot controller using the Arduino framework.
  • Two PCA9685 boards drive 18 MG996R servos over I2C.
  • Inverse kinematics for coxa, femur and tibia joints.
  • Tripod gait for forward/backward motion, strafing and rotation.
  • Bluetooth gamepad control through Bluepad32.
  • Runtime speed and body-height adjustment from the D-pad.
  • Following mode where the body pitch/roll follows the right joystick.
  • Short squat animation triggered from the gamepad.
  • Servo interpolation for smoother movement.

Hardware overview

Part Purpose
ESP32-WROOM-32D development board Main controller, Bluetooth gamepad link and motion logic
2x PCA9685 16-channel PWM drivers Servo PWM generation for 18 independent servos
18x Tower Pro MG996R servos Three joints per leg: coxa, femur and tibia
ESP32 terminal adapter More reliable wiring through screw terminals
3S Li-Pol battery, 11.1 V, 1550 mAh Main battery pack
20 A step-down converter 6 V power rail for the servo power circuit
LM2596S step-down converter Separate logic power rail for ESP32 and PCA9685 boards

The power system intentionally separates the high-current servo rail from the logic rail. This prevents voltage drops caused by servo load spikes from resetting the ESP32 or breaking the Bluetooth connection.

Repository structure

hexabot/
├── include/
│   ├── Config.h              # Physical constants, pins, limits and calibration values
│   ├── ControllerInput.h     # Bluepad32 controller handling
│   ├── Gait.h                # Tripod gait and body-following pose generation
│   ├── Hardware.h            # PCA9685 and servo abstraction
│   ├── Kinematics.h          # Per-leg inverse kinematics
│   ├── Robot.h               # Public setup/update entry points
│   ├── RobotState.h          # Shared robot state
│   └── StatusLed.h           # Built-in LED status helpers
├── src/
│   ├── Config.cpp
│   ├── ControllerInput.cpp
│   ├── Gait.cpp
│   ├── Hardware.cpp
│   ├── Kinematics.cpp
│   ├── Robot.cpp
│   ├── RobotState.cpp
│   ├── StatusLed.cpp
│   └── main.cpp              # Minimal Arduino entry point
├── docs/
│   └── project-notes.md
├── .clang-format
├── .gitignore
├── platformio.ini
└── README.md

Controls

Control Mode Action
Y Waiting / Walking / Following Toggle between waiting and active motion modes
X Walking / Following Toggle between walking mode and body-following mode
Left stick Y Walking Forward / backward motion
Left stick X Walking Strafe left / right
Right stick X Walking Rotate while walking
Hold B + left stick X Walking Rotate in place
Right stick X/Y Following Roll / pitch the body
A Walking / Following Squat animation, only when safe to execute
D-pad up / down Any non-pairing mode Increase / decrease gait speed multiplier
D-pad left / right Any non-pairing mode Lower / raise body height offset

Build and upload

This repository is prepared for PlatformIO in VS Code.

pio run
pio run -t upload
pio device monitor

Default serial monitor speed is 115200 baud.

Calibration

Important values are stored in include/Config.h and src/Config.cpp:

  • COXA_LENGTH_MM, FEMUR_LENGTH_MM, TIBIA_LENGTH_MM define leg segment lengths.
  • HOME_X, HOME_Y, HOME_Z define neutral toe positions.
  • BODY_X, BODY_Y, BODY_Z define coxa positions relative to the robot body centre.
  • COXA_CAL, FEMUR_CAL, TIBIA_CAL define per-servo angle offsets.
  • SERVO_MIN_US and SERVO_MAX_US define the PWM pulse range.

Before testing full motion, lift the robot so the legs are unloaded, verify each joint direction, then test at low speed.

Safety notes

  • Do not power the servos from the ESP32 5 V pin.
  • Use a dedicated high-current converter for the servo rail.
  • Keep the ESP32 and PCA9685 logic rail separate from the servo power rail.
  • Make sure all grounds are common.
  • Test servo direction and calibration before mounting all legs under load.
  • Stop immediately if a servo stalls, overheats or pushes against a mechanical limit.

References and credits