Unknown topic /counter, publishers and subscribers


I have created the package as asked in example 4.3. when asking for “rostopic echo /counter” the message “topic [/counter] does not appear to be published yet” appears. knowing that I have seen the echo(s) and its information of the previous unit of the same one(counter)>

Hi @shahad78 ,

Did you start publishing into /counter topic?
If you have already done publisher example, try running the publisher example in one webshell and then do rostopic echo in another webshell.

Try this and let me know if it worked for you!


thank you @girishkumar.kannan,

that has worked. one thing is that whenever I try to launch the topic subscriber launch file, this message appears: “ERROR: cannot launch node of type [topic_subscriber_pkg/simple_topic_subscriber]: Cannot locate node of type [simple_topic_subscriber] in package [topic_subscriber_pkg]. Make sure file exists in package path and permission is set to executable (chmod +x)”!
my launch file code is:

can you guide me through solving this error?

My Package launch file -->
node pkg="topic_subscriber_pkg" type="simple_topic_subscriber" name="topic_subscriber"  output="screen">

Hi @shahad78 ,

That is, I believe, a simple problem. You just have to do
chmod +x simple_topic_subscriber.py
chmod 755 simple_topic_subscriber.py

The above will not work. Just realized you are using C++.


@shahad78 ,

Add this line to CMakeLists.txt under ## Declare a C++ executable line
add_executable(simple_topic_subscriber src/simple_topic_subscriber.cpp)

That should remove the following error


this line is already added in the CMakeLists.txt:
“add_executable(simple_topic_subscriber src/simple_topic_subscriber.cpp)
add_dependencies(simple_topic_subscriber ${simple_topic_subscriber_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

Could you share your launch file contents as-is within a code block?

assuming that your CMakeLists.txt file is correct, please confirm that you are following these four steps in the exact same sequence:

1.- Move inside the catkin_ws directory:
cd ~/catkin_ws

2.- Build your workspace`:


3.- Source your workspace:
source devel/setup.bash

4.- Now execute the launch command (or you can also use rosrun).

If you miss any of the steps above ROS might not find the file it is looking for.