Hello dear community !
I joined here just recently. I searched for topics similar to mine but it didn’t solve my issue.
In the ROS Basics (5 days) course, in example 3.1, I run the following command as told:
rosrun my_examples_pkg simple_topic_publisher.py
This gives the following output:
/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py:842:UserWarning: ’ /counter’ is not a legal ROS graph resource name. This may cause problems with other ROS tools
super(Publisher, self).init(name, data_class, Registration.PUB)
[FATAL] [1647509354.474772, 0.000000]: unable to register publication [/ /counter] with master: ERROR: parameter [topic] contains illegal chars
And also, to see if i have created a topic, i run (in second webshell) :
rostopic list | grep ‘/counter’
But output shows blank. As per the tutorial text, output SHOULD BE :
user ~ $ rostopic list | grep ‘/counter’
/counter
Where am I doing wrong?
simple_topic_publisher.py contains the following code:
#! /usr/bin/env python
import rospy
from std_msgs.msg import Int32
rospy.init_node(‘topic_publisher’)
pub = rospy.Publisher(’ /counter’, Int32, queue_size=1)
rate = rospy.Rate(2)
count = Int32()
count.data = 0
while not rospy.is_shutdown():
pub.publish(count)
count.data += 1
rate.sleep()