Ask Your Question
0

rospy.exceptions.ROSInitException - time is not initialized.

asked 2018-02-18 23:40:18 -0600

updated 2018-02-19 00:06:15 -0600

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.

edit retag flag offensive close merge delete

Comments

I tried changing the rospy.init() position as in other solutions ( which is kinda naive )

that depends. Can you show what the order of statements is that you have now?

gvdhoorn gravatar imagegvdhoorn ( 2018-02-19 01:34:29 -0600 )edit

@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

arunavanag gravatar imagearunavanag ( 2018-02-19 02:00:14 -0600 )edit

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.

arunavanag gravatar imagearunavanag ( 2018-02-19 02:02:49 -0600 )edit

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?

arunavanag gravatar imagearunavanag ( 2018-02-19 02:06:41 -0600 )edit

Do I need to take down this question?

arunavanag gravatar imagearunavanag ( 2018-02-19 02:07:13 -0600 )edit

Post your comment about your paths being incorrect as an answer. Then accept that.

As to your Python issues: virtualenv is the key here.

ROS comes with its python

no. ROS uses whatever Python2 is distributed by your system, especially on Ubuntu.

gvdhoorn gravatar imagegvdhoorn ( 2018-02-19 02:10:25 -0600 )edit

When i install this python packages, they get installed in python2.7 or python3.5

You are in complete control of where things get installed, by using the appropriate pip or python scripts/binaries.

There are multiple questions about this on ROS Answers.

gvdhoorn gravatar imagegvdhoorn ( 2018-02-19 02:14:14 -0600 )edit

I have tried using virtualenv. I mostly use pip . Ok I might not be using the right tools, thanks I will have a look.

arunavanag gravatar imagearunavanag ( 2018-02-19 02:16:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-19 02:14:55 -0600

Hi All,

It was an issue with the python path and ros path. None of my ros kinetic packages were working. I tried using gdb to debug my launch files. Also my ros tools like rostopic list and rosnode list were not listing my launched nodes.

I had to remove everything and reinstall ros kinetic.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-02-18 23:40:18 -0600

Seen: 1,330 times

Last updated: Feb 19 '18