# Deploy a policy to your robot

> Connect a robot, ask to run a policy on it, approve the request, watch it run, and stop it.

Prompt for your AI: Read https://mousemouse.ai/docs/deploy-to-a-robot.md first. Help me get one of my policies running on my robot. You may ask for the deployment; I will approve it myself. Ask me before anything that costs money or moves a robot.

This guide puts one of your policies on a robot you connected, for a few
minutes, and stops it. A person approves every run. [How approvals keep your
robot safe](/docs/approvals) explains why it works this way.

You need a policy, such as the one from [the tutorial](/docs/first-policy). You
also need a robot of the kind it was trained for.

## 1 · Connect the robot

On the robot's page, open **Deploy → Connect a robot**.

1. **On the robot's computer.** The page shows a short code, valid for ten
   minutes. It also shows the lines to paste there: the driver's installer, the
   `PATH` line, `lucen-device pair` with your code, and `lucen-device serve`.
   The robot makes its own key. It never holds an API key.
   A robot that ships with the driver shows its own code instead; type it on the
   page.
2. **Confirm it is your robot.** The page shows what claimed the code: its
   software, the fail-safe the driver checked, and its key fingerprint. The
   robot's screen shows the same fingerprint. Name it and press **Confirm**. Only a signed-in
   person can do this.
3. **Connected.** The robot reads **Online** while `lucen-device serve` runs on
   it. It is listed under [My robots](/settings/devices).

No hardware yet? The driver's built-in `virtual` robot runs no physics and moves
nothing, so you can rehearse the whole path. A real robot needs an adapter of
its own: [Connect your robot](/docs/connect-your-robot) shows how to write one.

## 2 · Ask to deploy

On the policy's page, press **Deploy to robot**. Pick an online robot and how
long the policy may run: 1, 2, 5 or 10 minutes. After that it stops by itself.

Before you decide, the page shows what the hub checked:

- the robot accepts this policy's inputs and outputs;
- this kind of policy may run on the robot;
- the fail-safe the robot declared;
- the latest sim test of this policy on this robot;
- the policy still matches the robot's current description;
- the file the approval pins, by its checksum.

Deploy stays off while a check fails.

<details>
<summary>When an agent asks instead</summary>

An agent or an API key can file the same request, but cannot approve it. The
request waits in your [Inbox](/inbox). Open it to read the same checks, then
approve or deny it. Deny needs a reason, which goes into the record. A request
has no deadline: it waits until someone decides. Where the robot belongs to an
organization that asks for a second person, the person who asked cannot also
approve.

</details>

## 3 · Approve it

Tick the e-stop confirmation, then **hold** the button until it fills.
From the keyboard, press Enter twice. You may shorten the window before you
approve.

**You'll see** the live page. It counts down the window above the robot's
**signed trail**: Approved, Verified, Pulled, Started, then a heartbeat every few
seconds. Verified means the robot checked the approval's signature itself.
Pulled means it downloaded the file, and the bytes match.

## 4 · Stop it

Press **Stop now** on the live page, or **STOP** beside the robot on [My
robots](/settings/devices). Only a signed-in person can stop a run.

The robot reads the stop on its next heartbeat. It holds still, then stops, and
signs a **Stopped** event. With the virtual test robot, that took under two
seconds from the press. The same page is then the record of the run.

An approval runs once. To run the policy again, deploy it again; **Redeploy
previous** on My robots does that with the same file and window.

<details>
<summary>If the robot loses its connection to the hub</summary>

A walking or balance policy runs on the robot itself. If the robot loses the
hub, it keeps running that policy until its window ends. Then it stops on its
own clock. A stop pressed meanwhile reaches it when the link returns. A policy the
hub serves over the network is different. The robot holds, then stops, as soon
as that link drops. The robot's card on My robots says when no heartbeat has
arrived for 20 seconds.

</details>

## Disconnect a robot

On [My robots](/settings/devices), press **Disconnect**. Its key is revoked at
once, and anything it runs is asked to stop. Its history stays, and its name is
free to use again.
