BoSLOO/satsim/satsim.py

67 lines
1.7 KiB
Python
Raw Normal View History

2021-04-22 21:51:49 +00:00
import numpy as np
from sensor_module import gamma_sensor
from time import sleep
2021-04-22 23:45:15 +00:00
from astropy.coordinates import SkyCoord as sc
2021-05-01 13:36:26 +00:00
from os import system
#debugg to rebuild the file every test
system('cp command_q test_q')
ONSAT_FILESTORE = "DATA"
DOWNLINK_FILESTORE = "../store/data"
2021-04-22 21:51:49 +00:00
class sat:
2021-04-22 21:51:49 +00:00
def __init__(self):
2021-05-01 13:36:26 +00:00
self.location = self.get_loc()
2021-04-22 21:51:49 +00:00
self.attitude = sc(0,0, unit='deg', frame='icrs')
self.battery = 100.00
2021-04-22 23:45:15 +00:00
self.MTE = 0
self.kill = False
2021-05-01 13:36:26 +00:00
self.maneuver_q = []
self.maneuver_TTC = 0 #time to completion
self.gyro_saturation = 0
self.modules = [gamma_sensor(),gamma_sensor()]
2021-04-22 21:51:49 +00:00
2021-05-01 13:36:26 +00:00
def get_loc(self):
"""
retrieve location from orbit sim
"""
return (10,10,10)
2021-04-22 23:45:15 +00:00
2021-05-01 13:36:26 +00:00
def get_status(self, command="null"):
status_string = ""
2021-04-22 21:51:49 +00:00
2021-04-22 23:45:15 +00:00
def check_command_q(self):
cur_batch = []
with open("test_q","r") as q:
com_q = q.read().splitlines()
for com in com_q:
2021-04-22 23:45:15 +00:00
if int(com.split(":")[0]) == self.MTE:
cur_batch.append(com)
return cur_batch
def spin(self):
while True:
for m in self.modules:
m.mod_update()
print(m.mod_get("detections"))
if self.MTE % 10 == 0:
m.mod_set("flush", 1)
batch = self.check_command_q()
print("MTE:", self.MTE)
print("COMS:", batch)
if self.MTE == 5:
self.kill = False
if self.kill:
print("heading to bed")
return
self.MTE += 1
sleep(1)
2021-04-22 23:45:15 +00:00
if __name__ == "__main__":
BoSLOO = sat()
BoSLOO.spin()
2021-04-22 21:51:49 +00:00