34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
#!/usr/bin/python3
|
|
import logging
|
|
import time
|
|
import datetime
|
|
import sys, select
|
|
|
|
from dronekit_server_client import DroneKitComms
|
|
|
|
# class DroneKitComms:
|
|
# def __init__(self) -> None:
|
|
# pass
|
|
# def get_gps(self):
|
|
# return (11.2, 33.2)
|
|
|
|
if __name__ == "__main__":
|
|
FORKLIFT = DroneKitComms()
|
|
gps_file = open(f"gps_log__{datetime.datetime.now().strftime('%H.%M.%S')}.txt", "w+")
|
|
while True:
|
|
time.sleep(0.5)
|
|
current_gps_coords = FORKLIFT.get_gps()
|
|
print(f"Current coords: {current_gps_coords} | s for save and q to exit")
|
|
i, o, e = select.select( [sys.stdin], [], [], 1 )
|
|
if i:
|
|
in_text = sys.stdin.readline().strip()
|
|
print(f"input: {in_text}")
|
|
if in_text in ['s', 'S']:
|
|
print(f"Saving {current_gps_coords}")
|
|
gps_file.writelines([f'{datetime.datetime.now().strftime("%H:%M:%S")} | {{"lat": {current_gps_coords[0]}, "lon": {current_gps_coords[1]}}},\n'])
|
|
elif in_text in ['q', 'Q']:
|
|
print("Quitting...")
|
|
gps_file.close()
|
|
exit(0)
|
|
i = o = e = None
|