-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cdr): use decode_headerless_ros1 for ROS1 messages in DynCodec #59
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
64de397 to
54ec4b0
Compare
Greptile OverviewGreptile SummaryThis PR fixes ROS1 decoding through the dynamic CDR codec path by routing CDR schemas whose It also adds a ROS1 bag fixture and a new test suite intended to cover the streaming/S3-like path ( Main issues to address before merge are in the new tests/example: the tests appear to map
|
| Filename | Overview |
|---|---|
| src/encoding/cdr/codec.rs | Routes ROS1-encoded CDR schemas to decode_headerless_ros1() in decode_dynamic() based on schema_encoding containing "ros1"; otherwise uses standard decode(). |
| tests/ros1_decode_dynamic_tests.rs | Adds regression tests using a ROS1 bag fixture to exercise streaming decode_dynamic(); includes assertions about schema_encoding and allows partial decode success, but has a likely channel-id mapping bug (conn_id as u16) and a brittle assumption that all channels have schema_encoding == "ros1msg". |
| examples/test_leju_state.rs | Adds a manual example that hardcodes an absolute local file path and is not portable/reproducible as checked into the repo. |
| tests/fixtures/robocodec_test_24_leju_claw.bag | Adds a ~1.8MB ROS1 bag fixture used by new tests; review needed for repo policies on committing binary fixtures and test determinism. |
Sequence Diagram
sequenceDiagram
participant Caller as Client/Consumer
participant Factory as CodecFactory
participant Codec as CdrCodec (DynCodec)
participant Schema as SchemaMetadata::Cdr
participant Parser as schema parser
participant Decoder as CdrDecoder
Caller->>Factory: get_codec(Encoding::Cdr)
Factory-->>Caller: &dyn DynCodec (CdrCodec)
Caller->>Codec: decode_dynamic(data, schema)
Codec->>Schema: match SchemaMetadata::Cdr
Codec->>Parser: parse_schema_with_encoding_str(type_name, schema_text, schema_encoding)
Parser-->>Codec: MessageSchema
Codec->>Codec: is_ros1 = schema_encoding contains "ros1"
alt ROS1 schema_encoding
Codec->>Decoder: decode_headerless_ros1(parsed_schema, data, Some(type_name))
Decoder-->>Codec: DecodedMessage
else Standard CDR
Codec->>Decoder: decode(parsed_schema, data, Some(type_name))
Decoder-->>Codec: DecodedMessage
end
Codec-->>Caller: Result<DecodedMessage>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 3 comments
54ec4b0 to
a7021bf
Compare
When decoding ROS1 bag messages through the dynamic CDR codec path, we need to use decode_headerless_ros1() instead of decode() because: 1. ROS1 messages are stored without a CDR encapsulation header 2. ROS1 uses packed serialization (no alignment padding) The decode() method expects standard CDR format with alignment, which causes misalignment errors when reading ROS1 bag data. This change detects ROS1 encoding from the schema_encoding field and routes to the appropriate decoder method. Fixes roboflow_sources decode errors for ROS1 bag messages with string arrays and complex nested types.
a7021bf to
de560fa
Compare
Summary
When decoding ROS1 bag messages through the dynamic CDR codec path (
DynCodec), the code was usingdecode()which expects standard CDR format with alignment padding. However, ROS1 messages are stored:This mismatch caused decode errors for ROS1 bag messages, particularly those with string arrays or complex nested types.
Root Cause
The
DynCodec::decode()method was unconditionally callingself.decoder.decode()for all message schemas. This works for standard CDR but fails for ROS1 serialized data.Changes
schema_encoding.contains("ros1")decode_headerless_ros1()instead ofdecode()decode()as beforeFixes
Resolves decode errors in roboflow_sources when reading ROS1 bag files with messages like:
kuavo_msgs/lejuClawState(contains string arrays)Test
examples/test_leju_state.rsfor manual verificationrobocodec_test_24_leju_claw.bag