Skip to content

fix: reset header stamps to zero in reset methods to prevent timeout#2197

Open
Ishan1923 wants to merge 36 commits into
ros-controls:masterfrom
Ishan1923:fix/1774-reset-header-stamps
Open

fix: reset header stamps to zero in reset methods to prevent timeout#2197
Ishan1923 wants to merge 36 commits into
ros-controls:masterfrom
Ishan1923:fix/1774-reset-header-stamps

Conversation

@Ishan1923

@Ishan1923 Ishan1923 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Problem: When controllers reset their internal reference messages, the initialization functions assigned the current time (now()) to the new empty message's timestamp. This caused the message 'age' calculation to yield 0 seconds, which allowed the empty message to bypass safety timeout checks.

Solution:

  • Modified the reset functions across the affected controllers to set the timestamp to rclcpp::Time(0) instead of the current time. This explicitly marks the reset message as an old/invalid command, ensuring the safety timeout logic halts the robot.
  • Applied (void)node; cast to silence -Werror=unused-parameter compiler warnings without altering existing function signatures. I was unsure to remove this const std::shared_ptr<rclcpp_lifecycle::LifecycleNode> & node as I might break ABI, but I guess this might not, as it completely separate.
  • Updated EXPECT_EQ to EXPECT_GT in t_est_mecanum_drive_controller.cpp_ to correctly test the timestamp update against the new 0 baseline. The old EXPECT_EQ tested against an incorrect now() baseline; EXPECT_GT correctly ensures the timestamp advanced from 0.

Affected Controllers:

  • admittance_controller
  • diff_drive_controller
  • gpio_controllers
  • mecanum_drive_controller
  • omni_wheel_drive_controller
  • steering_controllers_library

fix #1774

@Ishan1923 Ishan1923 changed the title fix: reset header stamps to zero in reset methods to prevent timeout … fix #1774: reset header stamps to zero in reset methods to prevent timeout Mar 4, 2026
@Ishan1923 Ishan1923 changed the title fix #1774: reset header stamps to zero in reset methods to prevent timeout fix: reset header stamps to zero in reset methods to prevent timeout #1774 Mar 4, 2026
@Ishan1923 Ishan1923 changed the title fix: reset header stamps to zero in reset methods to prevent timeout #1774 fix: reset header stamps to zero in reset methods to prevent timeout Mar 4, 2026
@codecov

codecov Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.62%. Comparing base (68630ae) to head (f4ed8b0).

Files with missing lines Patch % Lines
gpio_controllers/src/gpio_command_controller.cpp 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2197      +/-   ##
==========================================
+ Coverage   85.61%   85.62%   +0.01%     
==========================================
  Files         148      148              
  Lines       15837    15850      +13     
  Branches     1339     1341       +2     
==========================================
+ Hits        13559    13572      +13     
  Misses       1792     1792              
  Partials      486      486              
Flag Coverage Δ
unittests 85.62% <96.77%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...dmittance_controller/src/admittance_controller.cpp 74.65% <100.00%> (ø)
...iff_drive_controller/src/diff_drive_controller.cpp 80.36% <100.00%> (ø)
..._drive_controller/src/mecanum_drive_controller.cpp 84.63% <100.00%> (+0.18%) ⬆️
..._controller/test/test_mecanum_drive_controller.cpp 98.35% <ø> (ø)
...ive_controller/src/omni_wheel_drive_controller.cpp 83.07% <100.00%> (ø)
...llers_library/src/steering_controllers_library.cpp 67.58% <100.00%> (+0.70%) ⬆️
...library/test/test_steering_controllers_library.cpp 98.92% <100.00%> (+<0.01%) ⬆️
gpio_controllers/src/gpio_command_controller.cpp 83.60% <75.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread admittance_controller/src/admittance_controller.cpp Outdated
@Ishan1923

Copy link
Copy Markdown
Contributor Author

@christophfroehlich The function signatures have been updated for the rolling target.
Apologies for the delay; I was occupied with my mid-semester exams.

  • Removed the unused node parameter and (void)node; casts from the
    reset_controller_reference_msg local helper functions in:
    • admittance_controller
    • gpio_controllers
    • mecanum_drive_controller
    • steering_controllers_library
  • Local colcon test passes for all modified controllers.

@Ishan1923 Ishan1923 requested a review from thedevmystic March 27, 2026 15:30
Comment thread steering_controllers_library/src/steering_controllers_library.cpp
@mergify

mergify Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

This pull request is in conflict. Could you fix it @Ishan1923?

@Ishan1923 Ishan1923 requested a review from thedevmystic April 2, 2026 16:49
…bypass

Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
@Ishan1923 Ishan1923 force-pushed the fix/1774-reset-header-stamps branch from 28d2417 to cc93ee3 Compare April 2, 2026 17:08
Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
@Ishan1923

Copy link
Copy Markdown
Contributor Author

