Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup wrong lifecycle transitions in tests and unnecessary checks #1534

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Feb 11, 2025

  • We can assume that only valid transitions are performed (on_configure only if on_init succeeded)
  • CM calls the update methods of controllers only in active state, so we don't have to check that again, and we also should not do that in the tests.

Closes #417 and closes #405 and closes #1501

saikishor
saikishor previously approved these changes Feb 11, 2025
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.49%. Comparing base (c83cfb3) to head (34b4a2c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1534      +/-   ##
==========================================
+ Coverage   84.27%   84.49%   +0.21%     
==========================================
  Files         123      123              
  Lines       11359    11297      -62     
  Branches      961      950      -11     
==========================================
- Hits         9573     9545      -28     
+ Misses       1470     1446      -24     
+ Partials      316      306      -10     
Flag Coverage Δ
unittests 84.49% <100.00%> (+0.21%) ⬆️

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

Files with missing lines Coverage Δ
...iff_drive_controller/src/diff_drive_controller.cpp 74.77% <100.00%> (+1.96%) ⬆️
...ive_controller/test/test_diff_drive_controller.cpp 94.31% <ø> (-0.02%) ⬇️
...mand_controller/src/forward_command_controller.cpp 100.00% <ø> (+20.00%) ⬆️
...src/multi_interface_forward_command_controller.cpp 100.00% <ø> (+18.75%) ⬆️
gpio_controllers/src/gpio_command_controller.cpp 86.78% <ø> (+1.47%) ⬆️
...per_controllers/gripper_action_controller_impl.hpp 32.11% <ø> (+0.68%) ⬆️
..._state_broadcaster/src/joint_state_broadcaster.cpp 89.17% <ø> (-0.07%) ⬇️
..._broadcaster/test/test_joint_state_broadcaster.cpp 96.60% <ø> (-0.03%) ⬇️
...ory_controller/src/joint_trajectory_controller.cpp 85.21% <ø> (+0.32%) ⬆️
...ectory_controller/test/test_trajectory_actions.cpp 97.10% <ø> (-0.01%) ⬇️
... and 6 more

... and 3 files with indirect coverage changes

bmagyar
bmagyar previously approved these changes Feb 12, 2025
@christophfroehlich christophfroehlich changed the title Cleanup wrong lifecycle transitions and unnecessary checks Cleanup wrong lifecycle transitions in tests and unnecessary checks Feb 12, 2025
@@ -101,15 +101,6 @@ controller_interface::return_type DiffDriveController::update_reference_from_sub
const rclcpp::Time & time, const rclcpp::Duration & /*period*/)
{
auto logger = get_node()->get_logger();
if (get_lifecycle_state().id() == State::PRIMARY_STATE_INACTIVE)
{
if (!is_halted)
Copy link
Member

Choose a reason for hiding this comment

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

Do we also need to remove the is_halted variable, if it is a member variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we use it in on_deactivate() transition

Copy link
Member

Choose a reason for hiding this comment

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

Can't we simply call halt in the deactivate method always, instead of using this is_halted variable?

What do you think?

I can recheck the code later and get back to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could, sure.

Comment on lines 385 to 389
if (!is_halted)
{
halt();
is_halted = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

@christophfroehlich why do we need this here?

Copy link
Contributor Author

@christophfroehlich christophfroehlich Feb 12, 2025

Choose a reason for hiding this comment

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

to stop the vehicle in deactivate transition

Copy link
Member

Choose a reason for hiding this comment

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

Same as above, can't we simply call halt without any check in the deactivate method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants