Skip to content

Fix Rate::sleep not resyncing after a backward time jump - #3362

Open
ahcorde wants to merge 2 commits into
rollingfrom
ahcorde/rolling/fix_rate_backward_time_jump
Open

ahcorde wants to merge 2 commits into
rollingfrom
ahcorde/rolling/fix_rate_backward_time_jump

Conversation

@ahcorde

@ahcorde ahcorde commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

After a backward time jump, Rate::sleep() correctly schedules the next wakeup at now + period, but then advances last_interval_ from the old timeline (last_interval_ += period_). Every following call sees now < last_interval_ again and sleeps a full period after the work finishes, so the loop runs at period + work time until the clock catches up (forever with a looping bag).

  • Set last_interval_ = next_interval. Without a time jump this is the same value as before.
  • Add a test using ROS time override that jumps back and checks the next wakeup is one period after the previous one.

Did you use Generative AI?

Claude Opus 5.5

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde ahcorde self-assigned this Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

ABI Compliance Check

❌ Verdict: incompatible

Library Verdict Summary
libcomponent_manager.so ✅ compatible No ABI changes detected.
librclcpp.so ❌ incompatible ABI changed: 0 removed, 1 changed, 0 added declaration(s); removed or changed declarations break backward compatibility.
librclcpp_action.so ✅ compatible No ABI changes detected.
librclcpp_lifecycle.so ✅ compatible No ABI changes detected.
✅ libcomponent_manager.so — full abidiff report

Compared:

  • Base: lib-base/libcomponent_manager.so
  • Head: lib-pr/libcomponent_manager.so @ e909a2b
(empty report — no differences printed by abidiff)
❌ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ e909a2b
Functions changes summary: 0 Removed (45 filtered out), 1 Changed (1722 filtered out), 0 Added (20 filtered out) functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'method rclcpp::node_interfaces::NodeParameters::NodeParameters(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr, rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr, rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr, rclcpp::node_interfaces::NodeServicesInterface::SharedPtr, rclcpp::node_interfaces::NodeClockInterface::SharedPtr, const std::vector<rclcpp::Parameter, std::allocator<rclcpp::Parameter> >&, bool, bool, const rclcpp::QoS&, const rclcpp::PublisherOptionsBase&, bool, bool)' at node_parameters.cpp:67:1 has some indirect sub-type changes:
    implicit parameter 0 of type 'rclcpp::node_interfaces::NodeParameters*' has sub-type changes:
      in pointed to type 'class rclcpp::node_interfaces::NodeParameters' at node_parameters.hpp:83:1:
        type size changed from 2496 to 2624 (in bits)
        no member function changes (24 filtered);
        1 data member insertion:
          'rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr node_logging_', at offset 2368 (in bits) at node_parameters.hpp:260:1
        1 data member changes (1 filtered):
          'rclcpp::node_interfaces::NodeClockInterface::SharedPtr node_clock_' offset changed from 2368 to 2496 (in bits) (by +128 bits)


✅ librclcpp_action.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_action.so
  • Head: lib-pr/librclcpp_action.so @ e909a2b
(empty report — no differences printed by abidiff)
✅ librclcpp_lifecycle.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_lifecycle.so
  • Head: lib-pr/librclcpp_lifecycle.so @ e909a2b
(empty report — no differences printed by abidiff)

Updated for commit e909a2b · check run · suppressions: /home/runner/work/_temp/ros2-abi-suppressions.txt

while (!done) {
std::this_thread::sleep_for(1ms);
ros_time += RCL_MS_TO_NS(10);
EXPECT_EQ(RCL_RET_OK, rcl_set_ros_time_override(clock_handle, ros_time));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think this is racy condition. should we hold the mutex clock->get_clock_mutex() to avoid thta?

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants