Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/encoding/cdr/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,20 @@ impl DynCodec for CdrCodec {
crate::schema::parse_schema(type_name, schema_text)?
};

// Decode using the existing CDR decoder
self.decoder.decode(&parsed_schema, data, Some(type_name))
// Decode using the appropriate method based on schema encoding.
// ROS1 bag messages are serialized WITHOUT a CDR encapsulation header
// and use packed layout (no alignment padding), so they need
// decode_headerless_ros1() instead of decode().
let is_ros1 = schema_encoding
.as_ref()
.is_some_and(|enc| enc.to_lowercase().contains("ros1"));

if is_ros1 {
self.decoder
.decode_headerless_ros1(&parsed_schema, data, Some(type_name))
} else {
self.decoder.decode(&parsed_schema, data, Some(type_name))
}
}
_ => Err(CodecError::invalid_schema(
schema.type_name(),
Expand Down
Binary file added tests/fixtures/robocodec_test_24_leju_claw.bag
Binary file not shown.
Loading