ros2 runtime_error ai_generated true

ros2 bag play: Clock time is not being published

ID: ros2/ros2-bag-play-clock-error

Also available as: JSON · Markdown
90%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

Nodes use use_sim_time:=true but ros2 bag play is not publishing /clock, or vice versa.

generic

Workarounds

  1. 95% success Use --clock flag when playing bags
    ros2 bag play my_bag --clock 100  # publishes /clock at 100 Hz
  2. 90% success Set use_sim_time:=true on ALL nodes when replaying bags
    ros2 launch my_pkg replay.launch.py use_sim_time:=true
  3. 85% success Use --rate to control playback speed while keeping clock consistent
    ros2 bag play my_bag --clock 100 --rate 0.5  # half speed

Dead Ends

Common approaches that don't work:

  1. Set use_sim_time on some nodes but not others 90% fail

    Causes TF extrapolation errors: some nodes use wall clock, others use sim time

  2. Publish /clock manually at a fixed rate 82% fail

    Clock must advance with bag time, not independently; manual clock causes data-time mismatch