Velocity streamingΒΆ

Call send_velocity / sendVelocity in a loop while you want the robot to move. Each call applies for the lease duration you pass; when commands stop arriving, the lease runs out, or stop is called, the Appliance publishes zero velocity and the robot stops.

The lease cannot exceed 2 seconds. Use move for finite motion that lasts longer than a velocity lease.

import time

from olo import Client

with Client() as client:
    locomotion = client.robot().locomotion

    # Keep a slow forward command alive for two seconds.
    deadline = time.monotonic() + 2.0
    while time.monotonic() < deadline:
        locomotion.send_velocity(x=0.2, lease=0.2)
        time.sleep(0.1)
    time.sleep(1)

    # Send and then cancel a command.
    locomotion.send_velocity(x=-0.2, lease=2.0)
    time.sleep(1)
    locomotion.stop()
import { connect } from "olo/web";

const delay = (milliseconds: number) =>
  new Promise<void>((resolve) => setTimeout(resolve, milliseconds));

const locomotion = (await connect().robot()).locomotion;

// Keep a slow forward command alive for two seconds.
const deadline = Date.now() + 2_000;
while (Date.now() < deadline) {
  await locomotion.sendVelocity({ x: 0.2, leaseMs: 200 });
  await delay(100);
}
await delay(1_000);

// Send and then cancel a command.
await locomotion.sendVelocity({ x: -0.2, leaseMs: 2_000 });
await delay(1_000);
await locomotion.stop();