Skip to content

fix(rosbag): widen Reader.messages start by 1ns to dodge rosbags MCAP chunk-filter off-by-one#279

Merged
hakuturu583 merged 2 commits into
feat/rosbag-lidar-readerfrom
fix/rosbag-chunk-offbyone
Jun 3, 2026
Merged

fix(rosbag): widen Reader.messages start by 1ns to dodge rosbags MCAP chunk-filter off-by-one#279
hakuturu583 merged 2 commits into
feat/rosbag-lidar-readerfrom
fix/rosbag-chunk-offbyone

Conversation

@hakuturu583
Copy link
Copy Markdown

Summary

Defensive workaround for an off-by-one bug in rosbags' MCAP backend that causes Rosbag2Reader.get_pointcloud (introduced in #277) to drop messages sitting at chunk boundaries. Observed loss is data-dependent but can exceed 50% for high-rate topics such as LiDAR packets.

Root cause (in rosbags upstream)

rosbags/rosbag2/storage_mcap.py:591:

if (start is None or start < x.message_end_time):

message_end_time is the inclusive timestamp of the chunk's last message, so the comparison should be <=. When the message we want is the last message of its chunk, the chunk is excluded from the search and the query returns empty.

Fix

Widen start by 1ns in Rosbag2Reader.get_pointcloud. The interval [target_ns - 1, target_ns + 1) still uniquely identifies the target packet (timestamps within the same topic are not packed at 1ns spacing).

Impact

On one production T4 dataset (50 frames, 6 LiDAR channels), 334 of 571 hesai_front_left packets (~58%) were previously unretrievable; all packets resolve after this fix.

Follow-up

A separate issue will be filed against rosbags upstream to fix the comparison at the true root cause. Once that lands and we bump our pinned rosbags, this widening remains correct and can stay as-is.

Test plan

  • New regression test in tests/rosbag/test_reader.py exercises a packet at a chunk boundary
  • pytest tests/rosbag/ -v passes
  • ruff check clean

🤖 Generated with Claude Code

… chunk-filter off-by-one

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added bug Something isn't working ci Continuous Integration (CI) processes and testing labels Jun 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
4588 3782 82% 50% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
t4_devkit/rosbag/reader.py 72% 🔴
TOTAL 72% 🔴

updated for commit: 20ea389 by action🐍

@hakuturu583 hakuturu583 merged commit 228694c into feat/rosbag-lidar-reader Jun 3, 2026
@hakuturu583 hakuturu583 deleted the fix/rosbag-chunk-offbyone branch June 3, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci Continuous Integration (CI) processes and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant