This simulation drives a six-legged walking robot shown in top-down view as it strides across scrolling terrain. Each of its six legs is a two-link arm — a femur of length 36 and a tibia of length 48 — and the knee angle is solved analytically with the law of cosines from the hip and foot positions. A central gait clock schedules which feet are planted and which are swinging, so the body advances smoothly while the legs cycle.
The Speed slider (0.3–2.5) sets how fast the body travels and how far each foot reaches forward. Two gait buttons switch between the fast alternating tripod and the slower, steadier wave gait, while the Terrain button toggles flat ground and rolling sinusoidal hills. Live read-outs report the active gait, step count and how many of the six legs are currently in stance — the principles real walking machines rely on for stable locomotion.
What is a hexapod walker?
A hexapod is a six-legged walking robot. Having six legs lets it keep several feet on the ground at all times, so it stays statically stable without the active balancing that bipeds or quadrupeds need. This page animates such a robot, coordinating its legs to walk across changing terrain.
How does the inverse kinematics work?
Each leg has two links — a femur of length 36 and a tibia of length 48. Given the hip position and the desired foot position, the code measures the straight-line distance and applies the law of cosines to find the knee angle. That single closed-form calculation places the knee joint, so no iterative solver is required.
What is the difference between tripod and wave gaits?
In the tripod gait the legs split into two alternating sets of three; one set swings forward while the other three stay planted, giving a fast walk with always exactly three feet down. The wave gait instead lifts one leg at a time through six sequential phases — slower, but it keeps five legs grounded for maximum stability.
The Speed slider sets the body velocity and how far each foot steps forward, from 0.3 to 2.5. The Tripod and Wave buttons select the gait pattern, and the Terrain button toggles between flat ground and bumpy sinusoidal hills. The stat badges show the current gait, the running step count and the number of legs in stance.
The view uses a body-fixed camera: the robot is always drawn at the centre of the screen and the world scrolls past it instead. This keeps the leg coordination clearly visible. Internally the body still advances along a world X coordinate, which the terrain grid and hills are rendered against.
On flat mode the ground is simply the mid-line of the screen. In bumpy mode the height is the sum of three sine waves of different frequencies and phases, producing smooth, irregular rolling hills. Each foot's landing height is sampled from this terrain function so the feet plant on the surface rather than floating.
It depends on the gait. The tripod gait always keeps three of the six legs planted while the other three swing. The wave gait lifts just one leg at a time, leaving five in stance. The "Stance" badge reports this count live, typically reading 3/6 for tripod and 5/6 for wave.
It is a kinematic model, not a full dynamics one: it reproduces realistic leg geometry, gait timing and foot placement, but it does not compute forces, ground reaction or balance from mass. The law-of-cosines IK and the gait scheduling mirror how real hexapod controllers are built, so the motion is believable even without rigid-body physics.
During the stance phase a foot is planted and pushes the body forward; during the swing phase it lifts off, arcs ahead and lands at a new target. Here swinging feet are drawn smaller and amber, while planted feet are larger and red, so you can read the phase of each leg at a glance.
Six-legged robots are used for search-and-rescue, inspection of rough or hazardous terrain, planetary exploration and research into insect-inspired locomotion. Their inherent stability and ability to step over obstacles make them well suited to ground that wheels or two legs cannot handle reliably.