Stretch 4 now integrates directly with Hugging Face’s LeRobot ecosystem. This integration brings modern imitation learning workflows – demonstration recording, policy training, and deployment – to Stretch 4 across various models like Diffusion Policy, ACT, and Physical Intelligence’s pi0.5.
Bringing a mobile manipulator with a stereo head camera (left and right), a gripper camera, and diverse teleoperation devices into an imitation learning framework involves critical systems choices. This post covers the core design decisions we made to build a robust pipeline, followed by benchmarks and real-robot results showing what is currently possible on hardware.
For step-by-step instructions on data collection, training, and deployment commands, refer to the stretch4_lerobot GitHub repository and its guides:
Key Design Decisions
1. Modular Architecture & Device-Agnostic Teleop
To keep Stretch 4 completely compatible with upstream LeRobot updates, support is implemented through LeRobot’s dynamic package discovery mechanism via three standalone packages:
lerobot_robot_stretch4: Manages the 9-DoF robot interface, base velocity control, action lookahead, and runtime state guards.lerobot_teleoperator_stretch4: Implements a passive observer pattern for teleoperation.lerobot_camera_oak: Handles multi-eye Luxonis OAK camera capture and hardware synchronization.
The Passive Observer Pattern: Users teleoperate Stretch with a wide variety of hardware: gamepads commanding base velocities, 3D SpaceMice, or VR controllers commanding Cartesian poses. Rather than recording device-specific operator commands, stretch4_observer acts as a passive listener: you drive the robot with your preferred controller in an independent process, and the recorder logs the actual measured robot states. Demonstrations collected via gamepad, SpaceMouse, or VR all share the exact same format.
Action Lookahead: Measured states lack the lead a teleop command has over the robot, so we define the action as the measured state k frames ahead, where k is --robot.action_lookahead (default 3, i.e. 100 ms at 30 fps):
at = st+k
2. Multi-Sensor Hardware Synchronization & Cropping
Stretch 4 captures visual data using two physical Luxonis OAK devices (head and gripper), yielding four separate camera streams.
- Device Multiplexing: An OAK device can only be opened once by a host process.
lerobot_camera_oakopens each physical device as a shared session and fans frames into per-eye ring buffers. Frames stay as compressed JPEGs until read, avoiding CPU decode overhead for unused streams. - Exposure Clocking: All observations are clocked to the primary head camera. When a head frame arrives, 100 Hz joint states are linearly interpolated to its hardware capture timestamp. The matching gripper frame is paired only if its hardware timestamp falls within 20 ms of the head frame; otherwise, it is dropped to prevent temporal skew.
- Aspect-Ratio Conscious Cropping: Stretch’s head cameras are 1920×1200 sensors mounted sideways, producing tall 1200×1920 portrait images. Because policies downsample images (e.g., 224×224 or 240×384), downsampling the full portrait view compresses the workspace and gripper into a blur of pixels. We crop in native sensor resolution, locked to the output’s aspect ratio (1.6 : 1 for the default 240×384), and only then resize, preserving full workspace detail without non-uniform stretching. The output size is yours to choose: pass any height and width with
stretch4_pick_cameras --size H W, and the crop box follows its aspect ratio.
3. Numerical Stability on Inactive Joints
LeRobot normalizes every state and action value by how much it varied in the training data. Diffusion and pi0.5 map each value’s range onto [−1, 1]:
x̂ = 2 · (x − xlo) / (xhi − xlo) − 1
where xlo, xhi are the min and max (diffusion) or the 1st and 99th percentiles (pi0.5). ACT uses mean and standard deviation instead, with the same effect.
When a joint never moves in the demonstrations, such as a gripper held shut around a tool or a wrist roll left alone, xhi − xlo is just encoder noise. Normalization stretches that noise across the full [−1, 1] range, so the policy fits noise and training loss spikes. On the robot, a reading slightly outside that tiny range becomes a huge input to the policy.
To prevent this, we added stretch4_fix_stats, an optional but highly recommended step that you run once after recording:
- Holding inactive joints: joints moved in fewer than 10% of episodes (
--min-episode-frac) are held at their median value in both state and action. - Spread flooring: every normalization spread (min/max, quantiles, std) is widened to a per-joint minimum (e.g. 4 cm for lift and arm, 0.2 rad for the wrist, 10 mm for the gripper), so a value that barely moved normalizes to about 0. The minimums can be changed per joint (
STATS_FLOORinstats_floor.py); tasks that rely on very small motions of a joint may need a lower floor for it.
At rollout, a state guard (--robot.preprocessing_from) pins held joints to their training value and clamps every other state value to its training range before inference.
4. Real-Time Inference: Jetson Orin NX and Desktop GPU
Running a policy on Stretch 4 needs a GPU. Smaller models like Diffusion and ACT run on a Jetson Orin NX mounted inside the robot (available as an accessory). Larger models like pi0.5 do not fit on the Jetson, so we ran them on a desktop GPU instead.
ACT ran smoothly on the Jetson out of the box. Diffusion did not, so we made the changes below.
Default DDPM sampling uses 100 denoising steps, which took 8.6 seconds per action chunk on the Jetson Orin NX (MAXN_SUPER mode). Because a default 32-action chunk executes in only 1.07 seconds at 30 fps, the robot spent nearly 90% of its time frozen.
We achieved seamless real-time motion through three coordinated changes:
- DDIM Sampling (10 steps): Switched from DDPM to DDIM. DDIM runs the same trained denoiser with larger steps through the noise schedule. Inference dropped from 8.6 s to 0.91 s (9.5×).
- Longer executed chunk (
n_action_steps=48): the policy predicts a 64-action horizon; the robot now executes 48 of them, or 1.6 s per chunk. - Asynchronous Prefetching (
--chunk_size_threshold=0.7): Configured the async client to prefetch the next chunk at 70% queue remaining (1.1 seconds ahead). Since Jetson inference takes ~0.95 seconds, new actions land before the queue empties, providing uninterrupted motion. LeRobot’s default (0.5) would request only 0.8 s ahead, less than the inference time, so the robot would pause between chunks.
5. Fine-Tuning pi0.5 with LoRA
Physical Intelligence’s pi0.5 combines a 27-layer SigLIP vision encoder, a 2B Gemma language model and a 300M Gemma action expert. A full fine-tune needs about 70 GB of GPU memory, so on a single workstation GPU we use Low-Rank Adaptation (LoRA): the pretrained weights stay frozen, and small adapters are trained next to the layers we choose.
LeRobot’s default LoRA puts adapters only on the action expert’s attention (q and v) and its input/output projections. The vision encoder and the language model are not trained at all.
We trained it on 100 demonstrations of opening a refrigerator. The training loss was low (0.037), but on the robot the arm reached for the wrong side of the door. The policy appeared to replay memorized joint motions rather than respond to the images: its actions barely changed when the view of the fridge changed.
We changed four settings:
- LoRA on every linear layer (
--peft.target_modules=all-linear), vision encoder included. - Rank 32 with
lora_alpha64 (--peft.r=32 --peft.lora_alpha=64). We setlora_alphaas well as the rank because the adapter is scaled bylora_alpha / r, and the defaultlora_alphaof 8 would have scaled a rank-32 adapter down to a quarter. - A learning rate of 1e-4. pi0.5’s default (2.5e-5) is meant for a full fine-tune.
- Image augmentation (
--dataset.image_transforms.enable=true), so the vision side generalizes instead of memorizing.
With these changes, the policy reached for the right side of the door and opened the fridge.
6. Hardening the Asynchronous Policy Server
During real-robot testing with LeRobot 0.6’s async policy server, we resolved three practical edge cases in stretch4_policy_server:
- Observation history: Policies that look at several past frames (
n_obs_steps≥ 2, e.g. diffusion) need a history of observations. The stock server passes one observation per chunk, so the policy fails an internal assert, the server logs an emptyError in StreamActions:, and the robot never moves. Our server keeps the observations it receives and feeds the policy the ones 1/fps apart, as in training. Policies that use one frame run exactly as stock. - Similarity filter: The stock server skips an observation if its joint state is within an L2 distance of 1.0 of the last one it ran. That suits joints in degrees, but Stretch reports metres and radians, where 1.0 is a large move, so nearly every early request was dropped and the robot moved stop-and-go. We turned the filter off by default (
--skip_similar_observations=truerestores it); the client already sends only when its queue runs low. - LoRA checkpoints: A LoRA checkpoint holds only the adapter weights. The stock server finds no full weights, logs
Returning model without loading pretrained weights, and runs a randomly initialized policy, so the joints move at random. Our server loads the base model named inadapter_config.jsonwith the checkpoint’s config and merges the adapter in.
Our server also logs the full traceback when inference fails; the stock server logs only the message.
Results
Diffusion and ACT ran on the Jetson Orin NX inside the robot; pi0.5 needs more compute and ran on a desktop with an RTX 5090.
Tasks
- Cleaning up: The robot brushes the nails scattered on a table into a box. Success: all of the nails end up in the box.
- Opening the fridge: The robot grasps the refrigerator handle and pulls the door open. Success: the fridge door is open.
- Pick and place a measuring tape: The robot picks up a measuring tape from a cluttered table and places it in a bin. Success: the measuring tape is in the bin.
Setup
| Task | Number of demonstrations | Teleoperation device | Variation in the demonstrations | Lerobot Dataset |
|---|---|---|---|---|
| Cleaning up | 50 | Gamepad | Base starting pose | hellorobotinc/stretch4_brushing_nails |
| Opening the fridge | 100 | Puppet teleop | Base and arm starting pose | hellorobotinc/stretch4_open_fridge |
| Pick and place a measuring tape | 100 | Gamepad | Placement of the tape and of the objects around it + Base starting pose | hellorobotinc/stretch4_measuring_tape_pick_place |
Every policy used three cameras (the left and right head cameras and the gripper camera) and the default action lookahead of 3 frames.
Success rates
Successful runs out of total attempts for each policy. A dash means the policy wasn’t tested on that task.
| Task | Diffusion (Jetson) | ACT (Jetson) | pi0.5 (RTX 5090) |
|---|---|---|---|
| Cleaning up | 5/10 | — | 7/10 |
| Opening the fridge | 9/10 | 8/10 | 16/20 |
| Pick and place a measuring tape | 3/10 | — | 6/10 |
Out of Distribution Successes
We also ran our Open Fridge task with Diffusion and pi0.5 from an out-of-distribution starting position, and both found their way to the fridge and opened it.
Notes
Common Failures
- Pick and place a measuring tape (diffusion): The policy found the tape and moved to it reliably; most failures came at the grasp. When it closed the gripper and missed, it did not reopen it to try again, and carried on to place an empty gripper in the bin.
- Cleaning up: On the return passes to brush what was left, the base sometimes rotated away from parallel to the table. Once angled, the robot kept moving away from the table and did not recover.
- Opening the fridge: The fridge’s surface is reflective, so performance depended on the lighting at that time of day. In some conditions the policy took longer to reach the handle, or needed several attempts before it opened the door.
Observed Behaviors
- Recovering from a miss (opening the fridge): The gripper stays open for the whole task, so when the robot misses the handle it is still in a state that looks like the demonstrations, and the policy can simply reach for the handle again. Diffusion and pi0.5 did this. ACT did not: after a miss, it carried on with the rest of the task, moving away from the fridge as if it were pulling the door, and the door stayed closed.
- Knowing when to stop (cleaning up): Once all of the nails were in the box, Diffusion stopped brushing, but pi0.5 kept making brushing passes over the empty table.