-
Notifications
You must be signed in to change notification settings - Fork 436
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
add wait_for_action_server() for action clients #598
Conversation
df989f0
to
df248de
Compare
rclcpp_action/src/client.cpp
Outdated
return true; | ||
} | ||
// server is not ready, loop if there is time left | ||
time_to_wait = timeout - (std::chrono::steady_clock::now() - start); |
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.
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.
Why would that be a problem? If timeout is a large negative (or a small one) then the while loop will exit just afte this and false
will be returned.
(your link doesn't work for me btw)
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.
Why would it exit? If timeout < std::chrono::nanoseconds(0)
holds, then it'll loop. Yes, I saw the client code too. Same observation.
(Fixed the link, not sure what happened)
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.
Oh you're right.
So a large negative would be used to wait, but that timeout is passed here:
graph_cv_.wait_for(graph_lock, timeout, pred); |
Which if negative will just wake up immediately.
So I think the code works, but maybe it could be more efficient. So I don't know what you would like to do differently here?
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.
Right, I checked std::condition_variable
reference and it doesn't say much really, so I'd guess you're right about it waking up immediately. It makes for a sophisticated busy loop :). I'll push a commit with a slightly different approach, that I think achieves what the function intent is.
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.
Sounds good to me, but we should also change the service one at the same time, since it actually has a lot of code utilizing it (via tests and stuff).
Signed-off-by: William Woodall <[email protected]>
df248de
to
be32a5f
Compare
W.r.t. to the waiting code, it was copied mostly verbatim from the existing wait for service code: rclcpp/rclcpp/src/rclcpp/client.cpp Lines 112 to 162 in fe09d93
So any comments about it will also apply to that code. |
* add wait_for_action_server() for action clients Signed-off-by: William Woodall <[email protected]> * Handle negative timeouts in wait_for_service() and wait_for_action_server() methods. * Fix uncrustify errors. * Ignore take failure on services for connext
Signed-off-by: Dan Rose <[email protected]>
This is based on a glob of changes needed for me to write the action tests in
test_communication
. It will have to be rebased when #594 and #593 are merged.c7c1738 is the only commit that is "new" to this pr.
Connects to ros2/system_tests#316