Ask Your Question

Revision history [back]

"I use rospy.wait_for_message(topic, data type) to wait for a message published by other node. The first program will wait for the "forward" message from the second program in order to restart the program to check the distance again." So here is the discrepancy. You are waiting for a message on the topic "forward", rather than waiting for the message "forward". Also, from your second program I can see that you are publishing on "move" topic a value of the type Int16 (assuming you have included the std_msgs library in your program) but later in the code, you are giving a String argument to move.publish. This will not work. Solution:

  1. Change:

    self.move = rospy.Publisher("move", Int16, queue_size=10)


self.move = rospy.Publisher("move", std_msgs.msg.String, queue_size=10)


rospy.wait_for_message("forward", String)


rospy.wait_for_message("move", String)