-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (38 loc) · 1.32 KB
/
main.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from dronekit import connect
import time
# diffrent modes:
# 5: Loiter
# 6: RTL
# 7: Circle
# 9: Land
# Connect to the Vehicle (in this case a UDP endpoint)
vehicle = connect('/dev/ttyUSB0', wait_ready=True, baud=57600)
#call for vehicle mode
@vehicle.on_attribute('mode')
def mode_callback(self,attr,msg):
print("Mode Callback: ",msg)
@vehicle.on_attribute('battery')
def mode_callback(self,attr,msg):
print("Battery Callback: ",msg)
try:
while True:
# vehicle.mode
# getting system status
# action = input("1:Change Mode \n 2:Incomming")
# if(int(action) == 1):
# action = input("change Mode to: \n 0: stabilize 5: Loiter")
# vehicle.mode = int(action)
# print("System: ".format(vehicle.system_status))
# # getting mode
# print("Mode: {0}".format(vehicle.mode.name))
# # getting the attitude
# print("vehicle attitude: {0}".format(vehicle.attitude))
# getting the battery
print("home location: {0}".format(vehicle.location.local_frame))
vehicle.
# print("hello".format(vehicle._voltage))
# vehicle.add_attribute_listener('mode',mode_callback)
time.sleep(4)
except KeyboardInterrupt:
print("exited the program")
vehicle.close()