Can you combine Publisher, Subscriber, Clients, Servers? And what is the best way to do it?

Hey Guys I just finished my first ROS-Tutorial and now I have a basic Question about Publisher/Actions/Services. I have the following Example in Mind:

Imagine I I have a System consisting of: a Robot, a Joystick and a Station. The goal is, that when a button on the joystick is pressed, The robot should drive to the Station. I am not quiet sure where to use which concept. My idea would be:

joystick_node [Publisher + Service Client]: It would publish the inputs and when a certain button is pressed, start the Station Detection Service.
station_detection_node [Subscriber + Service Server + Action Client]: Is a service that starts, when the button ist pressed. Needs to Subscribe to the sensor data, to be able to detect the station. And starts the go-to-Station Action, when its done.
go_to_Station_Node**[Action Server, Subscriber]**: Starts only when station_detection is done. And subscribes to the localiztation data.

What do you think about this? So far I only have seen Nodes to be Subscriber or Publisher or Client or Server. But my Station Detection would be Subscriber, Service Server and Action Client. Is that even possible? Are there more typical Ros-Ways?

Hi @GianAlessio, interesting idea you are having here. Yes, it is posible, in one script you can have as many subscribers, publishers, services, actions, etc. as you need, perhaps it is not the best idea to fit all of them in one script because of maintainability of the code, i think is always a bettter idea to have diferent scripts with simple tasks. Also, bear in mind that when a service is called, the script “stops” until it get response. Finally, this joystick functionality already exist, the husky robot implements it.

oh ok. Because in the courses I havent seen much about these combined nodes.

What would be the typical ROS-Way with different scipts for my station detection node?
The station detection needs to:

  1. Be activated somehow in the right moment
  2. Receive Sensordata for detecting the Station
  3. Tell the position of the station
  4. And start the trajectory planning.