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

Services: list, call, response #10

Closed
jhurliman opened this issue Nov 8, 2022 · 4 comments · Fixed by #136
Closed

Services: list, call, response #10

jhurliman opened this issue Nov 8, 2022 · 4 comments · Fixed by #136
Assignees
Labels
feature New feature or request

Comments

@jhurliman
Copy link
Contributor

No description provided.

@jhurliman jhurliman added the feature New feature or request label Nov 8, 2022
@jhurliman
Copy link
Contributor Author

jhurliman commented Jan 13, 2023

An example implementation of calling ROS 2 services from a bridge can be found here: https://github.com/v-kiniv/rws/blob/main/src/client_handler.cpp#L406-L450. The method is straightforward, most of the work is in JSON<->CDR serde. We can avoid this by using our client binary serialization already used for topic publishing.

ROS 2 listing services: std::map<std::string, std::vector<std::string>> services = node_->get_service_names_and_types();

ROS 2 calling a service:

auto client = node_->create_generic_client(serviceName, serviceType, rmw_qos_profile_services_default, nullptr);
// if we include an immediate response back to clients calling a service, we can skip
// the wait_for_service() call and just return a failure if the service isn't available
while (!client->wait_for_service(1s)) { ... }
using ServiceResponseFuture = rws::GenericClient::SharedFuture;
auto callback = [&](ServiceResponseFuture future) {
  ConstSharedMessage msg = future.get();
  // send this message back to the client
};
client->async_send_request(msgFromClient, callback);
// send a confirmation to the client their service call was initiated?

@jhurliman
Copy link
Contributor Author

Based on the ROS 2 notes above, I think the bridge protocol for services could roughly look like this:

  • op: advertiseService // server -> client
  • op: unadvertiseService // server -> client
  • op: callService // client -> server
  • op: serviceAcknowledgement // server -> client
  • op: serviceResponse // server -> client

@achim-k
Copy link
Collaborator

achim-k commented Jan 13, 2023

  • op: serviceAcknowledgement // server -> client

What is this for? Acknowledging a client's service call request?

@jhurliman
Copy link
Contributor Author

Let's drop serviceAcknowledgement, but send an error back if the service is not running or there's another failure to initiate the service call.

achim-k added a commit that referenced this issue Feb 7, 2023
**Public-Facing Changes**
- Add ROS1 support for calling server-advertised services

**Description**
- Adds ROS1 support for advertising/unadvertising services and allowing
clients to call them
- Implements the services spec that was added in
foxglove/ws-protocol#344

Implementation details:
- The service type is unfortunately not stored on the ROS master, so for
every new service, a connection to the service server has to be opened
to fetch the service type from the connection header
- For ROS1, one can call services with a custom type (here
`GenericService`) when one defines the `ros::service_traits` and
`ros::serialization` traits


Fixes #10 (together with #142)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants