Skip to content
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

rust: Add ws-stream-mcap example #196

Merged
merged 6 commits into from
Feb 12, 2025
Merged

rust: Add ws-stream-mcap example #196

merged 6 commits into from
Feb 12, 2025

Conversation

gasmith
Copy link
Contributor

@gasmith gasmith commented Feb 7, 2025

To play with the time messages, I wrote a little example to stream mcap files over a websocket. Might also be useful for performance testing against real data.

To use:

$ cargo run -p example-ws-stream-mcap --release -- --file ~/Downloads/example-014-ugv-ds.mcap --loop
[2025-02-07T18:32:26Z INFO  foxglove::runtime] Creating tokio runtime
[2025-02-07T18:32:26Z INFO  ws_stream_mcap] Loading mcap summary
[2025-02-07T18:32:26Z INFO  ws_stream_mcap] Waiting for client
[2025-02-07T18:32:29Z DEBUG tungstenite::handshake::server] Server handshake done.
[2025-02-07T18:32:29Z INFO  foxglove::websocket] Registered client 127.0.0.1:40132 advertising 38 channels
[2025-02-07T18:32:29Z INFO  foxglove::websocket] Advertised channel /os1_cloud_node/points with id 12 to client 127.0.0.1:40132
[2025-02-07T18:32:29Z INFO  foxglove::websocket] Advertised channel /downsampled_accumulated_points with id 6 to client 127.0.0.1:40132
[2025-02-07T18:32:29Z INFO  foxglove::websocket] Advertised channel /os1_cloud_node/points_downsampled with id 37 to client 127.0.0.1:40132
[2025-02-07T18:32:29Z INFO  foxglove::websocket] Advertised channel /right_drive/status/battery_voltage with id 16 to client 127.0.0.1:40132
...
[2025-02-07T18:32:31Z INFO  ws_stream_mcap] Starting stream
^C[2025-02-07T18:32:56Z INFO  foxglove::websocket] Shutting down
[2025-02-07T18:32:56Z INFO  foxglove::websocket] Unadvertised channel with id 10 to client 127.0.0.1:40132
[2025-02-07T18:32:56Z INFO  foxglove::websocket] Unadvertised channel with id 7 to client 127.0.0.1:40132
...

@gasmith gasmith self-assigned this Feb 7, 2025
@gasmith gasmith requested review from eloff and bryfox February 7, 2025 18:32
@gasmith gasmith force-pushed the gasmith/ws-stream-mcap branch from 35d74c5 to eb00a30 Compare February 7, 2025 18:35
@amacneil
Copy link
Contributor

amacneil commented Feb 7, 2025

Neat! Not sure if you've seen this prior art mcap-play in this repo, but it's great to have a rust example.

https://github.com/foxglove/ws-protocol/tree/main/typescript/ws-protocol-examples

Base automatically changed from gasmith/time-async to main February 7, 2025 21:05
@gasmith gasmith force-pushed the gasmith/ws-stream-mcap branch from eb00a30 to 8755296 Compare February 7, 2025 21:05
@gasmith gasmith marked this pull request as ready for review February 7, 2025 21:46
Copy link
Contributor

@bryfox bryfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; works well.

Note usage in PR description is out of date.

@gasmith gasmith merged commit a28931d into main Feb 12, 2025
28 checks passed
@gasmith gasmith deleted the gasmith/ws-stream-mcap branch February 12, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants