-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendData.py.save
53 lines (47 loc) · 1.93 KB
/
sendData.py.save
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
49
50
51
52
53
from dronekit import connect, VehicleMode
import threading
import requests
import time
import thread
import json
class SendData:
def send_data(self, vehicle, threadName, delay):
while 1:
loc = vehicle.location.global_frame
vel = vehicle.velocity
status = str(vehicle.system_status)
data = {}
data["firm"] = str(vehicle.version)
data["conn"] = True
data["arm"] = vehicle.armed
data["ekf"] = vehicle.ekf_ok
data["mode"] = vehicle.mode.name
data["lat"] = format(loc.lat,'.15f')
data["long"] = format(loc.lon,'.15f')
data["alt"] = format(loc.alt, '.2f')
data["altr"] = vehicle.location.global_relative_frame.alt
data["head"] = format(vehicle.heading, 'd')
data["lidar"] = vehicle.rangefinder.distance
data["gs"] = format(vehicle.groundspeed, '.3f')
data["roll"] = format(vehicle.attitude.roll, '.2f')
data["pitch"] = format(vehicle.attitude.pitch, '.2f')
data["yaw"] = format(vehicle.attitude.yaw, '.2f')
data["status"] = status[13:]
data["volt"] = format(vehicle.battery.voltage, '.2f')
data["vx"] = vel[0]
data["vy"] = vel[1]
data["vz"] = vel[2]
data["heartbeat"] = vehicle.last_heartbeat
data["numSat"] = vehicle.gps_0.satellites_visible
data["hdop"] = vehicle.gps_0.eph
data["fix"] = vehicle.gps_0.fix_type
print(data)
r = requests.get("https://nicdronestatus.herokuapp.com/data",params=data)
#r = requests.get("http://photooverlay.com/nic/get_data.php",params=data)
#print(r.text)
time.sleep(delay)
def start(self,vehicle):
try:
thread.start_new_thread(self.send_data,(vehicle,"Send Data", 1))
except Exception as e:
/print(e)