ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
753 stars 911 forks source link

rospy.core.is_initialized() is False after rospy.init_node() #2334

Open kosei1515 opened 1 year ago

kosei1515 commented 1 year ago

I found that after rospy.init_node(), rospy.core.is_initialized() still returns False. However, in the function rospy.init_node, there is the process of rospy.core.set_initialized(True) here I'm not sure why this problem is happening. Please use the following test code to check this error.

from mock import patch
from nose.tools import eq_
import rospy

@patch('rospy.init_node')
def test_rospy_core_is_initialized(init_mock):
    """Test rospy.core.is_initialized()"""    
    eq_(rospy.core.is_initialized(), False)    
    rospy.init_node("test_node")
    eq_(rospy.core.is_initialized(), True)