feat(viewer): interactive click-to-coordinate with Python bridge#2
Merged
spomichter merged 6 commits intomainfrom Mar 3, 2026
Merged
feat(viewer): interactive click-to-coordinate with Python bridge#2spomichter merged 6 commits intomainfrom
spomichter merged 6 commits intomainfrom
Conversation
…ration Adds click-to-coordinate support to the custom_callback viewer example. When a user clicks on an entity in a 2D/3D spatial view, world-space coordinates are sent via TCP to a Python bridge for downstream processing. Changes: - interaction/protocol.rs: ViewerEvent + AppCommand enums (bincode serde) - interaction/handle.rs: InteractionHandle mpsc wrapper with unit tests - interaction/sender.rs: TCP client with auto-reconnect to Python bridge - viewer.rs: on_event callback intercepting SelectionChange events, 100ms debounce, rapid-click detection - build-viewer.yml: CI workflow for Linux x64 + macOS arm64 Uses the official StartupOptions::on_event callback API — zero changes to rerun core crates. All modifications are in examples/rust/custom_callback/. DIM-643
Python TCP server + bincode codec that receives click events from the custom viewer. Provides @on_click decorator API for handling world-space coordinates. Files: - bincode_codec.py: pure Python bincode encoder/decoder - bridge_bincode.py: production TCP server (bincode protocol) - bridge.py: development TCP server (JSON protocol) - test_bridge.py: 4 JSON bridge tests - test_bridge_bincode.py: 6 bincode bridge tests DIM-643
Rerun's picking only fires on entity clicks. This adds a helper that logs a large, nearly-invisible subdivided mesh at z=0 so clicks on empty floor space still produce world-space coordinates. Usage: from ground_plane import log_ground_plane log_ground_plane() # 200m x 200m at z=0, alpha=1 DIM-643
Replace the TCP-based ViewerEventSender with an LCM UDP multicast publisher for sending click events from the Rerun viewer to Python. Changes: - Add interaction/lcm.rs: LcmPublisher that encodes and sends geometry_msgs/PointStamped messages via UDP multicast (239.255.76.67:7667) - Update viewer.rs: use LcmPublisher instead of ViewerEventSender, publish click events on '/clicked_point#geometry_msgs.PointStamped' - Update interaction/mod.rs: export LCM types (ClickEvent, LcmPublisher, click_event_from_ms, click_event_now) The LCM encoding is verified byte-for-byte compatible with Python's dimos_lcm.geometry_msgs.PointStamped via unit tests (10 Rust tests) and cross-language integration tests (15 Python tests). Wire format: [8B fingerprint hash][Header: seq+stamp+frame_id][Point: x+y+z] Fingerprint: 0x9cd764738ea629af (matches Python LCM recursive hash)
- remove python_bridge/ directory (TCP bridge replaced by LCM) - remove interaction/sender.rs (TCP event sender, unused) - remove ControlViewer connection (port 8889) - remove Control panel wrapper (old demo UI) - simplify protocol.rs: keep only Click variant - simplify handle.rs: keep only send_click - clean up build-viewer.yml: fix paths, update action versions (v4) - rename app env to 'DimOS Interactive Viewer' - final Box::new(rerun_app) instead of Control::new wrapper
refactor: remove dead TCP bridge code, clean up for LCM-only transport
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
what
adds click-to-coordinate support to the custom_callback viewer example. click on an entity in a 2D/3D spatial view → world-space coordinates sent via TCP to a Python bridge.
why
DimOS needs click-to-navigate — operators click on a map point, robot goes there. rerun is currently read-only with no backchannel from viewer to application.
uses the official
StartupOptions::on_eventcallback API. zero changes to rerun core crates — everything lives inexamples/rust/custom_callback/.changes
interaction/protocol.rsViewerEvent+AppCommandenums with bincode serdeinteraction/handle.rsInteractionHandle— mpsc channel wrapper, 3 unit testsinteraction/sender.rsViewerEventSender— TCP client with auto-reconnectinteraction/mod.rsviewer.rson_eventcallback: interceptSelectionChange, debounce (100ms), send via TCPpython_bridge/bincode_codec.pypython_bridge/bridge_bincode.pypython_bridge/bridge.pypython_bridge/ground_plane.pybuild-viewer.ymlarchitecture
setup & build (Ubuntu 22.04)
1. install rust
2. install system dependencies
sudo apt-get update && sudo apt-get install -y \ build-essential cmake clang \ libgtk-3-dev \ libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \ libxkbcommon-x11-dev libxkbcommon-dev \ libvulkan-dev \ libwayland-dev3. clone & build
4. run tests
e2e test (requires display)
terminal 1 — python bridge
terminal 2 — viewer
should see in terminal 1:
Viewer connected from ('127.0.0.1', ...)terminal 3 — log test data
option A: entity spheres only (click on visible objects)
option B: with ground plane (click anywhere on the floor)
what to verify
DIM-643