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

Use singleton approach to store and reuse the service clients #1949

Conversation

saikishor
Copy link
Member

@saikishor saikishor commented Dec 16, 2024

Fixes: #1934

the node.destroy_node() at the end does the same thing by destroying clients and every subscribers, publishers etc (https://github.com/ros2/rclpy/blob/8f1f16f16090184062f1993728d063ff2680f958/rclpy/rclpy/node.py#L2017-L2053)

@saikishor
Copy link
Member Author

@bijoua29 Check this approach to handle the same situations

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.71%. Comparing base (7374c43) to head (6ab29a3).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1949      +/-   ##
==========================================
- Coverage   87.73%   87.71%   -0.02%     
==========================================
  Files         122      122              
  Lines       13010    13020      +10     
  Branches     1165     1166       +1     
==========================================
+ Hits        11414    11421       +7     
- Misses       1165     1167       +2     
- Partials      431      432       +1     
Flag Coverage Δ
unittests 87.71% <100.00%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
.../controller_manager/controller_manager_services.py 80.95% <100.00%> (+1.57%) ⬆️
controller_manager/controller_manager/spawner.py 73.28% <100.00%> (+0.20%) ⬆️

... and 1 file with indirect coverage changes

@bijoua29
Copy link
Contributor

@saikishor Looks good to me but let me test this in the actual application

@saikishor
Copy link
Member Author

@saikishor Looks good to me but let me test this in the actual application

Sure. Go ahead. Please let us know if this helps in such situations.

I've only manually verified in the tests that if it is reusing it or not. This fix along with the multiple controllers spawning should be more robust

Copy link
Contributor

@bijoua29 bijoua29 left a comment

Choose a reason for hiding this comment

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

LGTM

@bijoua29
Copy link
Contributor

@saikishor I tested the PR in our application and replicated the same results as before i.e. improvement in controller startup success. So I think we can merge this in. I approved it. BTW, I wouldn't say it completely fixes #1934 but it definitely improves it.

I will close #1947 in lieu of this PR.

Copy link
Contributor

@fmauch fmauch left a comment

Choose a reason for hiding this comment

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

This seems great!

@saikishor saikishor added the backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. label Dec 17, 2024
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.

What do we have to change in ros2_control_demo_testing to make this work?

@saikishor
Copy link
Member Author

saikishor commented Dec 17, 2024

What do we have to change in ros2_control_demo_testing to make this work?

Thanks for bringing it to our attention @christophfroehlich. Now it should be all good. I verified locally

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.

LGTM, thanks for taking care of the downstream test failures ;)

@christophfroehlich christophfroehlich merged commit b039baa into ros-controls:master Dec 17, 2024
22 of 25 checks passed
@saikishor saikishor deleted the reuse/service/clients/spawner branch December 17, 2024 16:05
mergify bot pushed a commit that referenced this pull request Dec 17, 2024
(cherry picked from commit b039baa)

# Conflicts:
#	controller_manager/controller_manager/controller_manager_services.py
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
Development

Successfully merging this pull request may close these issues.

One or more controllers fail to start up when starting all of them simultaneously
4 participants