Can a node be a Publisher/Subscriber and a Service/Client at the same time

asked 2020-04-05 01:30:45 -0500

forbiddenfruit gravatar image

updated 2020-04-05 10:58:35 -0500

Hi Folks, Just starting out with ROS2 and I am trying to figure out if one node can be publisher/subscriber AS WELL as a service/client. If so how, and could you possibly present an example!

The biggest problem I think I am facing is spinning the node. The examples I have worked through for service/client only spin once, check if the future is completed and exit out of the situation. They check for the future variable AFTER. When I try to make it just spin (instead of spin once) the future variable never updates, leaving a client that never got a response back to their response. Any help would be great!

edit retag flag offensive close merge delete

Comments

You can spawn another node within your node, create a new thread for it to do an asynchronous service call and then shut it down again.

highmax1234 gravatar image highmax1234  ( 2021-05-11 15:29:02 -0500 )edit