Ask Your Question
0

Is it possible to have a Subscriber inside the Service Server

asked 2019-12-08 13:02:23 -0600

Yehor gravatar image

Hello,

I want to create a ROS service which will perform the docking based on the IR sensors. But for that I need a consistent feedback from IR receivers to navigate, so another words I have to have subscriber inside the service server which will get the information from IR topics while performing docking. Do I can implement subscriber inside the Service server??

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-12-08 13:54:03 -0600

gvdhoorn gravatar image

updated 2019-12-08 15:17:36 -0600

I want to create a ROS service which will perform the docking based on the IR sensors. [..] Do I can implement subscriber inside the Service server??

Yes you can, but you don't want to do this (for multiple reasons).

The main reason not to do this would be: services are not meant for long running operations, as both client and server will be blocked until the service has completed. Even worse: clients have no way of cancelling a service invocation, so they are completely "at the mercy" of the service server during that time.

Instead, implement an action server and update the client periodically on the progress.

Actions are comparable to C++ and Python futures and/or asynchronous services. Clients can choose to wait for completion, or register a callback and get notified about both progress and on completion, but are otherwise completely decoupled from the action server.

See also wiki/ROS/Patterns/Communication and #q11834.

And as an example, you may want to take a look at the kobuki_auto_docking package, and the accompanying tutorial: wiki/kobuki/Tutorials/Automatic Docking. They use the same approach.

Actually: you may even be able to reuse the code: it also uses IR sensors and commands the robot using geometry_msgs/Twist messages. If your robot has a similar interface -- and your docking station is setup similarly -- you may be able to just reuse kobuki_auto_docking, which could save you a lot of time.


1) In case I'm going to use an action server, I am going to implement a subscriber inside the server, because that what I need.

Yes, you'd add your subscriber to the action server.

And is it possible to use it with Python?

actionlib also supports Python.

2) I saw kobuki auto docking, but I didn't find an action server, only the client. So a don't know how do they implement the server. If you know where it is, could you please provide me the link.

See kobuki_auto_docking/src/auto_docking_ros.cpp.

edit flag offensive delete link more

Comments

Thank you! But can I clarify something?

1) In case I'm going to use an action server, I am going to implement a subscriber inside the server, because that what I need. Is it right? And is it possible to use it with Python?

2) I saw kobuki auto docking, but I didn't find an action server, only the client. So a don't know how do they implement the server. If you know where it is, could you please provide me the link. Because I will also need to set up a dock station, I am talking about the encoding of the signals which I have to send from IR.

Thank you

Yehor gravatar imageYehor ( 2019-12-08 15:08:57 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-12-08 13:02:23 -0600

Seen: 33 times

Last updated: Dec 08 '19