How does it takeoff/land?

Respected and Dear Prof,
In Unit 5: Actions, there’s one exercise where the drone has to takeoff, move around, and then land.

    The following codes are given in the solution part of it:

#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

How does it takeoff here. We don’t give any value here. takeoff_msg is empty and doesn’t return anything. This code apparantly looks like “doing nothing for 3 seconds” to me.

Similarly in case of landing:
#We land the drone during the first 3 seconds
i=0
while not i == 3:
move_msg.linear.x = 0
move_msg.angular.z = 0
move.publish(move_msg)
land.publish(land_msg)
rospy.loginfo(‘Landing…’)
time.sleep(1)
i += 1

The confusion is same here. There’s no input to the move.publish except Empty, then why did the drone land ?

Also, in plane motion, we define x and z and the drone moves accordingly. In takeoff/landing, how do we define the space coordinates, and how does the drone know whether to move up or down?

Hello @abdulbasitisdost,

The /takeoff and /land topics are used to send a signal to take off or land to the drone. These topics are triggered by sending an Empty message to them, as you can see with:

rostopic info /takeoff

Therefore, if you send an Empty message to the /takeoff topic, for instance, the drone will take off.

Best,

2 Likes