@christophfroehlich, @thedevmystic would you please have a look at this.

  • I have updated the function signature, removed the node parameter from reset_controller_reference_msg.

  • Moreover, I also updated the odometry_set_service test case in steering_controllers_library which started failing after the recent open-loop odometry merge (PR Fix open_loop odometry of steering controllers #2087). Because the open-loop odometry math now correctly integrates movement, the leftover simulated wheel feedback from previous test steps caused the robot to drift slightly during the update() call.

github-actions Bot and others added 15 commits May 27, 2026 02:53
… Joint State Broadcaster. (ros-controls#2082)

Co-authored-by: Sai Kishor Kothakota <saisastra3@gmail.com>
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
Co-authored-by: Surya! <thedevmystic@gmail.com>
…: admittance_controller, pose_broadcaster, tricycle_steering_controller (ros-controls#2345)
@mergify

mergify Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

This pull request is in conflict. Could you fix it @Ishan1923?

Ishan1923 added 2 commits May 27, 2026 03:06
Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
@Ishan1923

Copy link
Copy Markdown
Contributor Author

@christophfroehlich @thedevmystic merge conflict in mecanum_drive_controller.cpp has been resolved and pushed. Could you please take a look?

@saikishor

Copy link
Copy Markdown
Member

@christophfroehlich @thedevmystic merge conflict in mecanum_drive_controller.cpp has been resolved and pushed. Could you please take a look?

@Ishan1923 The CI builds are failing. Can you please take a look?

@bmagyar

bmagyar commented May 27, 2026

Copy link
Copy Markdown
Member

The CI is clearly unhappy still. Please ignore the main binary jobs but semi binaries and testing binaries should pass

@saikishor

Copy link
Copy Markdown
Member

@christophfroehlich @thedevmystic merge conflict in mecanum_drive_controller.cpp has been resolved and pushed. Could you please take a look?

  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp: In member function ‘virtual void SteeringControllersLibraryTest_odometry_set_service_Test::TestBody()’:
  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:428:13: error: no match for call to ‘(SteeringControllersLibraryTest_odometry_set_service_Test::TestBody()::<lambda(double, double)>) (double, double, double)’
    428 |   move_robot(0.0, 0.0, 0.0);
        |   ~~~~~~~~~~^~~~~~~~~~~~~~~
  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:409:23: note: there is 1 candidate
    409 |   auto move_robot = [&](double vx, double wz)

The code is not building for this error, can you take a look?

Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
@Ishan1923

Copy link
Copy Markdown
Contributor Author

@christophfroehlich @thedevmystic merge conflict in mecanum_drive_controller.cpp has been resolved and pushed. Could you please take a look?

  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp: In member function ‘virtual void SteeringControllersLibraryTest_odometry_set_service_Test::TestBody()’:
  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:428:13: error: no match for call to ‘(SteeringControllersLibraryTest_odometry_set_service_Test::TestBody()::<lambda(double, double)>) (double, double, double)’
    428 |   move_robot(0.0, 0.0, 0.0);
        |   ~~~~~~~~~~^~~~~~~~~~~~~~~
  /home/runner/work/ros2_controllers/ros2_controllers/.work/target_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:409:23: note: there is 1 candidate
    409 |   auto move_robot = [&](double vx, double wz)

The code is not building for this error, can you take a look?

The move_robot() function only takes 2 arguments:
auto move_robot = [&](double vx, double wz) {...};,

the error was from passing three arguments to it :
move_robot(0.0, 0.0, 0.0);

@Ishan1923

Copy link
Copy Markdown
Contributor Author

The CI is clearly unhappy still. Please ignore the main binary jobs but semi binaries and testing binaries should pass

The semi-binary(s) failures are infra failures :-

  • lyrical RHEL and Debian failing due to missing images (mainfest_unkown).
  • rolling RHEL semi-binary fails in realtime_tools due to a FastDDS ABI mismatch in upstream packages.

could you please confirm these are known infra issues

@christophfroehlich christophfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The 4 remaining failing jobs are known and not related.
Changes from this PR LGTM.

@christophfroehlich christophfroehlich requested review from saikishor and removed request for thedevmystic June 8, 2026 20:48

@saikishor saikishor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

void reset_wrench_msg(geometry_msgs::msg::WrenchStamped & msg)
{
msg.header.stamp = node->now();
msg.header.stamp = rclcpp::Time(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
msg.header.stamp = rclcpp::Time(0);
msg.header.stamp = rclcpp::Time(0, node->get_clock()->get_clock_type());

Maybe this is needed, seems like default is systemtime?

// Fill RealtimeBox with NaNs so it will contain a known value
// but still indicate that no command has yet been sent.
command_msg_.header.stamp = get_node()->now();
command_msg_.header.stamp = rclcpp::Time(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
command_msg_.header.stamp = rclcpp::Time(0);
command_msg_.header.stamp = rclcpp::Time(0, node->get_clock()->get_clock_type());

void reset_controller_reference_msg(gpio_controllers::CmdType & msg)
{
msg.header.stamp = node->now();
msg.header.stamp = rclcpp::Time(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
msg.header.stamp = rclcpp::Time(0);
msg.header.stamp = rclcpp::Time(0, node->get_clock()->get_clock_type());

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.

Reset header stamps to zero in reset methods