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

Adding a simple services implementation #390

Open
haixuanTao opened this issue Dec 4, 2023 · 0 comments
Open

Adding a simple services implementation #390

haixuanTao opened this issue Dec 4, 2023 · 0 comments
Labels
python Python API

Comments

@haixuanTao
Copy link
Collaborator

haixuanTao commented Dec 4, 2023

Is your feature request related to a problem? Please describe.
Implementing a service features could simplify implementing certain dataflows, including supporting ROS 2 legacy applications.

API details

I think that we can actually build around our current pub-sub pattern to support request-reply.

What we could do is to make a new method called send_request or request that will send an output and receive an input in one blocking function call. The function will return the reply from the request.

To do that, we could add the following dataflow pattern:

  - id: webcam
    custom:
      source: ./webcam.py
      inputs:
        tick:
          source: dora/timer/millis/50
          queue_size: 1000
      outputs:
        - image
  - id: object_detection
    operator:
      python: ../operators/webcam/object_detection.py
      services:
        get_image:
           reply: webcam/image
           request: webcam/tick

With the following python operator request code:

image = send_service("get_image", tick)


## alternatively
image = send("service", "get_image", tick)
image = send("request", "get_image", tick)
image = send_request("get_image", tick)
image = request("get_image", tick)

With the following python custom node request code:

image = node.send_service("get_image", tick)


## alternatively
image = node.send("service", "get_image", tick)
image = node.send("request", "get_image", tick)
image = node.send_request("get_image", tick)
image = node.request("get_image", tick)```

The webcam code does need to be changed. And the underlying communication design does not need to change as well so we can still make it flexible.

Edge cases details

  • We should try to keep message that has been received in between the request-reply, so that to not miss out on important messages. And so some work has to be done within the message queue.

Open for discussions

@github-actions github-actions bot added the python Python API label Dec 4, 2023
@haixuanTao haixuanTao changed the title Adding a simple requests Adding a simple services implementation Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python API
Projects
None yet
Development

No branches or pull requests

1 participant