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.
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.
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.
Oh you're right.
So a large negative would be used to wait, but that timeout is passed here:
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.
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.
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 <william@osrfoundation.org>
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 <william@osrfoundation.org> * 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 <dan@digilabs.io>
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