[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: writing a simple publisher and subscriber (python) (c++).
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Examining the Simple Publisher and Subscriber

Description: This tutorial examines running the simple publisher and subscriber.

Tutorial Level: BEGINNER

Next Tutorial: Writing a simple service and client (python) (c++)

Running the Publisher

Make sure that a roscore is up and running:

$ roscore

catkin specific If you are using catkin, make sure you have sourced your workspace's setup.sh file after calling catkin_make but before trying to use your applications:

# In your catkin workspace
$ cd ~/catkin_ws
$ source ./devel/setup.bash

In the last tutorial we made a publisher called "talker". Let's run it:

$ rosrun beginner_tutorials talker      (C++)
$ rosrun beginner_tutorials talker.py   (Python) 

You will see something similar to:

The publisher node is up and running. Now we need a subscriber to receive messages from the publisher.

Running the Subscriber

In the last tutorial we made a subscriber called "listener". Let's run it:

$ rosrun beginner_tutorials listener     (C++)
$ rosrun beginner_tutorials listener.py  (Python) 

You will see something similar to:

When you are done, press Ctrl-C to terminate both the listener and the talker.

Now that you have examined the simple publisher and subscriber, let's write a simple service and client (python) (c++).


2017-09-16 12:30