I have a doubt in the code from “multiple_broadcatser.py” from the chapter "Publish & Subscribe to TF data"
code snippet :
def publisher_of_tf(): rospy.init_node('publisher_of_tf_node', anonymous=True) robot_name_list = ["turtle1","turtle2"] gazebo_model_object = GazeboModel(robot_name_list) for robot_name in robot_name_list: pose_now = gazebo_model_object.get_model_pose(robot_name) # Leave enough time to be sure the Gazebo Model logs have finished time.sleep(1) rospy.loginfo("Ready..Starting to Publish TF data now...") rate = rospy.Rate(5) # 5hz while not rospy.is_shutdown(): for robot_name in robot_name_list: pose_now = gazebo_model_object.get_model_pose(robot_name) if not pose_now: print "The " + str(robot_name) + "'s Pose is not yet available...Please try again later" else: handle_turtle_pose(pose_now, robot_name) rate.sleep()
This particular part of the code where pose_now is being generated, is being calculated at two different points in the program, while I understand that the 2nd time (inside the while loop) its being sent to handle_turtle_pose I don’t understand why it is being used before time.sleep(1).
I tried commenting the 1st instance of pose_now and the code worked just fine, so I’m not really sure about its purpose.