-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython code
More file actions
34 lines (21 loc) · 1.04 KB
/
Python code
File metadata and controls
34 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import time
import argparse
from flyt_python import api as sp
drone = sp.navigation(timeout=110000) ##instance class
parser = argparse.ArgumentParser(description='Process a float value.')## parsing command line arguments while typing file address we can enter the side length in command line
parser.add_argument('side', metavar='side_length', type=float, help='side length of the square')
arguments = parser.parse_args()
time.sleep(5) ## sleep time of drone to initialize properly
side = arguments.side ## declaring variable for taking the argument
print ("taking off!")
drone.take_off(5.0) ## drone takes offs till 5m
print ("flying in square", side)
drone.position_set(side, 0, 0, relative=True)## sending position value from the command line for square lining
drone.position_set(0, side, 0, relative=True)
drone.position_set(-side, 0, 0, relative=True)
drone.position_set(0, -side, 0, relative=True)
print ("landing")
drone.land(False)
print ("Landed safely!")
drone.disconnect() ##disconnecting and shutting down the drone