ros2
runtime_error
ai_generated
true
ros2 bag play: Clock time is not being published
ID: ros2/ros2-bag-play-clock-error
90%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Nodes use use_sim_time:=true but ros2 bag play is not publishing /clock, or vice versa.
genericWorkarounds
-
95% success Use --clock flag when playing bags
ros2 bag play my_bag --clock 100 # publishes /clock at 100 Hz
-
90% success Set use_sim_time:=true on ALL nodes when replaying bags
ros2 launch my_pkg replay.launch.py use_sim_time:=true
-
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:
-
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
-
Publish /clock manually at a fixed rate
82% fail
Clock must advance with bag time, not independently; manual clock causes data-time mismatch