I tried searching for this issue in the forum but couldn’t find anything similar. I tried to execute example 3.1, after compiling and sourcing the workspace I used the command rosrun:
rosrun my_examples_pkg simple_topic_publisher.py
Nothing happens, as you can see from the screenshot:
The code that you have prints the output in a ROS topic called “/counter”. Thus you are unable to see the messages on your screen.
You can see the messages on your screen only if you have any print statement on your code. Currently, your code does not have any print statements. Thus you are unable to see any output on your screen.
I have finished this exercise. So trust me, it is correct.
So, If you want to see the output, do the following:
Execute rosrun my_examples_pkg simple_topic_publisher.py on web terminal 1.
Once started, switch to terminal 2 and execute rostopic echo /counter
Now, you will be able to see the output that this program prints onto ROS topic /counter.
Once you execute a command line after user:~/catkin_ws$, you should not execute another new commandline right under it.
That is why the command rostopic list | grep /counter did not work.
Which brings me to this very important advise:
If you have not understood the basic functionality of a terminal / command prompt in Linux machine, you must definitely take the Linux for Robotics (FREE course) on this website. This is very important before you can proceed further with your current course or any other course on this website.