rospy.exceptions.ROSInitException - time is not initialized.
Hello,
I was just testing my websocket, for which I was using the basic ros publisher subscriber tutorial. These worked until last week, and I haven't touched this package until today.
error thrown when i run my script:
rosrun my_package talker.py
the error as follows:
rate = rospy.Rate(10) # 10hz
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/timer.py", line 61, in __init__
self.last_time = rospy.rostime.get_rostime()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/rospy/rostime.py", line 190, in get_rostime
raise rospy.exceptions.ROSInitException("time is not initialized. Have you called init_node()?")
rospy.rospy.rospy.exceptions.ROSInitException: time is not initialized. Have you called init_node()?
I tried changing the rospy.init()
position as in other solutions ( which is kinda naive ) and check indentation. Actually, all of my scripts have started throwing errors. I did a catkin clean
and catkin build
as well. Also sometimes apt-get update
and upgrade
breaks; checked those as well. Anyone any pointers, please?
Additionally, after i launched my subscriber node, i dont find the the node name and topic name when I do rosnode list
and rostopic list
.
that depends. Can you show what the order of statements is that you have now?
@gvdhoorn it was not the issue with the order of statement. I had copied the publisher tutorial as it is. I used gdb however it did not help out. I tried running any ros kinetic package, everything failed until i realized my ros path, python path and other source paths have broken. I tried fixing
them from .bashrc and by editing the symlinks. But just had to remove ros-kinetic and reinstall. Things seems to work. ROS comes with its python which is often an issue with ubuntu python. Using other packages like openai, gym, tensorflow, everything gets messed up.
When i install this python packages, they get installed in python2.7 or python3.5 in /usr/local/lib/python.x.x But then when I try to import rospy and then import these external python packages, the paths get messed. Any suggestions on this? Should I create a new question for this?
Do I need to take down this question?
Post your comment about your paths being incorrect as an answer. Then accept that.
As to your Python issues:
virtualenv
is the key here.no. ROS uses whatever Python2 is distributed by your system, especially on Ubuntu.
You are in complete control of where things get installed, by using the appropriate
pip
orpython
scripts/binaries.There are multiple questions about this on ROS Answers.
I have tried using
virtualenv
. I mostly usepip
. Ok I might not be using the right tools, thanks I will have a look.