-
Notifications
You must be signed in to change notification settings - Fork 128
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
Added support for clients and services #146
Conversation
27c535f
to
7c6944a
Compare
Hi @esteve , My name is Shubham Chauhan. My team is using ros2 in our project. We are considering to use rust client for writing ros2 nodes. Currently, we are using CPP client. So I was looking into this repo. Although we found out it doesn't support services and clients yet. But as I can see, that will be supported once this PR has been merged. So could you tell us when this will be merged in the master and be officially supported? And if we can help you with anything, please let us know. |
@esteve Could you rebase this onto master? Also, what design decisions did you make along the way? |
Actually, nevermind with rebasing the whole thing - I think it would be better to open separate PRs for message generation and service (without client) first. |
8120cec
to
d85d298
Compare
@nnmm I've rebased anyway, I'd rather get all the changes in, generating clients and services by itself won't be of much use. |
@i-am-chauhan this should be almost ready for merging. In any case, your team can help by trying out this branch (or the rest of ros2-rust), we always welcome feedback! |
@esteve I was thinking that splitting it up into PRs would make it easier to review. This PR will gain many comments otherwise, since it's so large, which could get hard to keep an overview of. You can also make the new modules private if you don't want to have the partial features exposed on master. |
@nnmm I see what you mean and I'd agree, but given that messages are in sync with the API, splitting them wouldn't help much, so I prefer to keep both in the same PR to make sure that any changes in either side match. |
575cd40
to
24eab94
Compare
Great to see this PR moving forward :) |
c0f2251
to
7765b3e
Compare
Hi @esteve , couple of days ago, I was trying to write some service nodes using this. Things were working then. But when I upgraded to latest of this branch, It's not compiling. And I can see there is lot of changes being made here. So I guess I'll have to wait till it's a bit stable. |
@i-am-chauhan the latest commit should fix all the compilation issues, there will be more internal cleanups, but I don't expect the API to change much. Could you give it a try again? Thanks! |
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.
Apologies for the long delay in reviewing this. I finally had some spare time to look it over.
Getting services into ros2-rust is super exciting! I have some feedback on the callback signatures which loosely amounts to "I wish rclcpp
had done it this way from the start, so maybe we can have ros2-rust do things in a 'better' (subjective, I know) way from the start".
If my suggestions sound interesting I'll be happy to try making the changes and submit a PR that targets this one.
As the guy who implemented services in This PR is meant to be a first stake at clients and services, with the bare minimum implemented to make it useful for users and to finally make a first release of |
Makes sense, I'll be happy to do a follow-up PR in the future 👍 |
All feedback addressed, thanks everyone! Please have another look. If there any improvements, but are not super urgent, please open follow up tickets, I'd like to merge this soon and wrap up a new release. |
Great! I agree we're really close to merging this. I commented on two threads where I think changes are needed. |
@nnmm thanks for your feedback! I've applied the |
Could you also add clients/services it to the list of features in |
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.
Just a quick question about a comment.
Hi @esteve , I have created a PR for this with minimal changes. Please have a look and let me know if something needs to change. |
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.
Did my final review, only some nitpicks remaining.
err, | ||
s: topic.into(), | ||
})?; | ||
let rcl_node = { &mut *node.rcl_node_mtx.lock() }; |
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.
let rcl_node = { &mut *node.rcl_node_mtx.lock() }; | |
let rcl_node = &mut *node.rcl_node_mtx.lock(); |
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.
I can't find the thread, but this was changed based on @jhdcs 's suggestion to not lock the Node
's mutex for the entirety of the function and only for the handle instead. We should revisit the other handles in the codebase to make sure we're not locking too much.
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.
I agree with the idea, but I believe as long as you hold the mutable reference, the mutex stays locked.
} | ||
Err(e) => return Err(e), | ||
}; | ||
let requests = &mut *self.requests.lock(); |
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.
No need to change anything, just a remark: The &mut *
to convert the MutexGuard into a reference is mostly just needed when passing something to an rcl function, here and in a few other places we can also write self.futures.lock().remove()
.
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.
🚀🚀🚀🚀
@esteve Don't you want to merge it? :) |
This PR adds support for clients and services. Includes a very primitive implementation of a
Future
which will surely evolve once we support the executor API (see #126).