Use G1 WebRTC camera in headless setup#1553
Use G1 WebRTC camera in headless setup#1553kaiknower wants to merge 1 commit intodimensionalOS:mainfrom
Conversation
Greptile SummaryThis PR moves camera image and metadata publishing from the blueprint layer (via
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant G1 as G1 Robot (WebRTC)
participant Conn as G1Connection
participant LCM as LCM Transport
participant BP as Blueprint / Consumers
Note over Conn: start() called
Conn->>G1: Open WebRTC connection
G1-->>Conn: video_stream() Observable
loop Every video frame
G1->>Conn: Video frame (Image)
Conn->>Conn: color_image.publish(image)
Conn->>LCM: Broadcast /color_image
LCM->>BP: Image delivered
end
loop Every 1 second (background thread)
Conn->>Conn: camera_info.publish(static_info.with_ts)
Conn->>LCM: Broadcast /camera_info
Conn->>Conn: tf.publish(camera_link, camera_optical)
LCM->>BP: CameraInfo + TF delivered
end
Note over Conn: stop() called
Conn->>Conn: _stop_event.set()
Conn->>G1: connection.stop()
Conn->>Conn: Join camera_info thread
Last reviewed commit: d620ace |
| ip: str | None | ||
| connection_type: str | None = None | ||
| _global_config: GlobalConfig | ||
| camera_info_static: CameraInfo = _camera_info_static() |
There was a problem hiding this comment.
Class-level mutable default is shared across instances
_camera_info_static() is called once at class-definition time, so every G1Connection instance shares the same CameraInfo object. This is safe today because with_ts() returns a new copy and the static object is never mutated, but it's a subtle footgun if the object is ever modified in-place later. For comparison, G1SimConnection reads camera info at runtime from self.connection.camera_info_static.
Consider initializing this in __init__ instead:
| camera_info_static: CameraInfo = _camera_info_static() | |
| camera_info_static: CameraInfo |
And then in __init__, add self.camera_info_static = _camera_info_static().
Summary
Motivation
unitree-g1was trying to open/dev/video0on the deployment machine viaCameraModule, which breaks headless setups where the camera is actually on the G1 robot.Validation
python -m py_compileon the modified files