Does rospy.init_node need to be called everytime?
I developed two ROS packages and, until very recently, 1-2 days ago, I was calling one script from package A
(that I developed) with rosrun
(without ever calling roscore
or whatever), which uses another package that I developed B
. None of these packages, i.e. A
or B
, call rospy.init_node
. However, today, I tried again to run package A
's with rosrun A the_script
(as usual), and I get the error
line 150, in sync
filters[topics.index(topic)].signalMessage(msg)
File "/opt/ros/melodic/lib/python2.7/dist-packages/message_filters/__init__.py", line 58, in signalMessage
cb(*(msg + args))
File "/opt/ros/melodic/lib/python2.7/dist-packages/message_filters/__init__.py", line 264, in add
now = rospy.Time.now()
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/rostime.py", line 155, in now
return get_rostime()
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/rostime.py", line 190, in get_rostime
raise rospy.exceptions.ROSInitException("time is not initialized. Have you called init_node()?")
rospy.exceptions.ROSInitException: time is not initialized. Have you called init_node()?
I am using signalMessage
to synchronize a .bag
file and the problem is caused by this, given that the error is raised at line filters[topics.index(topic)].signalMessage(msg)
.
But, as I said above, I never called init_node
before and I never got this error and now I am getting it, for some reason. Why? How do I solve this problem? I didn't update ROS (as far as I know), but I only executed the latest software updates in Ubuntu. In fact, cat /var/log/dpkg.log | grep "\ install\ "
does not apparently produce any ROS-related package. By the way, I already tried to do catkin build
, but I still get the error.
Well, I added rospy.init_node('bag_synchronizer', anonymous=True, disable_signals=True)
to the class that uses signalMessage
, then I roscore
and executed the script again, and now I don't have the error anymore, but I would like to know why I was able to execute that script without rospy.init_node
before (I did this so many times) and now I can't do it anymore. My code does not see to publish or read topics, so I don't need to initialised the node, as far I understand.