From be4491249feeceb5622695a5481b8ea32829af25 Mon Sep 17 00:00:00 2001 From: Charles Nicholson <83499056+crnicholson@users.noreply.github.com> Date: Sat, 30 Nov 2024 23:25:05 -0500 Subject: [PATCH] Commit --- Code/groundStation/uploader/data/KC1SFR.csv | 1 + .../uploader/data/KC1SFR_to_glider.csv | 5 +++ Code/groundStation/uploader/main.py | 42 ++++++++++++------- Code/groundStation/uploader/stations.csv | 2 + 4 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 Code/groundStation/uploader/data/KC1SFR_to_glider.csv diff --git a/Code/groundStation/uploader/data/KC1SFR.csv b/Code/groundStation/uploader/data/KC1SFR.csv index 319de63..d61a519 100644 --- a/Code/groundStation/uploader/data/KC1SFR.csv +++ b/Code/groundStation/uploader/data/KC1SFR.csv @@ -1,3 +1,4 @@ Lat,Lon,Alt,Target lat,Target lon,Yaw,Pitch,Roll,Time,Temperature,Pressure,Humidity,Voltage,Received abort,TX count,RX count,RSSI,SNR,Uploader lat,Uploader lon,Uploader alt,ID 42.306705,-71.336548,1500.5,42.307,-71.335,45.0,2.5,0.0,2024-11-30T14:45:12Z,23.4,1013.25,55.3,3.7,False,102,95,-70,12.5,42.3601,-71.0589,20.0,1234 42.306705,-71.336548,1500.5,42.307,-71.335,45.0,2.5,0.0,2024-11-30T14:45:13Z,23.4,1013.25,55.3,3.7,False,102,95,-70,12.5,42.3601,-71.0589,20.0,1234 +42.306705,-71.336548,1500.5,42.307,-71.335,45.0,2.5,0.0,2024-12-01T03:14:13Z,23.4,1013.25,55.3,3.7,False,102,95,-70,12.5,42.3601,-71.0589,20.0,1234 diff --git a/Code/groundStation/uploader/data/KC1SFR_to_glider.csv b/Code/groundStation/uploader/data/KC1SFR_to_glider.csv new file mode 100644 index 0000000..328fb98 --- /dev/null +++ b/Code/groundStation/uploader/data/KC1SFR_to_glider.csv @@ -0,0 +1,5 @@ +tLat,tLon,abort +42.307,-71.335,0.0 +42.307,-71.335,1.0 +42.307,-71.335,0.0 +42.307,-71.335,1.0 diff --git a/Code/groundStation/uploader/main.py b/Code/groundStation/uploader/main.py index e946c99..f4db66c 100644 --- a/Code/groundStation/uploader/main.py +++ b/Code/groundStation/uploader/main.py @@ -69,6 +69,8 @@ async def handle_connection(websocket): microsecond=0, ) utc_time_str = utc_time.strftime("%Y-%m-%dT%H:%M:%SZ") + + print(f"\nReceived data from {call_sign} at {utc_time_str}") df = pd.DataFrame() @@ -138,7 +140,7 @@ async def handle_connection(websocket): "ID": id, } - print(f"\nLat: {lat}, lon: {lon}, alt: {alt}, target lat: {t_lat}, target lon: {t_lon}, yaw: {yaw}, pitch: {pitch}, roll: {roll}, time: {utc_time_str}, temp: {temp}, pressure: {pressure}, humidity: {humidity}, volts: {volts}, received abort: {received_abort}, tx count: {tx_count}, rx count: {rx_count}, rssi: {rssi}, snr: {snr}, uploader lat: {u_lat}, uploader lon: {u_lon}, uploader alt: {u_alt}, id: {id}") + print(f"Lat: {lat}, lon: {lon}, alt: {alt}, target lat: {t_lat}, target lon: {t_lon}, yaw: {yaw}, pitch: {pitch}, roll: {roll}, time: {utc_time_str}, temp: {temp}, pressure: {pressure}, humidity: {humidity}, volts: {volts}, received abort: {received_abort}, tx count: {tx_count}, rx count: {rx_count}, rssi: {rssi}, snr: {snr}, uploader lat: {u_lat}, uploader lon: {u_lon}, uploader alt: {u_alt}, id: {id}") df = pd.DataFrame([data]) @@ -224,24 +226,25 @@ async def handle_connection(websocket): def input_thread(): while True: try: - print("Avialable call signs:") - print([file.replace(".csv", "") for file in os.listdir(f"{os.getcwd()}/data")]) + print("\nAvialable call signs:") + print([file.replace(".csv", "") for file in os.listdir(f"{os.getcwd()}/data") if "glider" not in file]) s_call_sign = input("Enter the call sign you would like to change:\n") if s_call_sign + ".csv" in os.listdir(f"{cwd}/data"): df = pd.read_csv(f"{cwd}/data/{s_call_sign}.csv") - print(f"Lat: {df.loc[-1, 'Lat']}, lon: {df.loc[-1, 'Lon']}, alt: {df.loc[-1, 'Alt']}, last received at {df.loc[-1, 'Time']}, voltage: {df.loc[-1, 'Voltage']}") - print(f"Abort status: {df.loc[-1, "Abort"]}") - print(f"Target latitude: {df.loc[-1, "Target lat"]}") - print(f"Target longitude: {df.loc[-1, "Target lon"]}") + print(f"\nData for {s_call_sign}:") + print(f"Lat: {df.iloc[-1]['Lat']}, lon: {df.iloc[-1]['Lon']}, alt: {df.iloc[-1]['Alt']}, last received at {df.iloc[-1]['Time']}, voltage: {df.iloc[-1]['Voltage']}") + print(f"Abort status: {df.iloc[-1]["Received abort"]}") + print(f"Target latitude: {df.iloc[-1]["Target lat"]}") + print(f"Target longitude: {df.iloc[-1]["Target lon"]}") new_t_lat = float( - input("Enter the new target latitude. Enter 0 to do nothing:\n") + input("\nEnter the new target latitude. Enter 0 to do nothing:\n") ) new_t_lon = float( input("Enter the new target longitude. Enter 0 to do nothing:\n") ) - abort = bool( + abort = int( input( "Enter 1 to abort the mission or 0 to do nothing or revert your change:\n" ) @@ -252,18 +255,25 @@ def input_thread(): if new_t_lon == 0: new_t_lon = df.iloc[-1]["Target lon"] - if abort != 0 or 1: + if abort != 0 and abort != 1: print(f"Abort changed to {abort}, which is not 0 or 1.") abort = input("Please enter 0 (do nothing) or 1 (abort mission):\n") - if abort != 0 or 1: + if abort != 0 and abort != 1: print("Abort status still invalid. Resorting to orginal value.") - abort = df.iloc[-1]["Abort"] + abort = df.iloc[-1]["Received abort"] if os.path.exists(f"{cwd}/data/{s_call_sign}_to_glider.csv"): df = pd.read_csv(f"{cwd}/data/{s_call_sign}_to_glider.csv") - df.iloc[-1]["tLat"] = new_t_lat - df.iloc[-1]["tLon"] = new_t_lon - df.iloc[-1]["abort"] = abort + + data = { + "tLat": new_t_lat, + "tLon": new_t_lon, + "abort": abort, + } + + df = df._append(data, ignore_index=True) + + df.to_csv(f"{cwd}/data/{s_call_sign}_to_glider.csv", index=False) else: data = { "tLat": new_t_lat, @@ -282,7 +292,7 @@ def input_thread(): ) print( - f"Data for {s_call_sign} has been changed to coordinates {new_t_lat, new_t_lon} with abort status of {abort}. Sending to ground station shortly." + f"\nData for {s_call_sign} has been changed to coordinates {new_t_lat, new_t_lon} with abort status of {abort}. Sending to ground station shortly." ) else: print(f"{s_call_sign} not found in data directory.") diff --git a/Code/groundStation/uploader/stations.csv b/Code/groundStation/uploader/stations.csv index 9a87f85..cdbf346 100644 --- a/Code/groundStation/uploader/stations.csv +++ b/Code/groundStation/uploader/stations.csv @@ -4,3 +4,5 @@ ID,Time,Call sign,SNR,RSSI 1234,2024-11-30T14:45:12Z,KC1SFR,12.5,-70 1234,2024-11-30T14:45:12Z,KC1SFR,12.5,-70 1234,2024-11-30T14:45:13Z,KC1SFR,12.5,-70 +1234,2024-11-30T14:45:13Z,KC1SFR,12.5,-70 +1234,2024-12-01T03:14:13Z,KC1SFR,12.5,-70