Menlo

Examples

The runnable scripts that ship with the SDK, grouped by what they show.

Each file is one short, runnable script, kept in the examples directory of the SDK repository. Every script except connect.py and the livekit_raw/ scripts connects to the saved robot (menlo setup), or to the robot the MENLO_* environment variables describe; set MENLO_ROBOT=NAME to pick another saved robot. The settings a script uses, such as a speed, a duration or a joint name, are constants at the top of the file. Read the docstring at the top of a file before you run it: it says what the robot must be doing. Before a script that moves the robot, work through Before You Run a Script.

pip install menlo-sdk
git clone https://github.com/menloresearch/menlo-sdk.git
cd menlo-sdk
python examples/check.py

Check

ScriptWhat it shows
check.pypreflight() for stand, move and trajectory, without sending anything: the check every moving command runs before it sends

Connect

ScriptWhat it shows
connect.pythe udp, hybrid and livekit configs side by side in code; set MODE at the top and it prints the endpoint, robot mode, arming, battery and capabilities

State

ScriptWhat it shows
read_state.pya tour of robot.get_state(): mode, arming, faults, battery, the hottest actuators, gravity, alerts, state age and rate, and the mode and alert callbacks

Stand, Balance, Walk, Damp

ScriptWhat it shows
stand.pystand() from DAMP; it returns once the robot is armed, and the script prints the NotReadyError or WaitTimeoutError otherwise
balance.pybalance() from an armed STAND: the robot enters MOVE and balances in place; the script prints the NotReadyError or WaitTimeoutError otherwise
walk.pya bounded set_velocity(duration=3.0) in MOVE: the SDK holds the velocity, sends zero, and the robot balances in place; reports sent.clamped
stream_velocity.pyset_velocity(hold=False) from your own 50 Hz loop, one packet per tick, then balance()
damp.pydamp() on a supported robot, after asking; it returns once the robot reports DAMP

Keyboard

ScriptWhat it shows
keyboard.pydrive from the keyboard with short bounded holds: w/s walk, a/d strafe, q/e turn, space balance(), t stand from DAMP, b damp after asking, x quit

Joints

ScriptWhat it shows
move_joints.pyset_joints() on one named joint, on a supported robot; exits unless ROBOT_SUPPORTED = True is set in the file and refuses unless the robot is in STAND; the robot enters DAMP 2 s after the script exits
wait_until.pyset_joints(wait=False), then wait_until() acts the moment the joint passes an angle in the robot's own report; refuses unless the robot is in STAND

Media

ScriptWhat it shows
camera_and_audio.pya photo, a short clip saved as JPEG frames with its sound as WAV, and a tone on the speaker; hybrid or livekit
record_audio.pythree seconds of the microphone saved as WAV
play_audio.pya WAV file played on the robot's speaker, one second at a time

Recording

ScriptWhat it shows
record_and_replay.pyrobot.record() for three seconds, then reading the file back with recording.load()

Without the SDK

The scripts in livekit_raw/ use only the livekit and asimov-protocol packages; see Without the SDK. They read MENLO_CREDENTIAL and the MANAGER_URL set in manager_token.py.

ScriptWhat it shows
livekit_raw/manager_token.pya join token from Asimov Manager; the other scripts in the folder import it
livekit_raw/read_state.pyRobotState from the state data track for 5 s
livekit_raw/send_commands.pythe readiness checks by hand, then one STAND RobotCommand on the commands topic; the robot must hang from its gantry hook
livekit_raw/camera.pyone frame from the video track, saved as PPM
livekit_raw/audio.pythe microphone track, saved as WAV
  • Quickstart: check, stand, balance, walk and damp, step by step
  • Command Line: the same verbs without writing a script

How is this guide?

On this page