Playground key
create a key →

API reference

Safety.

DroidHub decides who can drive and enforces it at the media server. It also tells your robot what it decided, so the robot can do its part: stop.

What DroidHub guarantees

  • Only the controller's connection can send data. DroidHub grants it when that identity joins, and takes it away when control moves on, the connection ends, an e-stop latches or the controller times out.
  • An e-stop holds until someone clears it. While it holds, nobody can be given control and only robots can send data.
  • Every change reaches your robot through the room's metadata, pushed by the media server.

What your robot does

  1. Acts only on input from the identity named in controller. Cameras and other devices can send data too.
  2. Stops when input goes quiet (400 ms is a good default), when estop is set or controller is null, and when the room disconnects.
  3. With a control timeout, stops when the controller has sent nothing for controlTimeoutMs, then reports it once.
  4. With a max lag, pings the controller and holds still while the round trip is over maxLagMs.

The robot example in Hardware & devices does all four.

Room state

Read room.metadata after connecting, and again on every RoomMetadataChanged event.

room.metadata
{
  "droidhub": {
    "v": 1,
    "controller": { "identity": "operator-jane", "assignmentId": "Wc8kR…" },
    "estop": null,                 // { at, reason } while an e-stop holds
    "controlTimeoutMs": 1000,      // null = off
    "maxLagMs": 300                // null = off
  }
}

E-stop

Latching the e-stop revokes the controller, takes data permission from everyone except robots, and refuses new assignments and controller tokens with 409 estopped. Calling it again keeps the first time and reason.

BodyTypeDescription
reasonstringOptional, up to 200 chars. Shown to robots and in the dashboard.
POST/v1/streams/:id/estopcontroller:writeTry it
destructive — changes real data

Clearing gives cameras their data permission back. Nobody holds control until you assign a controller.

DELETE/v1/streams/:id/estopcontroller:writeTry it
destructive — changes real data

In the dashboard

Every stream page has an E-stop button. Any member can press it; owners and admins clear it.

Control timeout and max lag

Both are off by default. Set them on the stream; robots read them from the room state.

BodyTypeDescription
controlTimeoutMsinteger | null200–10000. How long the controller may send nothing before robots stop and control is revoked.
maxLagMsinteger | null50–10000. The longest robot-to-controller round trip robots drive with.
PATCH/v1/streams/:idstreams:writeTry it

The controller keeps the robot informed on data topic dh.hb, sent lossy:

MessageFromWhen
{"hb": 42}ControllerWhile it holds control. Every 250 ms covers any control timeout.
{"ping": 1764140000000}Robot → controllerEvery 100–250 ms while the stream has a max lag.
{"pong": 1764140000000}Controller → robotImmediately, echoing the ping's number.
controller.ts (livekit-client)
const encode = (msg) => new TextEncoder().encode(JSON.stringify(msg));

// While holding control: a heartbeat every 250 ms.
let seq = 0;
const heartbeat = setInterval(() => {
  room.localParticipant.publishData(encode({ hb: ++seq }), {
    reliable: false,
    topic: "dh.hb",
  });
}, 250);

// Echo every ping straight back to the robot that sent it.
room.on(RoomEvent.DataReceived, (payload, participant, _kind, topic) => {
  if (topic !== "dh.hb" || !participant) return;
  const { ping } = JSON.parse(new TextDecoder().decode(payload));
  if (typeof ping !== "number") return;
  room.localParticipant.publishData(encode({ pong: ping }), {
    reliable: false,
    topic: "dh.hb",
    destinationIdentities: [participant.identity],
  });
});

The dashboard's drive pad does both, so you can test a robot against these policies without writing a controller.

Report a timeout

After it stops for a quiet controller, your robot reports it once per assignment. DroidHub revokes control with reason timeout. Authenticated by the stream key, like the device token exchange.

BodyTypeDescription
streamKeyrequiredstringThe stream's dh_sk_… key.
identityrequiredstringcontroller.identity from the room state.
assignmentIdstringcontroller.assignmentId, so a newer assignment is never revoked.
POST/v1/streams/control-timeoutstream keyTry it
409 codeWhen
control_timeout_offThe stream has no control timeout.
not_current_controllerThat identity doesn't hold control, or a newer assignment exists.
too_earlyThe assignment is younger than one control timeout.

Revoke reasons

controller.revoked webhooks and safety.lastRevoke on the stream say why control ended.

ReasonWhen
apiDELETE /v1/streams/:id/controller
dashboardRevoke or Release in the dashboard
disconnectedThe controller's connection ended
timeoutA robot reported the controller quiet
estopAn e-stop latched

E-stops send stream.estopped and stream.estop_cleared. See Webhooks.