Skip to content

fix(ros2controlcli): use lifecycle nomenclature and add finalized sta…#3134

Open
shraavb wants to merge 3 commits intoros-controls:masterfrom
shraavb:fix/set-controller-state-lifecycle-nomenclature
Open

fix(ros2controlcli): use lifecycle nomenclature and add finalized sta…#3134
shraavb wants to merge 3 commits intoros-controls:masterfrom
shraavb:fix/set-controller-state-lifecycle-nomenclature

Conversation

@shraavb
Copy link
Copy Markdown

@shraavb shraavb commented Mar 22, 2026

Closes #688

Summary

Use ROS 2 lifecycle nomenclature consistently in the CLI and add the missing
finalized state to set_hardware_component_state.

Changes

set_controller_state.py

  • Replace informal "cleanup"/"stopping" with lifecycle terms (unconfigured, deactivating)
  • Improve help text to note that finalized is reached via unload_controller

set_hardware_component_state.py

  • Add finalized to valid choices using State.PRIMARY_STATE_FINALIZED
  • Fix if/if/ifif/elif/elif/elif for correct branch structure
  • Replace "cleaning up"/"stopping" with lifecycle terms throughout

Note on finalized for controllers

The controller manager has no FinalizeController service, so controllers cannot
be directly transitioned to finalized via this command. Hardware components can,
since SetHardwareComponentState.srv accepts any lifecycle state by ID.

Checklist

Copy link
Copy Markdown
Member

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thank you for submitting a PR.
The fixes of the if/elif branches and adding the finalized state are perfect, but I am not convinced from the rewording of the messages? I think this change is not needed.

I added a comment in the linked issue for clarification.

help="State in which the controller should be changed to",
help=(
"State in which the controller should be changed to. "
"Valid lifecycle states are: unconfigured, inactive, 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.

Is this needed? The help already prints the valid arguments:

  {unconfigured,inactive,active}
                        State in which the controller should be changed to

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I have reverted the help text change - you're right, the choices= already displays the valid arguments.
Kept the if/elif fixes and finalized state addition.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.36%. Comparing base (64b0963) to head (ae1474d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3134      +/-   ##
==========================================
+ Coverage   89.32%   89.36%   +0.04%     
==========================================
  Files         158      158              
  Lines       19497    19497              
  Branches     1584     1584              
==========================================
+ Hits        17416    17424       +8     
+ Misses       1428     1422       -6     
+ Partials      653      651       -2     
Flag Coverage Δ
unittests 89.36% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes

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

@shraavb shraavb force-pushed the fix/set-controller-state-lifecycle-nomenclature branch from de4d1c6 to 21ddb2c Compare March 28, 2026 23:29
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.

[ros2_control CLI] set_controller_state should support full lifecycle and use lifecycle nomenclature.

2 participants