Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
crnicholson committed Dec 1, 2024
1 parent be59fbb commit be44912
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
1 change: 1 addition & 0 deletions Code/groundStation/uploader/data/KC1SFR.csv
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Code/groundStation/uploader/data/KC1SFR_to_glider.csv
Original file line number Diff line number Diff line change
@@ -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
42 changes: 26 additions & 16 deletions Code/groundStation/uploader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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"
)
Expand All @@ -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,
Expand All @@ -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.")
Expand Down
2 changes: 2 additions & 0 deletions Code/groundStation/uploader/stations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit be44912

Please sign in to comment.