> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rua.hud.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Legged robot

> A Unitree Go2: walk by velocity, or drive every leg joint.

> [!NOTE]
>
> **Class** `articulated_mobile_base` · **Parts** `base`, or one part per leg · **Env** `legged` (Unitree Go2)

Two references, one per run:

| | `loco` | `joints` |
| - | - | - |
| Parts | `base` | `front_left`, `front_right`, `rear_left`, `rear_right` |
| Space | `base_vel` | `joint_abs` |
| Dimensions | `vx` -1.0 to 1.5 m/s, `vy` ±0.5 m/s, `wz` ±57 deg/s | `hip_abd`, `hip`, `knee` per leg, in degrees, named `<leg>_<joint>` such as `front_left_knee` |
| Carried out by | a pretrained walking policy | the joint servos directly |

## Example spec

`loco` is one `base` part. `joints` is one part per leg, with the ranges below intersected with each joint's range in the model.

```python Spec theme={"dark"}
import math

from rua.direct import Dim, Part, RobotSpec

LEGS = ("front_left", "front_right", "rear_left", "rear_right")
LEG_RANGES_DEG = {"hip_abd": (-48.0, 48.0), "hip": (-90.0, 200.0), "knee": (-156.0, -48.0)}

LOCO = RobotSpec(
    "articulated_mobile_base",
    "base_vel",
    (
        Part(
            "base",
            "base_vel",
            (
                Dim("vx", "m/s", -1.0, 1.5, max_accel=1.0),
                Dim("vy", "m/s", -0.5, 0.5, max_accel=1.0),
                Dim("wz", "rad/s", -1.0, 1.0, max_accel=math.radians(180)),
            ),
        ),
    ),
)

JOINTS = RobotSpec(
    "articulated_mobile_base",
    "leg joint_abs",
    tuple(
        Part(
            leg,
            "joint_abs",
            tuple(
                Dim(
                    f"{leg}_{joint}",
                    "rad",
                    math.radians(low),
                    math.radians(high),
                    max_speed=math.radians(180),
                )
                for joint, (low, high) in LEG_RANGES_DEG.items()
            ),
        )
        for leg in LEGS
    ),
)

SPEC = LOCO
```

## Example calls

`loco`: walk forward, then stop.

```json move theme={"dark"}
{
  "keyframes": [
    {"t": 3.0, "base": {"vx": 0.5}},
    {"t": 4.0, "base": {"vx": 0.0}}
  ]
}
```

`joints`: shift the weight back and right, every foot down. This is a call for the `JOINTS` spec.

```json move joints theme={"dark"}
{
  "keyframes": [
    {
      "t": 2.5,
      "front_left": {"front_left_hip_abd": 8, "front_left_hip": 42, "front_left_knee": -108},
      "front_right": {"front_right_hip_abd": 8, "front_right_hip": 42, "front_right_knee": -108},
      "rear_left": {"rear_left_hip_abd": 8, "rear_left_hip": 42, "rear_left_knee": -112},
      "rear_right": {"rear_right_hip_abd": 8, "rear_right_hip": 42, "rear_right_knee": -112}
    }
  ]
}
```

```json done theme={"dark"}
{"reason": "The robot is on the step."}
```

## What comes back

The part values and, for `joints`, a `state.trunk` readout: odometry, foot contacts, trunk roll and pitch, and height. Front (head) and chase cameras.

## Limits

* `loco` vetoes base acceleration (1 m/s², 180 deg/s²). `joints` vetoes joint speed (180 deg/s) and self-collision.
* With `joints` the agent keeps the robot balanced, and calls are slow compared with a gait. Walking needs `loco`.
* The walking policy takes only velocity, so the trunk posture (height, roll, pitch) is not commandable.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.