77from mavsdk .follow_me import (Config , FollowMeError , TargetLocation )
88
99default_height = 8.0 #in Meters
10- follow_distance = 2.0 #in Meters, this is the distance that the drone will remain away from Target while following it
11- #Direction relative to the Target
10+ follow_distance = 2.0 #in Meters, this is the distance that the drone will remain away from Target while following it
11+ #Direction relative to the Target
1212#Options are NONE, FRONT, FRONT_LEFT, FRONT_RIGHT, BEHIND
1313direction = Config .FollowDirection .BEHIND
1414responsiveness = 0.02
1919async def fly_drone ():
2020 drone = System ()
2121 await drone .connect (system_address = "udp://:14540" )
22-
22+
2323 #This waits till a mavlink based drone is connected
2424 async for state in drone .core .connection_state ():
2525 if state .is_connected :
26- print (f"-- Connected to drone with UUID: { state . uuid } " )
26+ print (f"-- Connected to drone! " )
2727 break
28-
28+
2929 #Checking if Global Position Estimate is ok
3030 async for global_lock in drone .telemetry .health ():
3131 if global_lock .is_global_position_ok :
3232 print ("-- Global position state is good enough for flying." )
3333 break
34-
34+
3535 #Arming the drone
3636 print ("-- Arming" )
3737 await drone .action .arm ()
38-
38+
3939 #Follow me Mode requires some configuration to be done before starting the mode
4040 conf = Config (default_height , follow_distance , direction , responsiveness )
4141 await drone .follow_me .set_config (conf )
42-
42+
4343 print ("-- Taking Off" )
4444 await drone .action .takeoff ()
4545 await asyncio .sleep (8 )
@@ -54,12 +54,12 @@ async def fly_drone():
5454 print ("-- Following Target" )
5555 await drone .follow_me .set_target_location (target )
5656 await asyncio .sleep (2 )
57-
57+
5858 #Stopping the follow me mode
5959 print ("-- Stopping Follow Me Mode" )
6060 await drone .follow_me .stop ()
6161 await asyncio .sleep (5 )
62-
62+
6363 print ("-- Landing" )
6464 await drone .action .land ()
6565
0 commit comments