-
Notifications
You must be signed in to change notification settings - Fork 303
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
Robustify spawner #1501
Merged
Merged
Robustify spawner #1501
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
324a012
Add integration test with a lot of controller spawners
fmauch 7ee0fad
Do not wait for controller_manager node
fmauch e25ea4f
Re-add controller_manager_timeout
fmauch c7bbbb5
Resolve deadlock in calling controller_manager services
fmauch 9b4ecfc
Add missing controllers file
fmauch f26e536
Merge branch 'master' into robustify_spawner
destogl de424ac
Update controller_manager/controller_manager/controller_manager_servi…
destogl 484cd4a
Add call_timeout parameter to service_caller
fmauch 77f7e16
Add documentation to service_caller parameters
fmauch 3e3aded
Make base_joint a revolute joint
fmauch 85c593c
Use attempt counting with starting from 1
fmauch a98ca81
Add test_dependency on launch_testing_ament_cmake
fmauch aa0aa97
Correct error message on failed service call
fmauch 2120fd8
Add more test dependencies
fmauch a77c600
Add used controllers to test dependencies
fmauch 14028ea
Do not depend on other controllers
fmauch 66ac4e8
Reduce installation scope
fmauch a117f8c
Fix test_ros2_control_node.yaml
fmauch 723a896
Use gtest instead of launch_testing for integration test
fmauch 26262c6
Revert sorting package.xml
fmauch 49137f2
Revert fixing yaml
fmauch 6d627b5
Apply suggestions from code review
fmauch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,39 @@ class ServiceNotFoundError(Exception): | |
pass | ||
|
||
|
||
def service_caller(node, service_name, service_type, request, service_timeout=0.0): | ||
def service_caller( | ||
node, | ||
service_name, | ||
service_type, | ||
request, | ||
service_timeout=0.0, | ||
call_timeout=10.0, | ||
max_attempts=3, | ||
): | ||
""" | ||
Abstraction of a service call. | ||
|
||
Has an optional timeout to find the service and a mechanism | ||
to retry a call of no response is received. | ||
fmauch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@param node Node object to be associated with | ||
@type rclpy.node.Node | ||
@param service_name Service URL | ||
@type str | ||
@param request The request to be sent | ||
@type service request type | ||
@param service_timeout Timeout (in seconds) to wait until the service is available. 0 means | ||
waiting forever, retrying every 10 seconds. | ||
@type float | ||
@param call_timeout Timeout (in seconds) for getting a response | ||
@type float | ||
@param max_attempts Number of attempts until a valid response is received. With some | ||
middlewares it can happen, that the service response doesn't reach the client leaving it in | ||
a waiting state forever. | ||
@type int | ||
@return The service response | ||
|
||
""" | ||
cli = node.create_client(service_type, service_name) | ||
|
||
while not cli.service_is_ready(): | ||
|
@@ -44,12 +76,20 @@ def service_caller(node, service_name, service_type, request, service_timeout=0. | |
node.get_logger().warn(f"Could not contact service {service_name}") | ||
|
||
node.get_logger().debug(f"requester: making request: {request}\n") | ||
future = cli.call_async(request) | ||
rclpy.spin_until_future_complete(node, future) | ||
if future.result() is not None: | ||
return future.result() | ||
else: | ||
raise RuntimeError(f"Exception while calling service: {future.exception()}") | ||
future = None | ||
for attempt in range(max_attempts): | ||
future = cli.call_async(request) | ||
rclpy.spin_until_future_complete(node, future, timeout_sec=call_timeout) | ||
if future.result() is None: | ||
node.get_logger().warning( | ||
f"Failed getting a result from calling {service_name} in " | ||
f"{service_timeout}. (Attempt {attempt+1} of {max_attempts}.)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fmauch should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's right! Thanks for spotting this |
||
) | ||
else: | ||
return future.result() | ||
raise RuntimeError( | ||
f"Could not successfully call service {service_name} in {max_attempts} attempts." | ||
fmauch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
|
||
def configure_controller(node, controller_manager_name, controller_name, service_timeout=0.0): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmauch one more question, do you see an easy way to make these configurable by the user? My bringup is quite CPU intensive causing the call_timeout to be reached, however it works if I increase it a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, any harm in arbitrarily increasing it to e.g. 30?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1808