Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

while loop only executes subscriber callback()


the key code parts:

def callback(data):
    global value
    value =

def listener():
    #init.node and creating a subscriber for a topic are performed

if __name__ == "__main__":
    while not rospy.is_shutdown():
        print('inside main')

My problem is that the print statement 'inside main' is executed only once and I don't understand why, shouldn't it be looping for as long as the rospy is up and running? However, after rospy.spin() the callback() function is executed constantly, but the print statement is not repeated.