Repository navigation
Ivan/feat/go2zenoh #3141
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
Merged
Merged
Ivan/feat/go2zenoh #3141
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c6ea15f
quick zenoh go2 implementation
leshy 3361342
adds compressedVideo
leshy f12f478
go2 zenoh: action verbs over a std_msgs/String topic
leshy e12db8b
nav blueprints
leshy 56c4e42
go2 zenoh: set_lidar rpc
leshy 9a39fdf
iterating on details, nav works
leshy 54208d3
planner visualizations
leshy 2bda3c5
flake relock
leshy 265aaed
cleaner map
leshy 9587383
go2 zenoh: stand up on start, lie down on stop
leshy 21ca92e
wait for zenoh init
leshy 354a90a
chore: bump dimos-viewer to 0.32.0a2
leshy e384a92
added dan planner, blueprint cleanup
leshy e1f18b3
blueprint cleanup 2
leshy cab4409
nice surface maps
leshy f671227
good viz
leshy 457d51d
Merge branch 'main' into ivan/feat/go2zenoh
leshy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """foxglove_msgs::msg::CompressedVideo — one encoded video packet. | ||
|
|
||
| Just the encoded bytes + codec name. Inter-frame codecs (h264) can't be decoded | ||
| one packet at a time — feed the ordered stream through | ||
| :class:`~dimos.robot.unitree.go2.dds.video.H264Decoder` to get ``Image`` frames, | ||
| or let the rerun bridge log it as a ``VideoStream`` and decode in-viewer. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import time | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from dimos_lcm.foxglove_msgs import CompressedVideo as LCMCompressedVideo | ||
| import numpy as np | ||
|
|
||
| from dimos.types.timestamped import Timestamped | ||
|
|
||
| if TYPE_CHECKING: | ||
| from dimos.visualization.rerun.bridge import RerunData | ||
|
|
||
|
|
||
| class CompressedVideo(Timestamped): | ||
| """One encoded video packet (Annex-B for h264).""" | ||
|
|
||
| msg_name = "foxglove_msgs.CompressedVideo" | ||
|
|
||
| def __init__( | ||
| self, | ||
| data: np.ndarray | bytes, | ||
| format: str = "h264", | ||
| frame_id: str = "", | ||
| ts: float | None = None, | ||
| ) -> None: | ||
| """Initialize a CompressedVideo. | ||
|
|
||
| Args: | ||
| data: The encoded packet, u8 | ||
| format: Codec name, e.g. "h264" | ||
| frame_id: Frame ID | ||
| ts: Timestamp in seconds | ||
| """ | ||
| self.data = data if isinstance(data, np.ndarray) else np.frombuffer(data, dtype=np.uint8) | ||
| self.format = format | ||
| self.frame_id = frame_id | ||
| self.ts = ts if ts is not None else time.time() | ||
|
|
||
| def lcm_encode(self) -> bytes: | ||
| msg = LCMCompressedVideo() | ||
| msg.timestamp.sec = int(self.ts) | ||
| msg.timestamp.nanosec = int((self.ts - int(self.ts)) * 1e9) | ||
| msg.frame_id = self.frame_id | ||
| msg.data = self.data.tobytes() | ||
| msg.data_length = len(msg.data) | ||
| msg.format = self.format | ||
| return msg.lcm_encode() # type: ignore[no-any-return] | ||
|
|
||
| @classmethod | ||
| def lcm_decode(cls, data: bytes) -> CompressedVideo: | ||
| msg = LCMCompressedVideo.lcm_decode(data) | ||
| return cls( | ||
| data=bytes(msg.data), | ||
| format=msg.format, | ||
| frame_id=msg.frame_id, | ||
| ts=msg.timestamp.sec + msg.timestamp.nanosec * 1e-9, | ||
| ) | ||
|
|
||
| def to_rerun(self) -> RerunData: | ||
| """Log the encoded packet as a rerun ``VideoStream`` sample (viewer decodes). | ||
|
|
||
| rerun decodes the stream in-viewer, so this stays per-packet and cheap — | ||
| no server-side decode, and the .rrd holds the compressed bytes. Iterate | ||
| from the start (or a keyframe) so the first sample the viewer sees is one. | ||
| """ | ||
| import rerun as rr | ||
|
|
||
| codecs = { | ||
| "h264": rr.VideoCodec.H264, | ||
| "h265": rr.VideoCodec.H265, | ||
| "av1": rr.VideoCodec.AV1, | ||
| "vp8": rr.VideoCodec.VP8, | ||
| "vp9": rr.VideoCodec.VP9, | ||
| } | ||
| codec = codecs.get(self.format.lower()) | ||
| if codec is None: | ||
| raise ValueError(f"no rerun VideoCodec for format {self.format!r}") | ||
| return rr.VideoStream(codec, sample=self.data.tobytes()) | ||
|
|
||
| def __repr__(self) -> str: | ||
| return ( | ||
| f"CompressedVideo(format='{self.format}', bytes={self.data.size}, " | ||
| f"frame_id='{self.frame_id}', ts={self.ts})" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import pytest | ||
| import rerun as rr | ||
|
|
||
| from dimos.msgs.foxglove_msgs.CompressedVideo import CompressedVideo | ||
| from dimos.msgs.helpers import resolve_msg_type | ||
|
|
||
| PACKET = b"\x00\x00\x00\x01\x65payload" | ||
|
|
||
|
|
||
| def test_lcm_encode_decode() -> None: | ||
| original = CompressedVideo(data=PACKET, format="h264", frame_id="front_camera", ts=1234567890.5) | ||
| decoded = CompressedVideo.lcm_decode(original.lcm_encode()) | ||
|
|
||
| assert decoded.data.tobytes() == PACKET | ||
| assert decoded.format == "h264" | ||
| assert decoded.frame_id == "front_camera" | ||
| assert abs(decoded.ts - original.ts) < 1e-6 | ||
|
|
||
|
|
||
| def test_resolves_over_the_raw_lcm_type() -> None: | ||
| """The rerun bridge decodes by type name — it must land on the to_rerun() class.""" | ||
| resolved = resolve_msg_type("foxglove_msgs.CompressedVideo") | ||
| assert resolved is CompressedVideo | ||
|
|
||
|
|
||
| def test_to_rerun_video_stream() -> None: | ||
| stream = CompressedVideo(data=PACKET, format="h264").to_rerun() | ||
| assert isinstance(stream, rr.VideoStream) | ||
| assert bytes(stream.sample.as_arrow_array().to_pylist()[0]) == PACKET # type: ignore[union-attr] | ||
|
|
||
|
|
||
| def test_to_rerun_unknown_codec() -> None: | ||
| with pytest.raises(ValueError, match="mjpeg"): | ||
| CompressedVideo(data=PACKET, format="mjpeg").to_rerun() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright 2025-2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """String message type.""" | ||
|
|
||
| from typing import ClassVar | ||
|
|
||
| from dimos_lcm.std_msgs import String as LCMString | ||
|
|
||
|
|
||
| class String(LCMString): # type: ignore[misc] | ||
| """ROS-compatible String message.""" | ||
|
|
||
| msg_name: ClassVar[str] = "std_msgs.String" | ||
|
|
||
| def __init__(self, data: str = "") -> None: | ||
| """Initialize String with data value.""" | ||
| self.data = data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.