ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This Node1 class has a call_back function that only prints "entering callback" in the terminal and that's all.
def object_callback(self, msg):
print ("entering callback")
for obj in msg.objects:
if self.obj_in_path(obj):
print("Found object in path: \n{}".format(obj))
self.send_brake_message()
else:
self.normal_driving()
break
the for loop is not part of the callback, since it has the same size of indentation as the callback function (it is at the same level). There for the for loop will execute at the initiation of the class instance (when you first start the node) and never again.
There is no deadlock. The second node doesn't react, because it is not running. There is no piece of a code that would launch allow to run Node2.
I suggest you should try to build your node following the official tutorials: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29
2 | No.2 Revision |
This Node1 class has a call_back function that only prints "entering callback" in the terminal and that's all.
def object_callback(self, msg):
print ("entering callback")
for obj in msg.objects:
if self.obj_in_path(obj):
print("Found object in path: \n{}".format(obj))
self.send_brake_message()
else:
self.normal_driving()
break
the for loop for-loop is not part of the callback, since it has the same size of indentation as the callback function (it is at the same level). There for Therefor the for loop for-loop will execute at the initiation of the class instance (when you first start the node) and never again.
There is no deadlock. The second node doesn't react, because it is not running. There is no piece of a code that would launch allow to run Node2.
I suggest you should try to build your node nodes while following the official tutorials: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29