# Quadruped kinematics

The dependency-free pose solver behind the quadruped. Four legs, three footfall patterns, and bounded controls that keep every foot reachable.

> For the complete index, see [llms.txt](https://robocn.dev/llms.txt). A Markdown version of any page is available by appending `.md` to its URL or by sending an `Accept: text/markdown` header.

## Install

```bash
bunx --bun shadcn@latest add https://robocn.dev/r/quadruped-kinematics.json
```

Registry item: `quadruped-kinematics` · [`https://robocn.dev/r/quadruped-kinematics.json`](https://robocn.dev/r/quadruped-kinematics.json)

## Notes

- The solver has no React or three.js dependency and does not mutate its inputs. Each side can be projected independently for an SVG or 3D renderer.
- These are illustrative gait trajectories, not a stability or dynamics model. Walk staggers quarter-cycle swings; trot pairs opposite corners.

## Usage

```tsx
import { solveQuadruped } from "@/lib/robocn/quadruped"

const pose = solveQuadruped({ gait: "walk", phase: 0.4, height: 0.6 })
pose.legs // id, side, hip, knee, foot, contact
pose.height // hip height in world units
```

## API

| name | type | default | description |
| --- | --- | --- | --- |
| `solveQuadruped` | `(options?: QuadrupedOptions) => QuadrupedPose` | — | Solves hip/knee/foot coordinates for front-left, front-right, rear-left, and rear-right, in that order. |
| `QuadrupedOptions` | `{ gait?, phase?, height?, stride?, lift? }` | — | Same gait and normalized stance controls as RobotQuadruped. Defaults to a neutral standing pose. |
| `QuadrupedLeg` | `{ id, side, hip: Vec2, knee: Vec2, foot: Vec2, contact }` | — | Coordinates in a sagittal plane: x points forward and y up. Upper links are 30 units, lower links 28. Contact means foot y is within 1e-7 of zero. |

## Source

- `src/lib/robocn/quadruped.ts`
