I was going the Exercise Solution 7.6 (Understanding ROS Actions - Clients) and stumbled upon this snippet :
#We takeoff the drone during the first 3 seconds
i=0
while not i == 3:
takeoff.publish(takeoff_msg)
rospy.loginfo('Taking off...')
time.sleep(1)
i += 1
I understand that the takeoff_msg is being published multiple times, is this because of the fact that the 1st message published into a topic may fail (because the topic connections are not ready yet) ?
If yes,
- can we use latched messages instead of publishing the same message multiple times ?
or - check if the number of connections are greater than 0 and then publish the message ?
TIA