Add Rust LCM code generator and generated bindings#20
Open
Conversation
Closes #1617 Adds tools/rust/lcm_rust_gen.py — a standalone Python generator (no external deps) that parses all .lcm type definitions and produces a complete Rust crate at generated/rust_lcm_msgs/. Generated crate: - 173 LCM types across 14 packages (188 source files) - Derives Clone, Debug, Default, PartialEq for all types - Implements encode/decode (big-endian, LCM wire format) - Implements get_hash() matching LCM's signed i64 fingerprint arithmetic - Depends only on byteorder = "1" - Passes cargo check with 0 errors, 0 warnings Edge cases handled: - r#type raw identifier escaping (9 files use reserved keywords) - Manual Default impl for [f64; 36] (>32 elements, no auto-derive) - Length field suppression for variable-length arrays - OnceLock for lazy fingerprint caching - String/name field collision resolution generate.sh updated with Rust generation step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tasks
Pure Rust LCM UDP multicast transport — no system LCM library required. Mirrors the TypeScript @dimos/lcm package. Includes publisher/subscriber examples using lcm-msgs generated types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add integration tests validating the Rust LCM implementation from PR #1622: - `generated/rust_lcm_msgs/tests/roundtrip.rs`: 7 tests covering encode/decode roundtrips for Vector3, Twist, PoseStamped; fingerprint consistency; corruption detection; and exact known binary layout verification. - `tools/rust/lcm/tests/loopback.rs`: 4 UDP multicast pubsub tests covering empty-channel try_recv, typed message publish+receive (Vector3, Twist), and raw byte round-trip — all using bounded retries (no sleeps, no interactive I/O). All 11 tests pass. No external services or manual steps required. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add PartialEq to generated struct derives (was missing despite PR description) - Add Debug and Clone derives to transport types (LcmTransport, etc.) - Fix encode_one to return io::Result<()> with ? propagation - Fix string decode to use proper from_utf8 with error handling - Regenerate 173 message types with corrected derives - Add 7 round-trip encode/decode tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Closes #1617
Adds tools/rust/lcm_rust_gen.py — a standalone Python generator (no external deps) that parses all .lcm type definitions and produces a complete Rust crate at generated/rust_lcm_msgs/.
Generated crate:
Edge cases handled:
generate.sh updated with Rust generation step.