ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

What are the criteria for selecting services or actions? Did they change in ROS2 due to asynchronous services?

asked 2021-05-01 04:54:47 -0600

Kenji Miyake gravatar image

In ROS1, this page says that services

  • should be used for remote procedure calls that terminate quickly
  • should never be used for longer running processes

I'm not sure the specific amount of "long", but I guess this is because services were synchronous in ROS1, am I correct?

Now I think services became asynchronous in ROS2 and this page doesn't say we shouldn't use services for long tasks. Also, seeing this page, I think the point of selecting services or actions are

  • whether we cancel tasks
  • whether we need feedback

So I guess we can use services for a bit long tasks now. For example, suppose that there is a task that takes 30 seconds, and we don't need to know the progress and don't need to cancel it.

Is it okay to use services for the task? Or are any problems?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-05-02 16:06:12 -0600

sgvandijk gravatar image

The asynchronicity indeed ensures that your node will not be stalled until a response comes back in ROS 2. If you don't require progress or the option to cancel the request then there will be no issue in your example.

Actually IMO in ROS 2 it's better to think that way about services: you make a request and you don't know how long you will wait for it, you just make sure to handle the response in a callback. As several questions on here show (e.g. this one), trying to stick to the ROS 1 thought model is not well supported.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-05-01 04:54:47 -0600

Seen: 105 times

Last updated: May 02 '21