-
Notifications
You must be signed in to change notification settings - Fork 3k
Add Remote Rerun Viewer #2243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Remote Rerun Viewer #2243
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -104,6 +104,10 @@ class TeleoperateConfig: | |||||
| teleop_time_s: float | None = None | ||||||
| # Display all cameras on screen | ||||||
| display_data: bool = False | ||||||
| # Display data on a remote Rerun server | ||||||
| display_url: str = None | ||||||
|
||||||
| display_url: str = None | |
| display_url: str | None = None |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,19 +16,23 @@ | |||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||||
| from typing import Any | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| import cv2 | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||||||||||||||||||
| import rerun as rr | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| from .constants import OBS_PREFIX, OBS_STR | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| def init_rerun(session_name: str = "lerobot_control_loop") -> None: | ||||||||||||||||||||||||||||||||||||||||
| def init_rerun(session_name: str = "lerobot_control_loop", url: str = None, port: int = 9876) -> None: | ||||||||||||||||||||||||||||||||||||||||
| """Initializes the Rerun SDK for visualizing the control loop.""" | ||||||||||||||||||||||||||||||||||||||||
| batch_size = os.getenv("RERUN_FLUSH_NUM_BYTES", "8000") | ||||||||||||||||||||||||||||||||||||||||
| os.environ["RERUN_FLUSH_NUM_BYTES"] = batch_size | ||||||||||||||||||||||||||||||||||||||||
| rr.init(session_name) | ||||||||||||||||||||||||||||||||||||||||
| memory_limit = os.getenv("LEROBOT_RERUN_MEMORY_LIMIT", "10%") | ||||||||||||||||||||||||||||||||||||||||
| rr.spawn(memory_limit=memory_limit) | ||||||||||||||||||||||||||||||||||||||||
| if url: | ||||||||||||||||||||||||||||||||||||||||
| rr.connect_grpc(url=f"rerun+http://{url}:{port}/proxy") | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
| rr.connect_grpc(url=f"rerun+http://{url}:{port}/proxy") | |
| rr.connect(f"{url}:{port}") |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path assumes 3-channel RGB input; it will fail or produce incorrect results for 1-channel (grayscale) and 4-channel (RGBA) images mentioned in the docstring. Handle channel count explicitly: no color conversion for single-channel, RGB→BGR for 3-channel, and RGBA→BGR (drop alpha) for 4-channel before JPEG encoding.
| _, buffer = cv2.imencode( | |
| ".jpg", cv2.cvtColor(arr, cv2.COLOR_RGB2BGR), [int(cv2.IMWRITE_JPEG_QUALITY), 50] | |
| # Handle channel count explicitly for JPEG encoding | |
| if arr.ndim == 3: | |
| if arr.shape[2] == 1: | |
| # Grayscale, no color conversion needed | |
| arr_to_encode = arr | |
| elif arr.shape[2] == 3: | |
| # RGB to BGR | |
| arr_to_encode = cv2.cvtColor(arr, cv2.COLOR_RGB2BGR) | |
| elif arr.shape[2] == 4: | |
| # RGBA to BGR (drop alpha) | |
| arr_to_encode = cv2.cvtColor(arr[:, :, :3], cv2.COLOR_RGB2BGR) | |
| else: | |
| raise ValueError(f"Unsupported number of channels for image encoding: {arr.shape[2]}") | |
| else: | |
| raise ValueError(f"Expected 3D array for image encoding, got shape {arr.shape}") | |
| _, buffer = cv2.imencode( | |
| ".jpg", arr_to_encode, [int(cv2.IMWRITE_JPEG_QUALITY), 50] |
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] cv2.imencode expects uint8 data; if arr is float (e.g., [0,1]) or another dtype, encoding may fail or yield incorrect output. Consider converting/scaling to uint8 prior to encoding and checking the boolean return value of cv2.imencode to handle failures.
Copilot
AI
Oct 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logged type should be rr.ImageEncoded, not rr.EncodedImage; rr.EncodedImage does not exist in the Python API and will fail at runtime. Replace with rr.ImageEncoded(contents=..., media_type="image/jpeg").
| rr.log(key, rr.EncodedImage(contents=encoded_image, media_type="image/jpeg"), static=True) | |
| rr.log(key, rr.ImageEncoded(contents=encoded_image, media_type="image/jpeg"), static=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Align the type of display_url with the project's union style by using str | None for consistency with other fields (e.g., teleop_time_s: float | None).