# Python SDK

> Install menlo-sdk, run the example scripts and operate the robot from the command line.

- Page: https://docs.menlo.ai/asimov/1/program/sdk
- Section: Asimov › Asimov 1 › Program Asimov 1
- Next: [Overview](https://docs.menlo.ai/asimov/1/program/api.md)

`menlo-sdk` drives the robot from Python: stand, balance, walk, joints, state, camera and
audio, over the robot's network or its LiveKit room. It is a client of Asimov Edge, so every
command passes through the robot's safety layer, and the Drive Robot page and a paired gamepad
outrank it.

Two guides cover it. [Drive from Python](https://docs.menlo.ai/asimov/1/operate/drive/python-sdk.md) is the hands-on
path: the robot's settings, a credential, install, and a first walk with video and sound.
The [Python SDK](https://docs.menlo.ai/sdk.md) section is the depth: every connection mode, verb, error and example.

> [!WARNING]
>
> **Before the robot moves**
>
> For a first run, hang the robot from its gantry hook with both feet on the floor, and give a
> walk 2 m of clear floor ahead. Nothing in the SDK is an emergency stop: keep the
> E-Stop in Asimov Manager open, or be ready to cut power at the battery unit. Read
> [Safety](https://docs.menlo.ai/sdk/safety.md) before the first run.

## Install

Python 3.12 or newer.

```bash
pip install menlo-sdk
menlo setup
```

`menlo setup` asks for a connection mode and what it needs, checks them against the robot,
and saves the robot, so every script and command below finds it without arguments. The
`udp` mode needs the robot to send UDP state to your computer; `hybrid` and `livekit` need an
SDK credential from the Developer page in Asimov Manager
([Drive from Python](https://docs.menlo.ai/asimov/1/operate/drive/python-sdk.md#get-an-sdk-credential)).

## Run the Examples

```bash
git clone https://github.com/menloresearch/menlo-sdk.git
cd menlo-sdk/examples
```

1. `python check.py` reports what the robot reports: robot mode, arming, faults, alerts,
   the hottest joint and the battery. It sends nothing.
2. `python stand.py` stands the robot up and returns once it is armed. Hang the robot from
   its gantry hook with both feet on the floor first: STAND has no balance loop.
3. `python balance.py` puts the robot in MOVE at zero velocity, where the walking policy
   balances it. Slacken the gantry only after it returns.
4. `python walk.py` walks forward at 0.3 m/s for 3 s, then balances in place. Give the robot
   2 m of clear floor ahead.
5. `python rest.py` brings the robot to rest: MOVE, then STAND, then DAMP. It asks first
   whether the robot is hanging from its gantry hook or seated on a stool or bench. `python
   damp.py` puts the robot in DAMP directly: every actuator stops holding its position, so a
   standing robot falls. Hang it from its gantry hook or seat it on a stool or bench first.
6. `python keyboard.py` drives from the keyboard: `w`/`s` walk, `a`/`d` strafe, `q`/`e`
   turn, space balances in place, `t` stands (asks first in MOVE), `b` damps after asking,
   `x` quits. It walks the robot backward and sideways too: keep clear floor all around it.

The SDK refuses a command only when there is no live state; the firmware decides the rest.
`stand.py`, `balance.py`, `walk.py` and `keyboard.py` carry `guard(robot)` from `guard.py`
commented out: an example guard of your own that stops the script on a fault, an alert, a
hot actuator or a low battery. Uncomment its two lines in a script to turn it on. The rest of the scripts, including the camera, microphone and speaker, are in
[Examples](https://docs.menlo.ai/sdk/examples.md); the sequence and why it is ordered this way are in
[Standing and Balancing](https://docs.menlo.ai/sdk/safety.md#standing-and-balancing).

## Operate from the Command Line

The same verbs, without a script:

```bash
menlo status
menlo stand
menlo balance
menlo walk --vx 0.3 --duration 3
menlo damp
```

`menlo status` sends nothing. `menlo stand`, `menlo balance`, `menlo walk` and `menlo damp`
show the robot's facts and ask `Proceed? [y/N]` before they send, unless you pass `-y`.
`stand`, `balance` and `walk` refuse only when there is no live state. See
[Command Line](https://docs.menlo.ai/sdk/cli.md).

## Learn More

- [Quickstart](https://docs.menlo.ai/sdk/quickstart.md): the check, stand, balance, walk and damp scripts, line by line
- [Move the Robot](https://docs.menlo.ai/sdk/move.md): velocity, holding it, limits, ending a walk
- [Connection Modes](https://docs.menlo.ai/sdk/connection-modes.md): `udp`, `hybrid` and `livekit`
- [SDK Reference](https://docs.menlo.ai/sdk/reference.md): every class, verb and error
