ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Yes, it is possible.
I don't know what is your goal but please reconsider your software design. In most cases is not needed publisher and subscriber at one place (doesn't have to be your case). Mostly: publisher is for sensor and subscriber is for the actuator, for example you may want to publish the data from rotary encoder from motor, and then you may want to send the data to the subscriber to the driver of the motor. At the very beginning the motor is considered as an one part. But in the detailed view there are two parts: the sensor and the actuator. And they can be launched via launch file in two separate threads. But again I don't know your intentions so doesn't have to be your case.
To your question: Take a look at this: link text
Try to google it (it may take i while) but there are examples on the internet.
Or you can publish your data in callback from subscriber (that is an Echo node) also a plenty examples on the internet. (Study this as an example)
Hope it helps. :-)