Introduction
Build a 12-DOF quadruped robot inspired by Boston Dynamics Spot with trot gait and terrain adaptation. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Build a 12-DOF quadruped robot inspired by Boston Dynamics Spot with trot gait and terrain adaptation.
Build a 12-DOF quadruped robot inspired by Boston Dynamics Spot with trot gait and terrain adaptation. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Each leg has 3 revolute joints: hip abduction/adduction (side motion), hip flexion/extension (fore-aft), knee flexion. The 3-link chain (coxa-femur-tibia) forms a 3R kinematic chain in 3D space. Forward kinematics: toe position from joint angles via DH matrix multiplication. Inverse kinematics: given toe position (x,y,z), compute joint angles. Closed-form solution for 3R chain with geometric decomposition into sub-problems.
10 components required for this project.
| # | Component | Purpose | Qty |
|---|---|---|---|
| 1 | Dynamixel XL430-W250 Servos | 12 joint motors (3 per leg) | x12 |
| 2 | Raspberry Pi 4 (8GB) | Main computer for ROS | x1 |
| 3 | Intel RealSense D435i | Depth camera for terrain mapping | x1 |
| 4 | Custom Aluminum Frame | Rigid lightweight body structure | x1 |
| 5 | Dynamixel U2D2 Interface | Servo bus to USB communication | x1 |
| 6 | IMU (Vectornav VN-100) | High-accuracy attitude reference | x1 |
| 7 | LiPo 14.8V 10000mAh | Motor power supply | x1 |
| 8 | Force/Torque Sensors (ATI Mini45) | Foot contact force measurement | x4 |
| 9 | Compact DC-DC Converters | 5V/12V distribution from battery | x3 |
| 10 | Emergency Stop Button | Safety cutoff | x1 |
Follow these 3 steps carefully.
Each leg has 3 revolute joints: hip abduction/adduction (side motion), hip flexion/extension (fore-aft), knee flexion. The 3-link chain (coxa-femur-tibia) forms a 3R kinematic chain in 3D space. Forward kinematics: toe position from joint angles via DH matrix multiplication. Inverse kinematics: given toe position (x,y,z), compute joint angles. Closed-form solution for 3R chain with geometric decomposition into sub-problems.
Trot gait: diagonal leg pairs move together (FR+RL, FL+RR alternating). Each cycle: first diagonal pair in stance (on ground, providing support), second diagonal in swing (lifted, moving forward). Timing: 50% duty cycle, symmetric. Generate foot trajectories: swing foot follows a cycloidal curve (smooth lift-forward-plant). Stance foot: moves backward at body speed (propulsion). Adjust body height to maintain ground clearance during swing.
Process depth camera point cloud to estimate terrain height map. For each foot placement point, sample the height map to know exact ground level. Adjust foot target height accordingly — step higher on raised terrain, avoid holes. Implement a foothold planner: evaluate candidate footholds around desired placement point, score based on flatness, stability, and distance from edges. Select highest-scored safe foothold.
Core code for quadruped_gait.py:
import numpy as np
class QuadrupedGait:
def __init__(self, body_length=0.3, body_width=0.2, leg_length=0.15):
self.L = body_length; self.W = body_width; self.l = leg_length
# Default foot positions (FR, FL, RR, RL) relative to body center
self.stance_feet = np.array([
[ L/2, -W/2, -l], # FR
[ L/2, W/2, -l], # FL
[-L/2, -W/2, -l], # RR
[-L/2, W/2, -l], # RL
])
def trot_trajectory(self, t, stride=0.1, freq=1.0, height=0.05):
"""Returns foot positions at time t for trot gait"""
phase = (t * freq) % 1.0
foot_pos = self.stance_feet.copy()
# Diagonal pairs: FR+RL in phase, FL+RR antiphase
for i, swing_phase in enumerate([phase, phase+0.5, phase+0.5, phase]):
sp = swing_phase % 1.0
if sp < 0.5: # Swing phase
foot_pos[i][0] += stride * (sp * 2 - 0.5) # X swing
foot_pos[i][2] += height * np.sin(np.pi * sp * 2) # Z lift
else: # Stance phase
foot_pos[i][0] -= stride * (sp - 0.5) * 2 # X pushback
return foot_pos
Test Quadruped Robot by verifying each subsystem individually before full integration.
Verify power voltages, check ground connections, use serial monitor for debug.
An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.