ESP32 Self-Balancing Quadruped Robot With ROS 2 Wireless Control and 3D GUI

by xprobyhimself in Circuits > Robots

1 Views, 0 Favorites, 0 Comments

ESP32 Self-Balancing Quadruped Robot With ROS 2 Wireless Control and 3D GUI

Untitled design (3).png
January 19, 2026

This DIY quadruped robot uses an ESP32, micro-ROS, and ROS2 for advanced self-balancing with PID control, smooth walking gaits, and obstacle distance sensing via ultrasonic. It includes a stunning cyberpunk-themed GUI with real-time 3D orientation visualization, roll/pitch plots, PID tuning, and manual/keyboard controls. Perfect for robotics enthusiasts!

Capabilities:

  1. Auto-balances on uneven surfaces using MPU6050 IMU
  2. Walks forward/backward/left/right with adjustable speed and gait
  3. Publishes distance data from HC-SR04 (ready for future obstacle avoidance)
  4. Cyberpunk GUI with neon styling and 3D robot attitude cube
  5. Keyboard or button control, per-leg overrides, sensor calibration

Downloads

Supplies

wireless Spider Robot microRos
hamedtaha-NEqR20e6eY4-unsplash.jpg
MPU6050-Pinout.png
dwad.jpg
hc.jpg
serv.jpg
batt.jpg
FO97T5WM085IEU8.jpg

Materials

  1. ESP32 development board
  2. PCA9685 16-channel PWM servo driver
  3. 8 × MG90S or similar metal gear servos (180° range)
  4. MPU6050 IMU module
  5. HC-SR04 ultrasonic sensor
  6. 3D-printed quadruped frame (4 legs, 2 servos per leg)
  7. 5–6V power supply/battery for servos (separate from ESP32)
  8. Jumper wires, breadboard or PCB
  9. Computer running Ubuntu 22.04 (for ROS2)

3D Print the Frame

Self-Balancing Quadruped Spider Robot with ROS2 and Neon 3D GUI
20250728_182049.jpg
20250728_181650.jpg
20250728_182240.jpg
20250728_182326.jpg
20250806_142857.jpg
20250806_152327.jpg
20250806_153022.jpg
20250826_002737.jpg
20250826_003739.jpg
20250827_235547.jpg
20250728_185435.jpg


Slicing Settings (Cura, PrusaSlicer, or similar)

  1. Layer Height: 0.2 mm (0.15 mm for smoother joints)
  2. Infill: 25–40% (Gyroid or Grid)
  3. Walls: 3–4 (1.2–1.6 mm thickness)
  4. Supports: Tree supports where required (overhangs on legs/mounts)
  5. Adhesion: 8–10 mm brim
  6. Temperatures: Nozzle 200–210°C, Bed 60°C
  7. Orientation: Body flat on bed; legs positioned to minimize supports

Printing Sequence

  1. Print the body first (monitor initial layers).
  2. Print the Top.
  3. Print upper legs.
  4. Print lower legs.

Post-Processing

  1. Carefully remove supports with pliers or cutters.
  2. Sand joints (220–400 grit) for smooth servo fit.
  3. Test-fit servos (no screws initially); ream holes if needed.
  4. Assemble using servo horns and screws (no glue required for joints).

The frame is now ready for electronics integration.

Assemble the Robot

V2++mpu.png
V2++shema.png


  1. Attach hip servos to the body (one per leg corner).
  2. Connect knee servos to the lower leg parts.
  3. Mount legs to hips — ensure symmetric layout (front-right, front-left, rear-right, rear-left).
  4. Secure the ESP32, PCA9685, MPU6050 (centered), and HC-SR04 (front-facing) on the body.
  5. Test servo fit — horns should allow full leg movement without binding.

Wire the Electronics

  1. Connect PCA9685 to ESP32 default I2C (SDA=21, SCL=22).
  2. Wire all 8 servos to PCA9685 channels 0–7.
  3. MPU6050 to secondary pins: SDA=32, SCL=33.
  4. HC-SR04: Trig=25, Echo=26.
  5. Power servos separately (common ground with ESP32).

Example wiring:

Upload Firmware to ESP32

Screenshot from 2026-01-18 00-21-19.png
  1. Install PlatformIO (VS Code extension).
  2. Clone the repo:
git clone https://github.com/ReizarXPro/MicroRos-Spider-Robot-quadrupedV3-
  1. Open the project, edit main.cpp: update WiFi SSID/password and agent IP (your PC's IP).
  2. Upload to ESP32. LED should light up when connected.

Install ROS2 and Dependencies

On Ubuntu 22.04:

sudo apt update && sudo apt install ros-humble-desktop
pip3 install matplotlib numpy rclpy
sudo apt install python3-tk

Setup and Run Micro-ROS Agent

Screenshot from 2026-01-18 18-54-32.png
Screenshot from 2026-01-18 18-56-30.png
Screenshot from 2026-01-18 19-00-33.png

Setup and Run micro-ROS Agent

  1. Install micro-ROS agent (use Docker for ease):
docker pull microros/micro-ros-agent:humble
docker run -it --rm --net=host microros/micro-ros-agent:humble udp4 --port 8888

(Or build from source if needed.)

Run the Controller and GUI

In separate terminals (source ROS2 each time: source /opt/ros/humble/setup.bash):

Terminal 1 (Controller):

python3 quadruped_controller_pid.py

Terminal 2 (Main GUI — recommended):

python3 quadruped_gui.py

Optional: Standalone IMU visualizer

python3 gui_gy.py

GUI example :

Calibrate and Test

ESP32 Self-Balancing Quadruped Robot With ROS 2 Wireless Control and 3D GUI
22.png
11.png
33.png

Calibrate and Test

  1. Place robot on flat surface.
  2. In GUI, click "CALIBRATE SENSORS".
  3. Use stance buttons to stand up.
  4. Tune PID (start low Kp ~0.2) while gently tilting.
  5. Enable walking — use WASD/arrows or buttons!

Enjoy your SpiderBot — it balances, walks, and looks futuristic! Share improvements on GitHub, Instructables .