Skip to content

Fix publishing transient local topics before playing from start offset - #4

Draft
ajsampathk wants to merge 3 commits into
kiltedfrom
publish-transient-local-topics-for-start-offset
Draft

Fix publishing transient local topics before playing from start offset#4
ajsampathk wants to merge 3 commits into
kiltedfrom
publish-transient-local-topics-for-start-offset

Conversation

@ajsampathk

@ajsampathk ajsampathk commented Feb 9, 2026

Copy link
Copy Markdown

Publish transient_local topics when using --start-offset

When playing a bag with --start-offset, topics with TRANSIENT_LOCAL durability (e.g. /robot_description, /tf_stati, /map_amcl) are skipped because they are only published at the beginning of the bag.

This change ensures the last message for each transient_local topic recorded before the start offset is published at the start of playback, so subscribers still receive essential latched data.

Tested on a couple bags from with

ros2 bag play BAG --start-offset 3600 --clock

And it works fine.

// transient_local topic that was recorded before the start offset.
// This ensures latched data (e.g. /robot_description, static TFs) is
// available to subscribers even when playback starts partway through.
publish_transient_local_messages_before_start_offset();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This potentially seek(begin), right after seek(starting_time_). Seek can be a costly operation, maybe reorder the seek() and the publish_transient_local_messages_before_start_offset?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is a good point, I do readers_->seek(starting _time_) in the function so the previous seek is wasteful.

Thanks for the feedback. Will fix when I get a minute and try and propose this as a new feature upstream.

@ajsampathk
ajsampathk marked this pull request as draft April 29, 2026 15:18
…start_offset

The function always seeks to earliest_time internally before scanning,
so the seek(starting_time_) preceding it was wasted. Reorder so the
function runs first and the single seek(starting_time_) follows,
reducing three seeks to two in the transient-local path.

https://claude.ai/code/session_01R4sSw7NnQSaDmgQQB3Z6ZD
Remove redundant seek in publish_transient_local_messages_before_start_offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants