Skip to content

Remove hardcoded default update rate - #3273

Open
naitikpahwa18 wants to merge 3 commits into
ros-controls:masterfrom
naitikpahwa18:fix/remove-hardcoded-update-rate-1575
Open

Remove hardcoded default update rate#3273
naitikpahwa18 wants to merge 3 commits into
ros-controls:masterfrom
naitikpahwa18:fix/remove-hardcoded-update-rate-1575

Conversation

@naitikpahwa18

Copy link
Copy Markdown
Contributor

Description

The update_rate in ResourceManagerParams and cm_update_rate_ in ResourceStorage were hardcoded to 100 Hz as defaults. This caused simulators that override load_and_initialize_components or construct ResourceManager without explicitly setting the rate to silently run at the wrong frequency with no error. This PR changes the default to 0 as a sentinel value and adds an explicit validation in load_and_initialize_components that logs an error and returns false if update_rate is not set. Two tests that constructed ResourceManagerParams without setting update_rate are also fixed to explicitly pass 100.

Fixes #1575

Copilot AI review requested due to automatic review settings May 5, 2026 21:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the implicit 100 Hz fallback for ResourceManager update rates so hardware initialization now requires an explicit non-zero update_rate. It aligns ResourceManagerParams and constructor defaults with the new sentinel-based validation intended to prevent simulators and custom ResourceManager setups from silently running at the wrong frequency.

Changes:

  • Changed ResourceManager and ResourceManagerParams default update rates from 100 to 0.
  • Added a validation in load_and_initialize_components() that logs an error and returns false when update_rate is unset/zero.
  • Updated two tests that constructed ResourceManagerParams directly to pass an explicit update_rate.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
hardware_interface/src/resource_manager.cpp Switches internal default rate to 0 and rejects zero-rate initialization.
hardware_interface/include/hardware_interface/types/resource_manager_params.hpp Changes ResourceManagerParams::update_rate default and documents the new requirement.
hardware_interface/include/hardware_interface/resource_manager.hpp Updates public constructor/helper defaults to use the new zero sentinel.
hardware_interface_testing/test/test_resource_manager.cpp Fixes a test setup to provide an explicit update rate.
hardware_interface_testing/test/test_resource_manager_prepare_perform_switch.cpp Fixes another test fixture to provide an explicit update rate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1513 to +1518
if (params.update_rate == 0)
{
RCLCPP_ERROR(
params.logger, "update_rate is not set or is zero - cannot initialize hardware components.");
components_are_loaded_and_initialized_ = false;
return false;
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface,
rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logger_interface,
bool activate_all = false, const unsigned int update_rate = 100);
bool activate_all = false, const unsigned int update_rate = 0);
explicit ResourceManager(
const std::string & urdf, rclcpp::Clock::SharedPtr clock, rclcpp::Logger logger,
bool activate_all = false, const unsigned int update_rate = 100);
bool activate_all = false, const unsigned int update_rate = 0);

@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.

Please fix the failing pre-commit tests (better also install pre-commit install for future commits)

@bmagyar

bmagyar commented May 21, 2026

Copy link
Copy Markdown
Member

@naitikpahwa18 you'll also have to either merge & fix conflicts or rebase the PR onto the latest master branch. Currently there are 3 conflicting files

@naitikpahwa18
naitikpahwa18 force-pushed the fix/remove-hardcoded-update-rate-1575 branch from e294179 to fd3e949 Compare May 21, 2026 11:58
@naitikpahwa18

Copy link
Copy Markdown
Contributor Author

I'm currently looking into the CI failures, but I'm not yet sure whether they're related to changes in this PR or to unrelated CI issues.

@christophfroehlich

Copy link
Copy Markdown
Member

I'm currently looking into the CI failures, but I'm not yet sure whether they're related to changes in this PR or to unrelated CI issues.

Most of the jobs are green on the master branch (except of rolling-main ones). I suggest to compare the list of failing jobs with other PRs, for example the latest merged one https://github.com/ros-controls/ros2_control/commits/master/

@bmagyar

bmagyar commented Jun 4, 2026

Copy link
Copy Markdown
Member

@naitikpahwa18 all tests are failing because now they need the old default set manually.

@naitikpahwa18

Copy link
Copy Markdown
Contributor Author

@bmagyar Thanks for pointing that out. Should I update the tests to explicitly set the update rate where they currently rely on the old default, or is there a preferred approach you’d like me to follow?

@destogl

destogl commented Jun 22, 2026

Copy link
Copy Markdown
Member

@bmagyar Thanks for pointing that out. Should I update the tests to explicitly set the update rate where they currently rely on the old default, or is there a preferred approach you’d like me to follow?

You should of course update the tests if they rely on former default.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions Bot added the stale label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove hardcoded default update rate in Resource Manager - might cause issues with simulators

5 participants