0
$\begingroup$

Rosanswers logo

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.


Originally posted by arunavanag on ROS Answers with karma: 277 on 2018-02-19

Post score: 1


Original comments

Comment by gvdhoorn on 2018-02-19:\

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?

Comment by arunavanag on 2018-02-19:
@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

Comment by arunavanag on 2018-02-19:
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.

Comment by arunavanag on 2018-02-19:
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?

Comment by arunavanag on 2018-02-19:
Do I need to take down this question?

Comment by gvdhoorn on 2018-02-19:
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.

Comment by gvdhoorn on 2018-02-19:\

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.

Comment by arunavanag on 2018-02-19:
I have tried using virtualenv. I mostly use pip . Ok I might not be using the right tools, thanks I will have a look.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by arunavanag with karma: 277 on 2018-02-19

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.