Feat/camera async read require new #2695
Open
+26
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title
feat(camera): allow immediate read in async_read without checking freshness
Type / Scope
lerobot.cameras.opencvandlerobot.cameras.realsense(OpenCV/RealSense camera async API)Summary / Motivation
This PR improves the camera async API for low-latency sampling. It adds an optional immediate path to
async_read, so callers can fetch the most recent frame without blocking when freshness is not required, while preserving the original wait->read->clear behavior when waiting is acceptable. This reduces unnecessary waits and latency during teleop, data collection, and policy inference, especially in multi-camera setups. It also decouples the achievable control frequency from individual camera streaming rates. Trade-off: clients that truly require a strict “new since last read” guarantee should continue to use the event-driven path, which is the case by default throughrequire_new=True.Related issues
None.
What changed
OpenCVCamera.async_readandRealsenseCamera.async_read:require_new: bool parameter (defaults to True, i.e., defaults to original behavior).require_new=Falseand a frame is already available, return immediately (no wait).require_new=TrueNo breaking changes to existing call sites that pass only timeout_ms.
How was this tested
./tests/cameras/test_realsense.pyand./tests/cameras/test_opencv.pyall passed.xuweiwu/bimanual-toy-box-cleanup(available on hf)How to run locally (reviewer)
Checklist (required before merge)
pre-commit run -a)pytest)Reviewer notes
The impact is most relevant in multi-camera setups where a slow source can stall the loop.
In my tests with three cameras, using require_new=True (freshness, original behavior) introduces waits when a camera lags:
Switching to require_new=False (no freshness check) returns whatever is already available and avoids blocking on the slow camera: