0
$\begingroup$

I had a problem with initializing a ROS node in python in a larger project. The following minimum reproducible example has the same issue:

#!/usr/bin/env python

import rospy

if __name__ == '__main__':
    print("Init node")
    rospy.init_node('testNode', anonymous=True)
    print("Node initialized")

Only the "Init node" is printed, and the script freezes in the rospy.init_node() call.

roscore is already running, confirmed by rostopic list returning the /rosout topic.

I have tried reinstalling ros and all python packages, as well as rebuilding the ros project.

When debugging using pdb, the program is stuck in the following loop:

while hasattr(f, "f_code"):

    co = f.f_code
    filename = os.path.normcase(co.co_filename)
    if filename == file_name and f.f_lineno == lineno and co.co_name == func_name:
    if f.f_back:
    f = f.f_back

in the following path: */opt/ros/noetic/lib/python3/dist-packages/rosgraph/roslogging.py(64)findCaller() *

Any help would be greatly appreciated!

EDIT:

It is also not possible to ctrl + c to stop the process, and I have to close the terminal for it to stop.

If I comment out the call to logger.info("init_node, name[%s], pid[%s]", resolved_node_name, os.getpid()) which leads to the infinite loop as shown above, the program instead gets stuck in the following loop:

while not node.uri and not is_shutdown():
    time.sleep(0.00001) #poll for XMLRPC init

in /opt/ros/noetic/lib/python3/dist-packages/rospy/impl/init.py(105)start_node()

$\endgroup$
1
  • 1
    $\begingroup$ This is a highly used part of the system by a lot of users. Based on where you're having issues are you on a non-standard system? What method have you used to install your system? What is your larger system? And what else has your larger system changed about your deployment from a standard system. There has to be something different on your system than the systems on which this has been running for the last 5 years or so since this code was last changed. Please edit your question to add this additional information. $\endgroup$
    – Tully
    Feb 12 at 22:05

1 Answer 1

0
$\begingroup$

Fixed by running

sudo apt-get remove ros-* 

then reinstalling using http://wiki.ros.org/noetic/Installation/Ubuntu, and creating a new conda environment. Not sure what actually caused the issue.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.