Skip to content

feat: warn when ForwardCommandController receives commands while inactive - #2488

Open
Rudyy75 wants to merge 2 commits into
ros-controls:masterfrom
Rudyy75:fix/forward-command-warn-inactive
Open

feat: warn when ForwardCommandController receives commands while inactive#2488
Rudyy75 wants to merge 2 commits into
ros-controls:masterfrom
Rudyy75:fix/forward-command-warn-inactive

Conversation

@Rudyy75

@Rudyy75 Rudyy75 commented Jul 26, 2026

Copy link
Copy Markdown

Description

This PR fixes #1760 where ForwardCommandController silently ignores commands when it is in an inactive lifecycle state.
Changes made:

  • Added a lifecycle state guard (get_node()->get_current_state()) to the subscription callback in ForwardControllersBase.
  • It now logs a throttled warning (RCLCPP_WARN_THROTTLE) and drops the message if the controller is not in PRIMARY_STATE_ACTIVE.
  • Since it's implemented in the base class, it fixes this behavior for both ForwardCommandController and MultiInterfaceForwardCommandController.

Fixes #1760

Is this user-facing behavior change?

Yes, controllers will now log a warning when commands are received while inactive, instead of silently ignoring them.

Did you use Generative AI?

Yes, Claude Sonnet 4.6

Additional Information

TODOs

To send us a pull request, please:

  • Fork the repository.
  • Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
  • Ensure local tests pass. (colcon test and pre-commit run (requires you to install pre-commit by pip3 install pre-commit)
  • Commit to your fork using clear commit messages.
  • Send a pull request, answering any default questions in the pull request interface.
  • Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

"~/commands", rclcpp::SystemDefaultsQoS(),
[this](const CmdType::SharedPtr msg)
{
if (get_node()->get_current_state().id() != lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)

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.

IMHO this is not a problem as this subscriber does not run in the RT loop, but maybe this is faster:

Suggested change
if (get_node()->get_current_state().id() != lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
if (get_lifecycle_id() != lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)

For reference ros-controls/ros2_control#2884

@saikishor what is best practice here?

@christophfroehlich
christophfroehlich marked this pull request as ready for review July 29, 2026 07:59
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.84%. Comparing base (be6f504) to head (b2a1a44).

Files with missing lines Patch % Lines
...ommand_controller/src/forward_controllers_base.cpp 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2488      +/-   ##
==========================================
- Coverage   86.85%   86.84%   -0.02%     
==========================================
  Files         148      148              
  Lines       16267    16269       +2     
  Branches     1367     1368       +1     
==========================================
  Hits        14128    14128              
- Misses       1632     1633       +1     
- Partials      507      508       +1     
Flag Coverage Δ
unittests 86.84% <0.00%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
...ommand_controller/src/forward_controllers_base.cpp 79.66% <0.00%> (-2.80%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

ForwardCommandController: It should at least warn when receives messages while not active

2 participants