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

Fix multiple calls of cleanup when system is unconfigured #1279

Merged
merged 12 commits into from
Jan 12, 2024

Conversation

destogl
Copy link
Member

@destogl destogl commented Jan 8, 2024

Replaces #1175

bmagyar
bmagyar previously approved these changes Jan 8, 2024
@bmagyar bmagyar added backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. backport-iron labels Jan 8, 2024
Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (71506d5) 47.87% compared to head (b183b0f) 47.90%.

❗ Current head b183b0f differs from pull request most recent head 2aa0d02. Consider uploading reports for the commit 2aa0d02 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1279      +/-   ##
==========================================
+ Coverage   47.87%   47.90%   +0.03%     
==========================================
  Files          41       41              
  Lines        3453     3463      +10     
  Branches     1878     1883       +5     
==========================================
+ Hits         1653     1659       +6     
- Misses        444      445       +1     
- Partials     1356     1359       +3     
Flag Coverage Δ
unittests 47.90% <100.00%> (+0.03%) ⬆️

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

Files Coverage Δ
hardware_interface/src/actuator.cpp 58.77% <100.00%> (+1.49%) ⬆️
hardware_interface/src/sensor.cpp 49.48% <100.00%> (-1.05%) ⬇️
hardware_interface/src/system.cpp 58.77% <100.00%> (+1.49%) ⬆️

... and 4 files with indirect coverage changes

Copy link
Contributor

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

Should we also return OK in PRIMARY_STATE_FINALIZED? This would maybe fix #1103, see the last point of the instructions in ros-controls/ros2_control_demos#417

@destogl
Copy link
Member Author

destogl commented Jan 8, 2024

Oh, yes, will do tomorrow morning. :)

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @destogl.

One question, why don't we use return type OK by default, but when we enter the INACTIVE and ACTIVE state we set it the ERROR at the beginning after the condition, in such a way we don't have to code OK for every lifecycle state.

(or)

Something as simple as if and else and by default we return OK in else

  if (
    impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE ||
    impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
  {
    return_type result = impl_->read(time, period);
    if (result == return_type::ERROR)
    {
      error();
    }  
    return result;
  }
  else
  {
    return return_type::OK;
  }
}

What do you think?

In any case, the current changes look fine to me. :)

@destogl
Copy link
Member Author

destogl commented Jan 9, 2024

@saikishor, I see your point here. This is definitely a simpler code, but I would like to have it rather explicit. Any unplanned thing should end up in error and OK state should be set explict.

hardware_interface/src/actuator.cpp Outdated Show resolved Hide resolved
hardware_interface/src/actuator.cpp Outdated Show resolved Hide resolved
hardware_interface/src/sensor.cpp Outdated Show resolved Hide resolved
hardware_interface/src/system.cpp Outdated Show resolved Hide resolved
hardware_interface/src/system.cpp Outdated Show resolved Hide resolved
@saikishor
Copy link
Member

@saikishor, I see your point here. This is definitely a simpler code, but I would like to have it rather explicit. Any unplanned thing should end up in error and OK state should be set explict.

Make sense. I agree with you. Thanks for the explanation. 👍

Copy link
Contributor

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

Now it fixes #1103 too, thanks!

@christophfroehlich christophfroehlich linked an issue Jan 9, 2024 that may be closed by this pull request
@destogl destogl merged commit acbeeea into master Jan 12, 2024
12 checks passed
@destogl destogl deleted the fix_multiple_cleanup_on_unconfigured_components branch January 12, 2024 14:34
mergify bot pushed a commit that referenced this pull request Jan 12, 2024
…of finalized (#1279)

---------

Co-authored-by: Andrea Scipione <[email protected]>
Co-authored-by: Bence Magyar <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
(cherry picked from commit acbeeea)
mergify bot pushed a commit that referenced this pull request Jan 12, 2024
…of finalized (#1279)

---------

Co-authored-by: Andrea Scipione <[email protected]>
Co-authored-by: Bence Magyar <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
(cherry picked from commit acbeeea)
destogl added a commit that referenced this pull request Jan 12, 2024
…of finalized (#1279) (#1287)

---------

Co-authored-by: Andrea Scipione <[email protected]>
Co-authored-by: Bence Magyar <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
(cherry picked from commit acbeeea)

Co-authored-by: Dr. Denis <[email protected]>
destogl added a commit that referenced this pull request Jan 12, 2024
…of finalized (#1279) (#1286)

---------

Co-authored-by: Andrea Scipione <[email protected]>
Co-authored-by: Bence Magyar <[email protected]>
Co-authored-by: Dr. Denis <[email protected]>
(cherry picked from commit acbeeea)

Co-authored-by: Dr. Denis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble.
Projects
None yet
5 participants