From 0d9090ddb5502acbd7b6274a1168e0084f51f17f Mon Sep 17 00:00:00 2001 From: Thomas McFarland Date: Sat, 4 Mar 2023 13:57:41 -0500 Subject: [PATCH 1/2] Redid all imports in every flight software file - Almost all files will show an edit, as basically every file was changed - VSCode decided to reformat in potentially damaging ways (redoing order of imports) so there may need to be a review on that change - Imports in general need a redo. There was a mix of relative and absolute, and while its somewhat fixed now the hack in main needs to be replaced --- .env.example | 5 -- HITL-tests/comms_driver_test.py | 4 +- HITL-tests/comms_hardware_receive.py | 6 +-- HITL-tests/comms_hardware_transmit.py | 14 +++--- HITL-tests/comms_security_test.py | 26 +++++------ HITL-tests/file_transmitter.py | 40 ++++++++-------- HITL-tests/flight_unit_downlink.py | 46 +++++++++---------- HITL-tests/flight_unit_receive.py | 14 +++--- HITL-tests/gom_console.py | 4 +- HITL-tests/gyro_bias_check.py | 2 +- HITL-tests/hitl_groundstation_rx.py | 4 +- HITL-tests/hitl_groundstation_tx.py | 10 ++-- HITL-tests/signal_test_satellite.py | 8 ++-- __init__.py | 1 + .../ax5043_manager/ax5043_manager.py | 2 +- communications/ax5043_manager/main_rx.py | 7 +-- communications/ax5043_manager/main_tx.py | 7 +-- .../ax5043_manager/mock_ax5043_driver.py | 5 +- .../ax5043_manager/test_ax5043_driver.py | 4 +- .../ax5043_manager/test_ax5043_manager.py | 6 +-- communications/codec.py | 2 +- communications/codecs.py | 4 +- communications/command_definitions.py | 20 ++++---- communications/command_handler.py | 20 ++++---- communications/command_queue_writer.py | 2 +- communications/commands.py | 10 ++-- communications/groundstation.py | 4 +- communications/satellite_radio.py | 8 ++-- drivers/adc.py | 4 +- drivers/device.py | 2 +- drivers/devices.py | 6 +-- drivers/gom.py | 8 ++-- drivers/imu.py | 6 +-- drivers/power/display_test.py | 2 +- drivers/power/loadswitch.py | 4 +- drivers/power/power_controller.py | 8 ++-- drivers/rtc.py | 2 +- flight_modes/attitude_adjustment.py | 6 +-- flight_modes/flight_mode.py | 6 +-- flight_modes/flight_mode_factory.py | 14 +++--- flight_modes/low_battery.py | 6 +-- flight_modes/maneuver_flightmode.py | 8 ++-- flight_modes/opnav_flightmode.py | 6 +-- flight_modes/restart_reboot.py | 8 ++-- main.py | 37 ++++++++------- opnav/core/attitude.py | 4 +- opnav/core/cam_meas.py | 4 +- opnav/core/observe_functions.py | 6 +-- opnav/core/opnav.py | 24 +++++----- opnav/core/sense.py | 2 +- opnav/core/ukf.py | 4 +- .../experiments/camera_initialization_test.py | 2 +- opnav/experiments/extract_frames_test.py | 12 ++--- opnav/experiments/extract_frames_test_v2.py | 10 ++-- opnav/experiments/findHyperParams.py | 13 ++++-- opnav/simulations/attitudeSim.py | 8 ++-- opnav/simulations/createCZML.py | 4 +- opnav/simulations/detectCesiumObjects.py | 4 +- opnav/simulations/getManeuvers.py | 2 +- opnav/simulations/sim.py | 6 +-- opnav/tests/ang_size_testing.py | 2 +- opnav/tests/const.py | 2 +- opnav/tests/gen_opnav_data.py | 12 ++--- opnav/tests/test_body_meas.py | 12 ++--- opnav/tests/test_center_finding.py | 8 ++-- opnav/tests/test_detections.py | 4 +- opnav/tests/test_end_to_end.py | 8 ++-- opnav/tests/test_pipeline.py | 12 ++--- opnav/tests/test_reprojections.py | 8 ++-- opnav/tests/test_sixhours.py | 24 +++++----- opnav/tests/test_ukf.py | 16 +++---- opnav/tests/test_ukf_functions.py | 6 +-- telemetry/dummy_sensors.py | 4 +- telemetry/telemetry.py | 10 ++-- tests/bitflip_test.py | 6 +-- tests/codec_test.py | 2 +- tests/command_test.py | 8 ++-- tests/commands_def_test.py | 4 +- tests/comms_test.py | 2 +- tests/db_test.py | 4 +- tests/device_container_test.py | 2 +- tests/env_test.py | 2 +- tests/gom_config_test.py | 10 ++-- tests/main_test.py | 10 ++-- tests/maneuver_test.py | 12 ++--- tests/parameters_test.py | 2 +- utils/cqc.py | 2 +- utils/db.py | 2 +- utils/db_functions.py | 10 ++-- utils/gom_util.py | 4 +- utils/parameter_utils.py | 6 +-- 91 files changed, 374 insertions(+), 365 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index fba3f580..00000000 --- a/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -CISLUNAR_BASE_DIR=cislunar_data -SURRENDER_LOCAL_DIR=outside_repo -FOR_FLIGHT=0 -LOG=1 -TEST=1 diff --git a/HITL-tests/comms_driver_test.py b/HITL-tests/comms_driver_test.py index 4d2c9497..10fc1dc6 100644 --- a/HITL-tests/comms_driver_test.py +++ b/HITL-tests/comms_driver_test.py @@ -1,5 +1,5 @@ -from communications.satellite_radio import Radio -from communications.command_handler import CommandHandler +from fsw.communications.satellite_radio import Radio +from fsw.communications.command_handler import CommandHandler import time # Setup diff --git a/HITL-tests/comms_hardware_receive.py b/HITL-tests/comms_hardware_receive.py index 5923d8dc..b11c8438 100644 --- a/HITL-tests/comms_hardware_receive.py +++ b/HITL-tests/comms_hardware_receive.py @@ -1,6 +1,6 @@ -from communications.satellite_radio import Radio +from fsw.communications.satellite_radio import Radio -#Initialize variables, nothing to modify on this end +# Initialize variables, nothing to modify on this end transmissionCounter = 0 radio = Radio() @@ -8,4 +8,4 @@ message = radio.receiveSignal() if message is not None: print(f'Transmission #{transmissionCounter} Received: {message}') - transmissionCounter += 1 \ No newline at end of file + transmissionCounter += 1 diff --git a/HITL-tests/comms_hardware_transmit.py b/HITL-tests/comms_hardware_transmit.py index c7a7f53d..e1bf39d3 100644 --- a/HITL-tests/comms_hardware_transmit.py +++ b/HITL-tests/comms_hardware_transmit.py @@ -1,13 +1,13 @@ -from communications .satellite_radio import Radio +from fsw.communications .satellite_radio import Radio import time -#Test constants -radio = Radio() # Do not modify -signal = b'\x08\x07\x00\x00' #Pattern you want to send -interval = 3 # Number of seconds between each transmission -repetitions = 10 # Number of total times you want to transmit the pattern +# Test constants +radio = Radio() # Do not modify +signal = b'\x08\x07\x00\x00' # Pattern you want to send +interval = 3 # Number of seconds between each transmission +repetitions = 10 # Number of total times you want to transmit the pattern for i in range(1, repetitions+1): radio.transmit(signal) print('Transmitted: ' + str(i)) - time.sleep(interval) \ No newline at end of file + time.sleep(interval) diff --git a/HITL-tests/comms_security_test.py b/HITL-tests/comms_security_test.py index fbf6f8d4..8b86d9cb 100644 --- a/HITL-tests/comms_security_test.py +++ b/HITL-tests/comms_security_test.py @@ -1,20 +1,20 @@ -from communications.satellite_radio import Radio -from communications.commands import CommandHandler -from communications.downlink import DownlinkHandler +from fsw.communications.satellite_radio import Radio +from fsw.communications.commands import CommandHandler +from fsw.communications.downlink import DownlinkHandler import time -#Setup +# Setup ch = CommandHandler() groundstation = Radio() -#Invalid counter -#badCounterCommand = ch.pack_command(2,8,7) -#groundstation.transmit(badCounterCommand) +# Invalid counter +# badCounterCommand = ch.pack_command(2,8,7) +# groundstation.transmit(badCounterCommand) -#Invalid MAC -#invalidMAC = ch.pack_command(1,8,7) -#groundstation.transmit(invalidMAC) +# Invalid MAC +# invalidMAC = ch.pack_command(1,8,7) +# groundstation.transmit(invalidMAC) -#Shutdown via command -shutdown = ch.pack_command(1,8,11) -groundstation.transmit(shutdown) \ No newline at end of file +# Shutdown via command +shutdown = ch.pack_command(1, 8, 11) +groundstation.transmit(shutdown) diff --git a/HITL-tests/file_transmitter.py b/HITL-tests/file_transmitter.py index 487c6573..805a38f9 100644 --- a/HITL-tests/file_transmitter.py +++ b/HITL-tests/file_transmitter.py @@ -1,7 +1,7 @@ -from utils.constants import MIN_COMMAND_SIZE, FMEnum, CommandCommandEnum, FLIGHT_SOFTWARE_PATH -from communications.satellite_radio import Radio -from communications.commands import CommandHandler -from communications.downlink import DownlinkHandler +from fsw.utils.constants import MIN_COMMAND_SIZE, FMEnum, CommandCommandEnum, FLIGHT_SOFTWARE_PATH +from fsw.communications.satellite_radio import Radio +from fsw.communications.commands import CommandHandler +from fsw.communications.downlink import DownlinkHandler import hashlib import time @@ -11,17 +11,17 @@ command_counter = 1 transmission_interval = 0 satellite_file_path = 'main.py' -file_path= FLIGHT_SOFTWARE_PATH + 'FlightSoftware/' + satellite_file_path +file_path = FLIGHT_SOFTWARE_PATH + 'FlightSoftware/' + satellite_file_path -#Set file to be updated +# Set file to be updated update_file_name = ch.pack_command(command_counter, FMEnum.Command.value, -CommandCommandEnum.SetUpdatePath.value, file_path=satellite_file_path) + CommandCommandEnum.SetUpdatePath.value, file_path=satellite_file_path) groundstation.transmit(update_file_name) print('File name set') command_counter += 1 -#Get file -#Max transmission size - space alotted for file name - block number - +# Get file +# Max transmission size - space alotted for file name - block number - # min command size - 2*(2 bytes for string length) max_string_size = 195 - MIN_COMMAND_SIZE - 4 file = open(file_path) @@ -30,30 +30,30 @@ checksum = str(hashlib.md5(file_string.encode('utf-8')).hexdigest()) print('File Checksum: ' + checksum) -#Determine number of blocks +# Determine number of blocks number_of_blocks = len(file_string)//max_string_size if len(file_string) % max_string_size != 0: number_of_blocks += 1 for i in range(number_of_blocks): block_text = file_string[i*max_string_size:(i+1)*max_string_size] - file_blocks.append((i,block_text)) + file_blocks.append((i, block_text)) i = 0 -#Transmit blocks +# Transmit blocks for block in file_blocks: - - block_command = ch.pack_command(command_counter, FMEnum.Command.value, - CommandCommandEnum.AddFileBlock.value, - block_number = block[0],block_text = block[1]) + + block_command = ch.pack_command(command_counter, FMEnum.Command.value, + CommandCommandEnum.AddFileBlock.value, + block_number=block[0], block_text=block[1]) groundstation.transmit(block_command) print('Transmitted Block #' + str(block[0])) time.sleep(transmission_interval) - command_counter+= 1 + command_counter += 1 file_info_request = ch.pack_command(command_counter, FMEnum.Command.value, -CommandCommandEnum.GetFileBlocksInfo.value,total_blocks=number_of_blocks) + CommandCommandEnum.GetFileBlocksInfo.value, total_blocks=number_of_blocks) groundstation.transmit(file_info_request) command_counter += 1 print('Receiving...') @@ -67,8 +67,8 @@ if file_info[4]['checksum'] == checksum: activate_file_command = ch.pack_command(command_counter, FMEnum.Command.value, - CommandCommandEnum.ActivateFile.value,total_blocks=number_of_blocks) + CommandCommandEnum.ActivateFile.value, total_blocks=number_of_blocks) groundstation.transmit(activate_file_command) print('File Activated') else: - print('Missing blocks: ' + file_info[4]['missing_blocks']) \ No newline at end of file + print('Missing blocks: ' + file_info[4]['missing_blocks']) diff --git a/HITL-tests/flight_unit_downlink.py b/HITL-tests/flight_unit_downlink.py index 2e8e8d35..673d2934 100644 --- a/HITL-tests/flight_unit_downlink.py +++ b/HITL-tests/flight_unit_downlink.py @@ -1,66 +1,66 @@ -from communications.satellite_radio import Radio -from drivers.gom import Gomspace -import utils.parameters as params +from fsw.communications.satellite_radio import Radio +from fsw.drivers.gom import Gomspace +import fsw.utils.parameters as params from time import sleep radio = Radio() gom = Gomspace() electrolyzing = False -interval = 3 # Number of seconds between each transmission -repetitions = 5 # Number of total times you want to transmit the pattern -downlink = b'\x08\x07\x00\x00' #Message you want to downlink -#––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– +interval = 3 # Number of seconds between each transmission +repetitions = 5 # Number of total times you want to transmit the pattern +downlink = b'\x08\x07\x00\x00' # Message you want to downlink +# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– # Enter Transmit Mode - -#Stop electrolyzing + +# Stop electrolyzing if gom.is_electrolyzing(): electrolyzing = True gom.set_electrolysis(False) print('Electrolyzers turned off') -#Set RF receiving side to low +# Set RF receiving side to low gom.rf_receiving_switch(receive=False) print('RF Receiving set to low') -#Turn off LNA +# Turn off LNA gom.lna(False) print('LNA turned off') -#Set RF transmitting side to high +# Set RF transmitting side to high gom.rf_transmitting_switch(receive=False) print('RF transmitting set to high') -#Turn on power amplifier +# Turn on power amplifier gom.set_pa(on=True) print('Power amplifier turned on') -#––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– -#Downlink +# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– +# Downlink radio.transmit(downlink) for i in range(1, repetitions+1): radio.transmit(downlink) print('Transmitted: ' + str(i)) sleep(interval) -#––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– -#Enter Receiving Mode +# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– +# Enter Receiving Mode -#Turn off power amplifier +# Turn off power amplifier gom.set_pa(on=False) print('Power amplifier turned off') -#Set RF transmitting side to low +# Set RF transmitting side to low gom.rf_transmitting_switch(receive=True) print('RF transmitting set to low') -#Turn on LNA +# Turn on LNA gom.lna(True) print('LNA turned on') -#Set RF receiving side to high +# Set RF receiving side to high gom.rf_receiving_switch(receive=True) print('RF receiving set to high') -#Resume electrolysis if we paused it to transmit +# Resume electrolysis if we paused it to transmit if electrolyzing: - gom.set_electrolysis(True,delay = params.DEFAULT_ELECTROLYSIS_DELAY) + gom.set_electrolysis(True, delay=params.DEFAULT_ELECTROLYSIS_DELAY) print('Electrolysis Resumed with Delay ' + str(params.DEFAULT_ELECTROLYSIS_DELAY)) diff --git a/HITL-tests/flight_unit_receive.py b/HITL-tests/flight_unit_receive.py index e3d93866..627b3d73 100644 --- a/HITL-tests/flight_unit_receive.py +++ b/HITL-tests/flight_unit_receive.py @@ -1,23 +1,23 @@ -from communications.satellite_radio import Radio -from drivers.gom import Gomspace +from fsw.communications.satellite_radio import Radio +from fsw.drivers.gom import Gomspace radio = Radio() gom = Gomspace() transmissionCounter = 0 -#Turn off power amplifier +# Turn off power amplifier gom.set_pa(on=False) print('Power amplifier turned off') -#Set RF transmitting side to low +# Set RF transmitting side to low gom.rf_transmitting_switch(receive=True) print('RF transmitting set to low') -#Turn on LNA +# Turn on LNA gom.lna(True) print('LNA turned on') -#Set RF receiving side to high +# Set RF receiving side to high gom.rf_receiving_switch(receive=True) print('RF receiving set to high') @@ -25,4 +25,4 @@ message = radio.receiveSignal() if message is not None: print('Transmission #' + transmissionCounter + ' Received: ' + str(message)) - transmissionCounter += 1 \ No newline at end of file + transmissionCounter += 1 diff --git a/HITL-tests/gom_console.py b/HITL-tests/gom_console.py index 38cee9ba..65cacf66 100644 --- a/HITL-tests/gom_console.py +++ b/HITL-tests/gom_console.py @@ -3,8 +3,8 @@ # Be careful though when hardware is connected - the ipython notebook # does NOT have the same precautionary measures in place that are defined in this file. -from drivers.gom import Gomspace -import drivers.power.power_structs as ps +from fsw.drivers.gom import Gomspace +import fsw.drivers.power.power_structs as ps from time import sleep import logging diff --git a/HITL-tests/gyro_bias_check.py b/HITL-tests/gyro_bias_check.py index 3d851977..4515d624 100644 --- a/HITL-tests/gyro_bias_check.py +++ b/HITL-tests/gyro_bias_check.py @@ -1,4 +1,4 @@ -from drivers.imu import Gyro +from fsw.drivers.imu import Gyro import numpy as np import logging from typing import List diff --git a/HITL-tests/hitl_groundstation_rx.py b/HITL-tests/hitl_groundstation_rx.py index 3377d3a0..4d6ef299 100644 --- a/HITL-tests/hitl_groundstation_rx.py +++ b/HITL-tests/hitl_groundstation_rx.py @@ -1,5 +1,5 @@ -from communications.satellite_radio import Radio -from communications.command_handler import CommandHandler +from fsw.communications.satellite_radio import Radio +from fsw.communications.command_handler import CommandHandler groundstation = Radio() dh = CommandHandler(None) diff --git a/HITL-tests/hitl_groundstation_tx.py b/HITL-tests/hitl_groundstation_tx.py index 5d43ef1e..9a15eb5b 100644 --- a/HITL-tests/hitl_groundstation_tx.py +++ b/HITL-tests/hitl_groundstation_tx.py @@ -1,7 +1,7 @@ -from communications.groundstation import Groundstation -from communications.commands import CommandHandler -from communications.downlink import DownlinkHandler -from flight_modes.flight_mode_factory import FLIGHT_MODE_DICT +from fsw.communications.groundstation import Groundstation +from fsw.communications.commands import CommandHandler +from fsw.communications.downlink import DownlinkHandler +from fsw.flight_modes.flight_mode_factory import FLIGHT_MODE_DICT import time import logging @@ -29,7 +29,7 @@ signIndex = argsList[i].index("=") argName = argsList[i][:signIndex] - argValue = argsList[i][signIndex + 1 :] + argValue = argsList[i][signIndex + 1:] arg_type = FLIGHT_MODE_DICT[mode_id].command_arg_types[argName] if arg_type == "int" or arg_type == "short": diff --git a/HITL-tests/signal_test_satellite.py b/HITL-tests/signal_test_satellite.py index 97f74bf2..d8a7012b 100644 --- a/HITL-tests/signal_test_satellite.py +++ b/HITL-tests/signal_test_satellite.py @@ -1,11 +1,11 @@ -import communications.satellite_radio as sr -from communications.serialization import DataHandler +import fsw.communications.satellite_radio as sr +from fsw.communications.serialization import DataHandler import board import busio import time from adafruit_bus_device.spi_device import SPIDevice -from communications.ax5043_manager.ax5043_driver import Ax5043 -from communications.ax5043_manager.ax5043_manager import Manager +from fsw.communications.ax5043_manager.ax5043_driver import Ax5043 +from fsw.communications.ax5043_manager.ax5043_manager import Manager # Radio setup driver = Ax5043(SPIDevice(busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO))) diff --git a/__init__.py b/__init__.py index e69de29b..b0d64337 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file diff --git a/communications/ax5043_manager/ax5043_manager.py b/communications/ax5043_manager/ax5043_manager.py index 60aee1e0..e25910d5 100644 --- a/communications/ax5043_manager/ax5043_manager.py +++ b/communications/ax5043_manager/ax5043_manager.py @@ -1,7 +1,7 @@ import logging import queue import time -from communications.ax5043_manager.ax5043_driver import ( +from fsw.communications.ax5043_manager.ax5043_driver import ( Reg, Pwrmode, Bits, diff --git a/communications/ax5043_manager/main_rx.py b/communications/ax5043_manager/main_rx.py index 404713b7..e46c2f5e 100644 --- a/communications/ax5043_manager/main_rx.py +++ b/communications/ax5043_manager/main_rx.py @@ -3,8 +3,8 @@ import board import busio from adafruit_bus_device.spi_device import SPIDevice -from communications.ax5043_manager.ax5043_driver import Ax5043 -from communications.ax5043_manager.ax5043_manager import Manager +from fsw.communications.ax5043_manager.ax5043_driver import Ax5043 +from fsw.communications.ax5043_manager.ax5043_manager import Manager logging.basicConfig(level=logging.DEBUG) driver = Ax5043(SPIDevice(busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO))) @@ -32,7 +32,8 @@ cycles += 1 # After 30s, break for clean shutdown # (TODO: use interrupt handler to ensure clean shutdown when killed) - if cycles >= 30: break + if cycles >= 30: + break time.sleep(1) mgr.tx_enabled = False diff --git a/communications/ax5043_manager/main_tx.py b/communications/ax5043_manager/main_tx.py index 44f7e786..e66f3194 100644 --- a/communications/ax5043_manager/main_tx.py +++ b/communications/ax5043_manager/main_tx.py @@ -3,8 +3,8 @@ import board import busio from adafruit_bus_device.spi_device import SPIDevice -from communications.ax5043_manager.ax5043_driver import Ax5043 -from communications.ax5043_manager.ax5043_manager import Manager +from fsw.communications.ax5043_manager.ax5043_driver import Ax5043 +from fsw.communications.ax5043_manager.ax5043_manager import Manager logging.basicConfig(level=logging.DEBUG) driver = Ax5043(SPIDevice(busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO))) @@ -30,7 +30,8 @@ # After 10s, break for clean shutdown # (TODO: use interrupt handler to ensure clean shutdown when killed, # or monitor transmitting state and exit when complete) - if cycles >= 10: break + if cycles >= 10: + break time.sleep(1) mgr.tx_enabled = False diff --git a/communications/ax5043_manager/mock_ax5043_driver.py b/communications/ax5043_manager/mock_ax5043_driver.py index 3f87ddbd..aef21acf 100644 --- a/communications/ax5043_manager/mock_ax5043_driver.py +++ b/communications/ax5043_manager/mock_ax5043_driver.py @@ -1,8 +1,10 @@ -from communications.ax5043_manager.ax5043_driver import Ax5043 +from fsw.communications.ax5043_manager.ax5043_driver import Ax5043 # Ideas: # * Writes replace read_defaults # * FIFO utilities + + class MockAx5043(Ax5043): def __init__(self): super().__init__(None) @@ -21,6 +23,7 @@ def read_16(self, addr): return 0x0000 def read_fifo(self, count): return bytearray(count) def write_fifo(self, values): pass + # TODO: Document importance of rst_values rst_values = { 0x000: 0x51, diff --git a/communications/ax5043_manager/test_ax5043_driver.py b/communications/ax5043_manager/test_ax5043_driver.py index 428760be..6ed6542b 100644 --- a/communications/ax5043_manager/test_ax5043_driver.py +++ b/communications/ax5043_manager/test_ax5043_driver.py @@ -1,7 +1,9 @@ import unittest -from communications.ax5043_manager.ax5043_driver import * +from fsw.communications.ax5043_manager.ax5043_driver import * # TODO: Document code + + class TestChunk(unittest.TestCase): def test_from_bytes(self): buf = bytearray([0x55, 0x80, 0x80, diff --git a/communications/ax5043_manager/test_ax5043_manager.py b/communications/ax5043_manager/test_ax5043_manager.py index 88a79521..7dcf4e82 100644 --- a/communications/ax5043_manager/test_ax5043_manager.py +++ b/communications/ax5043_manager/test_ax5043_manager.py @@ -1,8 +1,8 @@ import unittest import logging -from communications.ax5043_manager.ax5043_manager import Manager -from communications.ax5043_manager.mock_ax5043_driver import MockAx5043 -from communications.ax5043_manager.ax5043_driver import Reg, Bits +from fsw.communications.ax5043_manager.ax5043_manager import Manager +from fsw.communications.ax5043_manager.mock_ax5043_driver import MockAx5043 +from fsw.communications.ax5043_manager.ax5043_driver import Reg, Bits class TestManager(unittest.TestCase): diff --git a/communications/codec.py b/communications/codec.py index 9ece664a..b1446858 100644 --- a/communications/codec.py +++ b/communications/codec.py @@ -1,4 +1,4 @@ -from utils.struct import packer_dict +from fsw.utils.struct import packer_dict from typing import Dict, Any diff --git a/communications/codecs.py b/communications/codecs.py index 79d2385a..66d48c2a 100644 --- a/communications/codecs.py +++ b/communications/codecs.py @@ -1,5 +1,5 @@ -from communications.codec import Codec -from utils.constants import DownlinkKwargs as dk +from fsw.communications.codec import Codec +from fsw.utils.constants import DownlinkKwargs as dk TIME_codec = Codec(dk.RTC_TIME, "double") diff --git a/communications/command_definitions.py b/communications/command_definitions.py index 03edf089..21e76b54 100644 --- a/communications/command_definitions.py +++ b/communications/command_definitions.py @@ -2,12 +2,12 @@ import logging from typing import TYPE_CHECKING, Dict, List, Optional, Union, cast -from communications.codec import Codec -from communications.commands import Command -from communications import codecs -from utils import parameter_utils +from fsw.communications.codec import Codec +from fsw.communications.commands import Command +from fsw.communications import codecs +from fsw.utils import parameter_utils -from utils import gom_util +from fsw.utils import gom_util if TYPE_CHECKING: from main import MainSatelliteThread @@ -15,23 +15,23 @@ # https://stackoverflow.com/questions/39740632/python-type-hinting-without-cyclic-imports # It lets your IDE know what type(main) is, without causing any circular imports at runtime. -import drivers.power.power_structs as ps +import fsw.drivers.power.power_structs as ps import time import hashlib -from utils.constants import ( +from fsw.utils.constants import ( FMEnum, CommandEnum, CommandKwargs as ck, DownlinkKwargs as dk, GomConfKwargs, ) -import utils.constants as consts -from utils.exceptions import CommandArgException +import fsw.utils.constants as consts +from fsw.utils.exceptions import CommandArgException import subprocess import os -import utils.parameters as params +import fsw.utils.parameters as params class FM_Switch(Command): diff --git a/communications/command_handler.py b/communications/command_handler.py index af56feb1..957436c1 100644 --- a/communications/command_handler.py +++ b/communications/command_handler.py @@ -1,11 +1,11 @@ from __future__ import annotations from typing import TYPE_CHECKING, Any, Union -from utils import parameter_utils +from fsw.utils import parameter_utils if TYPE_CHECKING: from main import MainSatelliteThread -from utils.constants import ( +from fsw.utils.constants import ( DATA_OFFSET, MAC_LENGTH, COUNTER_OFFSET, @@ -20,13 +20,13 @@ from typing import Optional, Tuple, Dict import hashlib -from communications.commands import Command -from communications.command_definitions import COMMAND_DICT -from utils.exceptions import CommandUnpackingException -from communications.downlink import bit_inflation -from communications.groundstation import bit_deflation +from fsw.communications.commands import Command +from fsw.communications.command_definitions import COMMAND_DICT +from fsw.utils.exceptions import CommandUnpackingException +from fsw.communications.downlink import bit_inflation +from fsw.communications.groundstation import bit_deflation import logging -import utils.parameters as params +import fsw.utils.parameters as params def compute_mac(data: bytes) -> bytes: @@ -87,7 +87,7 @@ def unpack_link( if verify_mac(data): # TODO deal with counter counter = int.from_bytes( - data[COUNTER_OFFSET : COUNTER_OFFSET + COUNTER_SIZE], "big" + data[COUNTER_OFFSET: COUNTER_OFFSET + COUNTER_SIZE], "big" ) mac = data[:MAC_LENGTH] @@ -146,7 +146,7 @@ def pack_link( data_buffer[:COUNTER_SIZE] = counter.to_bytes(COUNTER_SIZE, "big") data_buffer[ID_OFFSET - MAC_LENGTH] = command_id data_buffer[DATA_LEN_OFFSET - MAC_LENGTH] = len(link_data) - data_buffer[DATA_OFFSET - MAC_LENGTH :] = link_data + data_buffer[DATA_OFFSET - MAC_LENGTH:] = link_data mac = compute_mac(bytes(data_buffer)) packet = mac + bytes(data_buffer) diff --git a/communications/command_queue_writer.py b/communications/command_queue_writer.py index 6d24fed3..8d52e439 100644 --- a/communications/command_queue_writer.py +++ b/communications/command_queue_writer.py @@ -2,7 +2,7 @@ commands to the EDU/HITL through the radio board, use this to write commands to a txt file, which is then read by main.py's read_command_queue_from_file method """ -from communications.command_handler import CommandHandler +from fsw.communications.command_handler import CommandHandler import logging diff --git a/communications/commands.py b/communications/commands.py index d20b3302..dee442c8 100644 --- a/communications/commands.py +++ b/communications/commands.py @@ -1,10 +1,10 @@ from __future__ import annotations from abc import ABC, abstractmethod -from utils.constants import MAX_COMMAND_SIZE, MIN_COMMAND_SIZE, CommandEnum -from utils.exceptions import CommandException +from fsw.utils.constants import MAX_COMMAND_SIZE, MIN_COMMAND_SIZE, CommandEnum +from fsw.utils.exceptions import CommandException from typing import TYPE_CHECKING, Union, Dict, List, Any, Optional -from communications.codec import Codec +from fsw.communications.codec import Codec import logging @@ -67,7 +67,7 @@ def _unpack(data: bytes, codec_dict: Dict[str, Codec]) -> Dict[str, Any]: offset = 0 kwargs = {} for codec in codec_dict.values(): - kwarg = codec.unpack(data[offset : offset + codec.num_bytes]) + kwarg = codec.unpack(data[offset: offset + codec.num_bytes]) kwargs.update(kwarg) offset += codec.num_bytes @@ -82,7 +82,7 @@ def _pack( for name, value in kwargs.items(): codec = codecs_dict[name] - buffer[offset : offset + codec.num_bytes] = codec.pack(value) + buffer[offset: offset + codec.num_bytes] = codec.pack(value) offset += codec.num_bytes return bytes(buffer) diff --git a/communications/groundstation.py b/communications/groundstation.py index f90a32f0..83c6664c 100644 --- a/communications/groundstation.py +++ b/communications/groundstation.py @@ -7,9 +7,9 @@ from bitstring import BitArray -from communications.satellite_radio import Radio +from fsw.communications.satellite_radio import Radio -from utils.constants import ZERO_WORD, ONE_WORD +from fsw.utils.constants import ZERO_WORD, ONE_WORD class Groundstation: diff --git a/communications/satellite_radio.py b/communications/satellite_radio.py index ea8903fb..4298ca04 100644 --- a/communications/satellite_radio.py +++ b/communications/satellite_radio.py @@ -3,17 +3,17 @@ from adafruit_blinka.agnostic import board_id -from utils.constants import ZERO_WORD, ONE_WORD +from fsw.utils.constants import ZERO_WORD, ONE_WORD -from drivers.device import Device, DeviceEnum +from fsw.drivers.device import Device, DeviceEnum if board_id and board_id != "GENERIC_LINUX_PC": import board import busio from adafruit_bus_device.spi_device import SPIDevice -from communications.ax5043_manager.ax5043_driver import Ax5043 -from communications.ax5043_manager.ax5043_manager import Manager +from fsw.communications.ax5043_manager.ax5043_driver import Ax5043 +from fsw.communications.ax5043_manager.ax5043_manager import Manager from bitstring import BitArray from time import time, sleep diff --git a/drivers/adc.py b/drivers/adc.py index c292563b..b16ab357 100644 --- a/drivers/adc.py +++ b/drivers/adc.py @@ -12,8 +12,8 @@ # look at the accompanying End of Semester Report found here: # https://cornell.app.box.com/file/664230352636 -from drivers.device import Device, DeviceEnum -from drivers.imu import Gyro +from fsw.drivers.device import Device, DeviceEnum +from fsw.drivers.imu import Gyro import ADS1115 diff --git a/drivers/device.py b/drivers/device.py index fe149412..02779023 100644 --- a/drivers/device.py +++ b/drivers/device.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod import logging from typing import Any -from utils.constants import StringEnum +from fsw.utils.constants import StringEnum class DeviceEnum(StringEnum): diff --git a/drivers/devices.py b/drivers/devices.py index 13696c45..1a2d9068 100644 --- a/drivers/devices.py +++ b/drivers/devices.py @@ -1,8 +1,8 @@ import logging from typing import Dict -from drivers import adc, gom, imu, rtc -from communications.satellite_radio import Radio -from drivers.device import Device, DeviceEnum +from fsw.drivers import adc, gom, imu, rtc +from fsw.communications.satellite_radio import Radio +from fsw.drivers.device import Device, DeviceEnum class DeviceContainer: diff --git a/drivers/gom.py b/drivers/gom.py index 29c30b28..6ce045f7 100644 --- a/drivers/gom.py +++ b/drivers/gom.py @@ -1,12 +1,12 @@ from enum import Enum from typing import Optional -from drivers.device import Device, DeviceEnum -import drivers.power.loadswitch as ls +from fsw.drivers.device import Device, DeviceEnum +import fsw.drivers.power.loadswitch as ls -import drivers.power.power_controller as power_controller +import fsw.drivers.power.power_controller as power_controller import logging -from drivers.power.power_structs import eps_hk_t +from fsw.drivers.power.power_structs import eps_hk_t class Hk(Enum): diff --git a/drivers/imu.py b/drivers/imu.py index 21e20ed7..84899b79 100644 --- a/drivers/imu.py +++ b/drivers/imu.py @@ -5,9 +5,9 @@ import busio import adafruit_fxos8700 import adafruit_fxas21002c -from utils.constants import GYRO_RANGE -import utils.parameters as params -from drivers.device import Device, DeviceEnum +from fsw.utils.constants import GYRO_RANGE +import fsw.utils.parameters as params +from fsw.drivers.device import Device, DeviceEnum gyro_biases = (params.GYRO_BIAS_X, params.GYRO_BIAS_Y, params.GYRO_BIAS_Z) gyro_biases_temperature_dependence = ( diff --git a/drivers/power/display_test.py b/drivers/power/display_test.py index b6a9656d..6e86b8cc 100644 --- a/drivers/power/display_test.py +++ b/drivers/power/display_test.py @@ -1,6 +1,6 @@ # Testing code, does not need to be on the satelite -from drivers.power.power_structs import * +from fsw.drivers.power.power_structs import * dtest = eps_hk_t() diff --git a/drivers/power/loadswitch.py b/drivers/power/loadswitch.py index 19e7d9f5..264d3873 100644 --- a/drivers/power/loadswitch.py +++ b/drivers/power/loadswitch.py @@ -1,11 +1,11 @@ import logging from typing import Union -from drivers.power.power_controller import PA_EN, RF_RX_EN, RF_TX_EN, Power +from fsw.drivers.power.power_controller import PA_EN, RF_RX_EN, RF_TX_EN, Power from abc import ABC, abstractmethod import time from dataclasses import dataclass -from utils.constants import GomOutputs +from fsw.utils.constants import GomOutputs import random diff --git a/drivers/power/power_controller.py b/drivers/power/power_controller.py index 73a88eb7..469f9b6b 100644 --- a/drivers/power/power_controller.py +++ b/drivers/power/power_controller.py @@ -13,10 +13,10 @@ from typing import List, cast import pigpio -import drivers.power.power_structs as ps -from utils.constants import GomOutputs -import utils.parameters as params -from utils.exceptions import PowerInputError, PowerReadError # , PowerException +import fsw.drivers.power.power_structs as ps +from fsw.utils.constants import GomOutputs +import fsw.utils.parameters as params +from fsw.utils.exceptions import PowerInputError, PowerReadError # , PowerException from time import sleep import logging diff --git a/drivers/rtc.py b/drivers/rtc.py index bbb8b74b..e24d4840 100644 --- a/drivers/rtc.py +++ b/drivers/rtc.py @@ -1,4 +1,4 @@ -from drivers.device import Device, DeviceEnum +from fsw.drivers.device import Device, DeviceEnum from adafruit_blinka.agnostic import board_id if board_id and board_id != "GENERIC_LINUX_PC": diff --git a/flight_modes/attitude_adjustment.py b/flight_modes/attitude_adjustment.py index d74ac107..12171171 100644 --- a/flight_modes/attitude_adjustment.py +++ b/flight_modes/attitude_adjustment.py @@ -2,9 +2,9 @@ # import numpy as np # from typing import Tuple from time import sleep, time -from utils.constants import FMEnum, GOM_TIMING_FUDGE_FACTOR -import utils.parameters as params -from flight_modes.flight_mode import PauseBackgroundMode +from fsw.utils.constants import FMEnum, GOM_TIMING_FUDGE_FACTOR +import fsw.utils.parameters as params +from fsw.flight_modes.flight_mode import PauseBackgroundMode import logging # from math import sin, cos diff --git a/flight_modes/flight_mode.py b/flight_modes/flight_mode.py index 2c8bce22..e43ebe6e 100644 --- a/flight_modes/flight_mode.py +++ b/flight_modes/flight_mode.py @@ -17,10 +17,10 @@ from traceback import format_tb import logging -import utils.constants as consts -import utils.parameters as params +from fsw.utils import constants as consts +from fsw.utils import parameters as params -from utils.exceptions import UnknownFlightModeException +from fsw.utils.exceptions import UnknownFlightModeException no_transition_modes = [ consts.FMEnum.SensorMode.value, diff --git a/flight_modes/flight_mode_factory.py b/flight_modes/flight_mode_factory.py index 5dc13a83..25c283fd 100644 --- a/flight_modes/flight_mode_factory.py +++ b/flight_modes/flight_mode_factory.py @@ -1,4 +1,4 @@ -from flight_modes.flight_mode import ( +from fsw.flight_modes.flight_mode import ( NormalMode, SafeMode, SensorMode, @@ -8,13 +8,13 @@ CommandMode, ) -from flight_modes.low_battery import LowBatterySafetyMode +from fsw.flight_modes.low_battery import LowBatterySafetyMode -from flight_modes.restart_reboot import RestartMode, BootUpMode -from flight_modes.maneuver_flightmode import ManeuverMode -from flight_modes.attitude_adjustment import AAMode -from utils.constants import FMEnum -from utils.exceptions import UnknownFlightModeException +from fsw.flight_modes.restart_reboot import RestartMode, BootUpMode +from fsw.flight_modes.maneuver_flightmode import ManeuverMode +from fsw.flight_modes.attitude_adjustment import AAMode +from fsw.utils.constants import FMEnum +from fsw.utils.exceptions import UnknownFlightModeException FLIGHT_MODE_DICT = { FMEnum.Boot.value: BootUpMode, diff --git a/flight_modes/low_battery.py b/flight_modes/low_battery.py index fe58a1ae..a3126b1a 100644 --- a/flight_modes/low_battery.py +++ b/flight_modes/low_battery.py @@ -1,9 +1,9 @@ import logging from time import sleep, time -from flight_modes.flight_mode import FlightMode -from utils import parameters as params -from utils.constants import * +from fsw.flight_modes.flight_mode import FlightMode +from fsw.utils import parameters as params +from fsw.utils.constants import * class LowBatterySafetyMode(FlightMode): diff --git a/flight_modes/maneuver_flightmode.py b/flight_modes/maneuver_flightmode.py index 28a8fe7b..2595e1d1 100644 --- a/flight_modes/maneuver_flightmode.py +++ b/flight_modes/maneuver_flightmode.py @@ -1,10 +1,10 @@ from time import sleep, time -from .flight_mode import PauseBackgroundMode +from fsw.flight_modes.flight_mode import PauseBackgroundMode import logging -from utils.parameter_utils import set_parameter -import utils.constants as consts -import utils.parameters as params +from fsw.utils.parameter_utils import set_parameter +import fsw.utils.constants as consts +import fsw.utils.parameters as params NO_ARGS = ([], 0) diff --git a/flight_modes/opnav_flightmode.py b/flight_modes/opnav_flightmode.py index d6d90df7..012ed194 100644 --- a/flight_modes/opnav_flightmode.py +++ b/flight_modes/opnav_flightmode.py @@ -4,10 +4,10 @@ from sqlalchemy.exc import SQLAlchemyError from multiprocessing import Process -from utils.constants import FMEnum -from utils.db import OpNavCoordinatesModel +from fsw.utils.constants import FMEnum +from fsw.utils.db import OpNavCoordinatesModel import logging -from .flight_mode import PauseBackgroundMode +from fsw.flight_modes.flight_mode import PauseBackgroundMode class OpNavMode(PauseBackgroundMode): diff --git a/flight_modes/restart_reboot.py b/flight_modes/restart_reboot.py index b1351eae..d266b532 100644 --- a/flight_modes/restart_reboot.py +++ b/flight_modes/restart_reboot.py @@ -1,12 +1,12 @@ import time from datetime import datetime -from utils.db import create_sensor_tables_from_path, RebootsModel -from utils.constants import DB_FILE, BOOTUP_SEPARATION_DELAY, NO_FM_CHANGE, FMEnum -from flight_modes.flight_mode import FlightMode +from fsw.utils.db import create_sensor_tables_from_path, RebootsModel +from fsw.utils.constants import DB_FILE, BOOTUP_SEPARATION_DELAY, NO_FM_CHANGE, FMEnum +from fsw.flight_modes.flight_mode import FlightMode import os import logging import psutil -import utils.parameters as params +import fsw.utils.parameters as params class BootUpMode(FlightMode): diff --git a/main.py b/main.py index 820394d3..0b637501 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +import sys +sys.path.append("../") from multiprocessing import Process from queue import Queue, PriorityQueue from threading import Thread @@ -5,27 +7,28 @@ from typing import Optional, List import os import signal -from flight_modes.flight_mode import FlightMode, TestMode +from fsw.flight_modes.flight_mode import FlightMode, TestMode import logging from time import sleep -import sys -import utils.constants as consts +import fsw.utils.constants as consts +from fsw.flight_modes.restart_reboot import RestartMode, BootUpMode +from fsw.flight_modes.flight_mode_factory import build_flight_mode +from fsw.communications.command_handler import CommandHandler +from fsw.telemetry.telemetry import Telemetry +from fsw.utils.boot_cause import hard_boot +from fsw.udp_client.client import Client +from fsw.communications.comms_driver import CommunicationsSystem +from fsw.drivers.devices import DeviceContainer +from fsw.drivers.nemo.nemo_manager import NemoManager +import fsw.opnav.core.camera as camera +from fsw.utils.parameter_utils import init_parameters +from fsw.utils.db import create_sensor_tables_from_path +from fsw.sim.sim_data import SimData + +sys.path.append(r'./') + # from drivers.dummy_sensors import PressureSensor -from flight_modes.restart_reboot import RestartMode, BootUpMode -from flight_modes.flight_mode_factory import build_flight_mode -from communications.command_handler import CommandHandler -from telemetry.telemetry import Telemetry -from utils.boot_cause import hard_boot -from udp_client.client import Client - -from communications.comms_driver import CommunicationsSystem -from drivers.devices import DeviceContainer -from drivers.nemo.nemo_manager import NemoManager -import opnav.core.camera as camera -from utils.parameter_utils import init_parameters -from utils.db import create_sensor_tables_from_path -from sim.sim_data import SimData class MainSatelliteThread(Thread): diff --git a/opnav/core/attitude.py b/opnav/core/attitude.py index c19baf19..e7927e6d 100644 --- a/opnav/core/attitude.py +++ b/opnav/core/attitude.py @@ -1,5 +1,5 @@ from typing import List -from opnav.core.const import ( +from fsw.opnav.core.const import ( AttitudeEstimateOutput, AttitudeStateVector, CovarianceMatrix, @@ -7,7 +7,7 @@ GyroVars, QuaternionVector, ) -from opnav.core.const import AttitudeUKFConstants +from fsw.opnav.core.const import AttitudeUKFConstants import numpy as np # from numpy.linalg import inv diff --git a/opnav/core/cam_meas.py b/opnav/core/cam_meas.py index 241a1aeb..7393db51 100644 --- a/opnav/core/cam_meas.py +++ b/opnav/core/cam_meas.py @@ -3,8 +3,8 @@ import cv2 import copy import os -from opnav.core.find_algos.find import findEarth, findMoon, findSun -from opnav.core.const import ( +from fsw.opnav.core.find_algos.find import findEarth, findMoon, findSun +from fsw.opnav.core.const import ( NoImagesInCameraAcquisitionDirectory, InvalidBodyNameForLoadProperties, ) diff --git a/opnav/core/observe_functions.py b/opnav/core/observe_functions.py index 97bec6d1..12caf7cf 100644 --- a/opnav/core/observe_functions.py +++ b/opnav/core/observe_functions.py @@ -1,4 +1,4 @@ -from opnav.core.const import ( +from fsw.opnav.core.const import ( BodyEnum, CisLunarCameraParameters, FileData, @@ -7,8 +7,8 @@ CameraParameters, CameraRecordingParameters, ) -from opnav.core.find_algos.find_with_contours import find -from opnav.core.sense import select_camera, record_video +from fsw.opnav.core.find_algos.find_with_contours import find +from fsw.opnav.core.sense import select_camera, record_video from adafruit_blinka.agnostic import board_id diff --git a/opnav/core/opnav.py b/opnav/core/opnav.py index 68321b72..cd104166 100644 --- a/opnav/core/opnav.py +++ b/opnav/core/opnav.py @@ -1,4 +1,4 @@ -from opnav.core.const import ( +from fsw.opnav.core.const import ( AttitudeStateVector, CameraMeasurementVector, CameraParameters, @@ -12,32 +12,32 @@ # TrajUKFConstants, TrajectoryStateVector, ) -from opnav.core.preprocess import extract_frames -import opnav.core.ukf as traj_ukf -import opnav.core.attitude as attitude +from fsw.opnav.core.preprocess import extract_frames +import fsw.opnav.core.ukf as traj_ukf +import fsw.opnav.core.attitude as attitude # from opnav.core.sense import select_camera, record_video -from opnav.core.sense import record_gyro +from fsw.opnav.core.sense import record_gyro # from opnav.core.preprocess import extract_frames # from opnav.core.find_algos.find_with_contours import find -from opnav.core.const import OPNAV_EXIT_STATUS, CisLunarCameraParameters # , BodyEnum -from opnav.core.observe_functions import * +from fsw.opnav.core.const import OPNAV_EXIT_STATUS, CisLunarCameraParameters # , BodyEnum +from fsw.opnav.core.observe_functions import * -from utils.db import ( +from fsw.utils.db import ( create_sensor_tables_from_path, OpNavTrajectoryStateModel, OpNavAttitudeStateModel, ) -from utils.db import ( +from fsw.utils.db import ( OpNavEphemerisModel, OpNavCameraMeasurementModel, OpNavPropulsionModel, OpNavGyroMeasurementModel, ) -from utils.constants import SURRENDER_LOCAL_DIR, DB_FILE, OPNAV_MEDIA_DIR -from utils.log import * -import utils.parameters as params +from fsw.utils.constants import SURRENDER_LOCAL_DIR, DB_FILE, OPNAV_MEDIA_DIR +from fsw.utils.log import * +import fsw.utils.parameters as params import numpy as np from datetime import datetime, timezone diff --git a/opnav/core/sense.py b/opnav/core/sense.py index 11933407..0d70fd03 100644 --- a/opnav/core/sense.py +++ b/opnav/core/sense.py @@ -1,4 +1,4 @@ -from opnav.core.camera import PiCam, CameraMux +from fsw.opnav.core.camera import PiCam, CameraMux def select_camera(id): diff --git a/opnav/core/ukf.py b/opnav/core/ukf.py index 4005f9f2..caec6ac0 100644 --- a/opnav/core/ukf.py +++ b/opnav/core/ukf.py @@ -1,4 +1,4 @@ -from opnav.core.const import ( +from fsw.opnav.core.const import ( CameraMeasurementVector, CovarianceMatrix, EphemerisVector, @@ -10,7 +10,7 @@ ) import numpy as np import math -from opnav.core.const import TrajUKFConstants as Const +from fsw.opnav.core.const import TrajUKFConstants as Const def __length(M): diff --git a/opnav/experiments/camera_initialization_test.py b/opnav/experiments/camera_initialization_test.py index 46bdec7d..e9f326df 100644 --- a/opnav/experiments/camera_initialization_test.py +++ b/opnav/experiments/camera_initialization_test.py @@ -1,5 +1,5 @@ import argparse -import opnav.core.camera as camera +import fsw.opnav.core.camera as camera # Run restart and then manually restart with sudo reboot # To record, specify the name of file you wish to create diff --git a/opnav/experiments/extract_frames_test.py b/opnav/experiments/extract_frames_test.py index 38d46878..d3df68b5 100644 --- a/opnav/experiments/extract_frames_test.py +++ b/opnav/experiments/extract_frames_test.py @@ -1,9 +1,9 @@ -from opnav.core.preprocess import extract_frames -from opnav.core.sense import select_camera, record_video -from utils.constants import OPNAV_MEDIA_DIR -from opnav.core.const import CameraRecordingParameters -from opnav.core.opnav import __get_elapsed_time -import utils.parameters as params +from fsw.opnav.core.preprocess import extract_frames +from fsw.opnav.core.sense import select_camera, record_video +from fsw.utils.constants import OPNAV_MEDIA_DIR +from fsw.opnav.core.const import CameraRecordingParameters +from fsw.opnav.core.opnav import __get_elapsed_time +import fsw.utils.parameters as params from picamera import PiCamera import time import numpy as np diff --git a/opnav/experiments/extract_frames_test_v2.py b/opnav/experiments/extract_frames_test_v2.py index ae1e27b2..e7a4964e 100644 --- a/opnav/experiments/extract_frames_test_v2.py +++ b/opnav/experiments/extract_frames_test_v2.py @@ -1,8 +1,8 @@ -from opnav.core.preprocess import extract_frames -from opnav.core.sense import select_camera, record_video -from utils.constants import OPNAV_MEDIA_DIR -from opnav.core.const import CameraRecordingParameters -import utils.parameters as params +from fsw.opnav.core.preprocess import extract_frames +from fsw.opnav.core.sense import select_camera, record_video +from fsw.utils.constants import OPNAV_MEDIA_DIR +from fsw.opnav.core.const import CameraRecordingParameters +import fsw.utils.parameters as params # from picamera import PiCamera import argparse diff --git a/opnav/experiments/findHyperParams.py b/opnav/experiments/findHyperParams.py index 3cb93eae..a7bfb000 100644 --- a/opnav/experiments/findHyperParams.py +++ b/opnav/experiments/findHyperParams.py @@ -1,5 +1,5 @@ -from opnav.core.find_algos.find import find, round_up_to_odd, create_circular_mask -from opnav.tests.test_find import calculateErrors +from fsw.opnav.core.find_algos.find import find, round_up_to_odd, create_circular_mask +from fsw.opnav.tests.test_find import calculateErrors import cv2 import os import glob @@ -67,6 +67,8 @@ SPACE_KEY = 32 # Parse dataset + + def parse(): """ Render all images in a sequence to obtain the Earth's, Sun's and Moon's @@ -168,8 +170,8 @@ def cropImage(name, x, y, s): if SUN_TEMPLATES_SUBFOLDER in name: selectionSize = int(min(c - x, x, r - y, y)) selection = original[ - y - selectionSize : y + selectionSize, - x - selectionSize : x + selectionSize, + y - selectionSize: y + selectionSize, + x - selectionSize: x + selectionSize, :, ] img = selection @@ -815,7 +817,8 @@ def generateSingleImages(bodyType): generateSingleImages(args["body"]) elif str(args["conf"]) == "three": three( - earthPath=os.path.join("D:\\OpNav\\data\\DetectorDatasetGenerator\\Earth\\Crescent\\crescentearthmoon.jpg"), + earthPath=os.path.join( + "D:\\OpNav\\data\\DetectorDatasetGenerator\\Earth\\Crescent\\crescentearthmoon.jpg"), moonPath=os.path.join( "D:\\OpNav\\data\\DetectorDatasetGenerator\\Moon\\Crescent\\steve-donna-o-meara-waxing-crescent-moon-showing-mare-crisium-large-dark-sea-on-the-right_a-G-6110078-4990703.jpg" ), diff --git a/opnav/simulations/attitudeSim.py b/opnav/simulations/attitudeSim.py index f08f29b2..08dfdac4 100644 --- a/opnav/simulations/attitudeSim.py +++ b/opnav/simulations/attitudeSim.py @@ -2,10 +2,10 @@ import numpy as np import math import os -from opnav.simulations.animations import LiveMultipleAttitudePlot, Live2DPlot -from opnav.simulations.sim import isOrthogonal -from opnav.tests.gen_opnav_data import generateSyntheticData -from opnav.core.ukf import __attitudeMatrix +from fsw.opnav.simulations.animations import LiveMultipleAttitudePlot, Live2DPlot +from fsw.opnav.simulations.sim import isOrthogonal +from fsw.opnav.tests.gen_opnav_data import generateSyntheticData +from fsw.opnav.core.ukf import __attitudeMatrix import argparse ### FOR CAMERA ORIENTATION ### diff --git a/opnav/simulations/createCZML.py b/opnav/simulations/createCZML.py index 3423cf04..2e12a0bb 100644 --- a/opnav/simulations/createCZML.py +++ b/opnav/simulations/createCZML.py @@ -4,8 +4,8 @@ import json from tqdm import tqdm -from sim import isOrthogonal, attitudeMatrix -from attitudeSim import getCameraVectors, rotateVector +from fsw.opnav.simulations.sim import isOrthogonal, attitudeMatrix +from fsw.opnav.simulations.attitudeSim import getCameraVectors, rotateVector def output_CZML( diff --git a/opnav/simulations/detectCesiumObjects.py b/opnav/simulations/detectCesiumObjects.py index e52f6d64..62315c57 100644 --- a/opnav/simulations/detectCesiumObjects.py +++ b/opnav/simulations/detectCesiumObjects.py @@ -10,8 +10,8 @@ from tqdm import tqdm import threading -from opnav.core.find_algos.find import round_up_to_odd -from opnav.core.preprocess import rectilinearToStereographicProjection +from fsw.opnav.core.find_algos.find import round_up_to_odd +from fsw.opnav.core.preprocess import rectilinearToStereographicProjection """ Extracts circles from iteration images generated in Cesium for true measurements (red moon texture, no directional lighting) diff --git a/opnav/simulations/getManeuvers.py b/opnav/simulations/getManeuvers.py index 7310a9f7..3e5ca752 100644 --- a/opnav/simulations/getManeuvers.py +++ b/opnav/simulations/getManeuvers.py @@ -2,7 +2,7 @@ import pandas as pd import numpy as np from tqdm import tqdm -from tests.gen_opnav_data import generateSyntheticData +from fsw.opnav.tests.gen_opnav_data import generateSyntheticData import argparse import os diff --git a/opnav/simulations/sim.py b/opnav/simulations/sim.py index f01925bd..568a9537 100644 --- a/opnav/simulations/sim.py +++ b/opnav/simulations/sim.py @@ -29,13 +29,13 @@ from tqdm import tqdm import argparse from datetime import datetime -from opnav.simulations.animations import LiveMultipleTrajectoryPlot -from opnav.simulations.getManeuvers import ( +from fsw.opnav.simulations.animations import LiveMultipleTrajectoryPlot +from fsw.opnav.simulations.getManeuvers import ( extractCheckpoints, getMissionTimeline, createDiscreteAttitudeManeuvers, ) -from opnav.core.ukf import __attitudeMatrix +from fsw.opnav.core.ukf import __attitudeMatrix def isOrthogonal(a, b): diff --git a/opnav/tests/ang_size_testing.py b/opnav/tests/ang_size_testing.py index 4e75441c..0455034b 100644 --- a/opnav/tests/ang_size_testing.py +++ b/opnav/tests/ang_size_testing.py @@ -5,7 +5,7 @@ import os # from opnav.core.find_algos.tiled_remap import -from utils.constants import FLIGHT_SOFTWARE_PATH +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH def stereographic_inv(x, y): diff --git a/opnav/tests/const.py b/opnav/tests/const.py index 6327e2b7..4d94e80a 100644 --- a/opnav/tests/const.py +++ b/opnav/tests/const.py @@ -1,4 +1,4 @@ -from opnav.core.const import CameraParameters +from fsw.opnav.core.const import CameraParameters import os import numpy as np diff --git a/opnav/tests/gen_opnav_data.py b/opnav/tests/gen_opnav_data.py index 66daa112..e50b7611 100644 --- a/opnav/tests/gen_opnav_data.py +++ b/opnav/tests/gen_opnav_data.py @@ -16,17 +16,17 @@ # import matplotlib.pyplot as plt -from opnav.simulations.animations import LiveTrajectoryPlot +from fsw.opnav.simulations.animations import LiveTrajectoryPlot -from opnav.core.attitude import crs, meas_model, quaternionComposition, quaternionInv +from fsw.opnav.core.attitude import crs, meas_model, quaternionComposition, quaternionInv -from opnav.tests.const import ( +from fsw.opnav.tests.const import ( TEST_6HOURS_meas, TEST_6HOURS_moonEph, TEST_6HOURS_sunEph, TEST_6HOURS_traj, ) -from opnav.tests.const import ( +from fsw.opnav.tests.const import ( TEST_C1_DISCRETIZED_meas, TEST_C1_DISCRETIZED_moonEph, TEST_C1_DISCRETIZED_sunEph, @@ -34,7 +34,7 @@ TEST_C1_DISCRETIZED_matlab, ) -from opnav.tests.const import ( +from fsw.opnav.tests.const import ( SPACECRAFT_I_B, DAMPER_C, DAMPER_I_D, @@ -42,7 +42,7 @@ TORQUE_THRUSTER, ) -from opnav.core.const import AttitudeEstimateOutput, AttitudeUKFConstants +from fsw.opnav.core.const import AttitudeEstimateOutput, AttitudeUKFConstants _a = AttitudeUKFConstants._a _f = AttitudeUKFConstants._f diff --git a/opnav/tests/test_body_meas.py b/opnav/tests/test_body_meas.py index 8981b1d3..e4801879 100644 --- a/opnav/tests/test_body_meas.py +++ b/opnav/tests/test_body_meas.py @@ -4,14 +4,14 @@ import json import re import logging -from utils.log import log +from fsw.utils.log import log import numpy as np -from opnav.core.find_algos.tiled_remap import st_to_sph -from opnav.core.const import BodyEnum, FileData, DetectionData, Vector3 -from opnav.core.observe_functions import cam_to_body, body_to_T0 -from opnav.core.opnav import calculate_cam_measurements -from utils.constants import FLIGHT_SOFTWARE_PATH +from fsw.opnav.core.find_algos.tiled_remap import st_to_sph +from fsw.opnav.core.const import BodyEnum, FileData, DetectionData, Vector3 +from fsw.opnav.core.observe_functions import cam_to_body, body_to_T0 +from fsw.opnav.core.opnav import calculate_cam_measurements +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH class BodyMeas(unittest.TestCase): diff --git a/opnav/tests/test_center_finding.py b/opnav/tests/test_center_finding.py index 70ae5bd6..a4fe32a4 100644 --- a/opnav/tests/test_center_finding.py +++ b/opnav/tests/test_center_finding.py @@ -8,11 +8,11 @@ import math import unittest import time -from utils.constants import FLIGHT_SOFTWARE_PATH +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH -from utils.log import log -from opnav.core.find_algos.find_with_hough_transform_and_contours import find -from opnav.core.const import BodyEnum +from fsw.utils.log import log +from fsw.opnav.core.find_algos.find_with_hough_transform_and_contours import find +from fsw.opnav.core.const import BodyEnum # import argparse diff --git a/opnav/tests/test_detections.py b/opnav/tests/test_detections.py index 0b137882..604d7c2d 100644 --- a/opnav/tests/test_detections.py +++ b/opnav/tests/test_detections.py @@ -1,5 +1,5 @@ -from opnav.core.find_algos.find_with_contours import find -from utils.constants import FLIGHT_SOFTWARE_PATH, SURRENDER_LOCAL_DIR +from fsw.opnav.core.find_algos.find_with_contours import find +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH, SURRENDER_LOCAL_DIR import numpy as np import unittest import glob diff --git a/opnav/tests/test_end_to_end.py b/opnav/tests/test_end_to_end.py index 08d8347d..f1334998 100644 --- a/opnav/tests/test_end_to_end.py +++ b/opnav/tests/test_end_to_end.py @@ -3,10 +3,10 @@ import glob # import logging -from utils.log import log -from opnav.tests import test_center_finding, test_reprojections, test_body_meas -from opnav.core.const import BodyEnum -from utils.constants import FLIGHT_SOFTWARE_PATH +from fsw.utils.log import log +from fsw.opnav.tests import test_center_finding, test_reprojections, test_body_meas +from fsw.opnav.core.const import BodyEnum +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH import re import numpy as np diff --git a/opnav/tests/test_pipeline.py b/opnav/tests/test_pipeline.py index 10074415..f4461fee 100644 --- a/opnav/tests/test_pipeline.py +++ b/opnav/tests/test_pipeline.py @@ -3,24 +3,24 @@ # import re from datetime import datetime, timedelta -import opnav.core.opnav as opnav +import fsw.opnav.core.opnav as opnav -import opnav.core.const as opnav_constants -from tests.const import CesiumTestCameraParameters +import fsw.opnav.core.const as opnav_constants +from fsw.opnav.tests.const import CesiumTestCameraParameters -from utils.db import ( +from fsw.utils.db import ( create_sensor_tables_from_path, OpNavTrajectoryStateModel, OpNavAttitudeStateModel, ) -from utils.db import ( +from fsw.utils.db import ( OpNavEphemerisModel, OpNavCameraMeasurementModel, OpNavPropulsionModel, OpNavGyroMeasurementModel, RebootsModel, ) -from utils.constants import DB_FILE +from fsw.utils.constants import DB_FILE # import utils.parameters as params diff --git a/opnav/tests/test_reprojections.py b/opnav/tests/test_reprojections.py index 5c281877..5ad477fb 100644 --- a/opnav/tests/test_reprojections.py +++ b/opnav/tests/test_reprojections.py @@ -3,9 +3,9 @@ from numpy import radians import glob import os -from opnav.core.find_algos import tiled_remap +from fsw.opnav.core.find_algos import tiled_remap import unittest -from utils.constants import FLIGHT_SOFTWARE_PATH +from fsw.utils.constants import FLIGHT_SOFTWARE_PATH DATA_DIR = str(FLIGHT_SOFTWARE_PATH) + "/opnav/simulations/sim/data/" @@ -174,10 +174,10 @@ def reproj_test(self, write_remapped: bool, write_composite: bool, path=None) -> for j, c2 in enumerate(contoursTgt): x, y, w, h = cv2.boundingRect(c) - outc = out[y : y + h, x : x + w] + outc = out[y: y + h, x: x + w] x2, y2, w2, h2 = cv2.boundingRect(c2) - tgtc = tgt[y2 : y2 + h2, x2 : x2 + w2] + tgtc = tgt[y2: y2 + h2, x2: x2 + w2] # Skip if either contour is more than 2 times the size of the other. # They should be close to the same size; if they aren't, they are diff --git a/opnav/tests/test_sixhours.py b/opnav/tests/test_sixhours.py index 235ea2dc..74aad736 100644 --- a/opnav/tests/test_sixhours.py +++ b/opnav/tests/test_sixhours.py @@ -11,19 +11,19 @@ # from sqlalchemy.orm import session -from opnav.core.ukf import runTrajUKF -from opnav.tests.const import POS_ERROR_6HOURS, VEL_ERROR_6HOURS -from opnav.tests.const import ZERO_STARTING_NOISE, SMALL_STARTING_NOISE, LARGE_STARTING_NOISE -from opnav.tests.const import MatlabTestCameraParameters -from opnav.simulations.animations import LiveTrajectoryPlot -from opnav.tests.gen_opnav_data import get6HoursBatch -from opnav.tests.const import ( +from fsw.opnav.core.ukf import runTrajUKF +from fsw.opnav.tests.const import POS_ERROR_6HOURS, VEL_ERROR_6HOURS +from fsw.opnav.tests.const import ZERO_STARTING_NOISE, SMALL_STARTING_NOISE, LARGE_STARTING_NOISE +from fsw.opnav.tests.const import MatlabTestCameraParameters +from fsw.opnav.simulations.animations import LiveTrajectoryPlot +from fsw.opnav.tests.gen_opnav_data import get6HoursBatch +from fsw.opnav.tests.const import ( TEST_6HOURS_meas, TEST_6HOURS_moonEph, TEST_6HOURS_sunEph, TEST_6HOURS_traj, ) -from opnav.core.const import ( +from fsw.opnav.core.const import ( AttitudeEstimateOutput, AttitudeStateVector, CameraMeasurementVector, @@ -36,18 +36,18 @@ TrajectoryEstimateOutput, TrajectoryStateVector, ) -from FlightSoftware.utils.db import ( +from fsw.utils.db import ( OpNavEphemerisModel, OpNavCameraMeasurementModel, OpNavPropulsionModel, OpNavGyroMeasurementModel, ) -from FlightSoftware.utils.db import ( +from fsw.utils.db import ( create_sensor_tables_from_path, OpNavTrajectoryStateModel, OpNavAttitudeStateModel, ) -import opnav.core.opnav as opnav +import fsw.opnav.core.opnav as opnav SQL_PREFIX = "sqlite:///" sql_path = SQL_PREFIX + os.path.join("D:", "OpNav", "db", "satellite-db.sqlite") @@ -62,7 +62,7 @@ def calculate_velocity_error(true_state, est_state): ################################################################ -###################6 HOURS TRAJECTORY########################### +################### 6 HOURS TRAJECTORY########################### ################################################################ # Testing Traj UKF on propagation data # NOTE: trajectory is split into 6hr intervals due to impulses diff --git a/opnav/tests/test_ukf.py b/opnav/tests/test_ukf.py index a9853641..3d253bf5 100644 --- a/opnav/tests/test_ukf.py +++ b/opnav/tests/test_ukf.py @@ -5,20 +5,20 @@ import os from tqdm import tqdm -from opnav.tests.const import CesiumTestCameraParameters -from opnav.core.const import ( +from fsw.opnav.tests.const import CesiumTestCameraParameters +from fsw.opnav.core.const import ( CameraMeasurementVector, CovarianceMatrix, EphemerisVector, TrajectoryEstimateOutput, TrajectoryStateVector, ) -from opnav.core.ukf import runTrajUKF -from opnav.tests.const import POS_ERROR, VEL_ERROR -from opnav.tests.const import ZERO_STARTING_NOISE, SMALL_STARTING_NOISE, LARGE_STARTING_NOISE -from opnav.tests.const import MatlabTestCameraParameters -from opnav.simulations.animations import LiveTrajectoryPlot -from opnav.tests.gen_opnav_data import get6HoursBatch +from fsw.opnav.core.ukf import runTrajUKF +from fsw.opnav.tests.const import POS_ERROR, VEL_ERROR +from fsw.opnav.tests.const import ZERO_STARTING_NOISE, SMALL_STARTING_NOISE, LARGE_STARTING_NOISE +from fsw.opnav.tests.const import MatlabTestCameraParameters +from fsw.opnav.simulations.animations import LiveTrajectoryPlot +from fsw.opnav.tests.gen_opnav_data import get6HoursBatch # def test_ukf_c1_discretized_zero_starting_noise(visual_analysis): # """ diff --git a/opnav/tests/test_ukf_functions.py b/opnav/tests/test_ukf_functions.py index 03ff0b88..e95a9125 100644 --- a/opnav/tests/test_ukf_functions.py +++ b/opnav/tests/test_ukf_functions.py @@ -1,4 +1,4 @@ -from opnav.core.const import ( +from fsw.opnav.core.const import ( CameraMeasurementVector, CovarianceMatrix, EphemerisVector, @@ -7,8 +7,8 @@ ) import numpy as np -from opnav.core.ukf import runTrajUKF -from opnav.core.opnav import calculate_cam_measurements +from fsw.opnav.core.ukf import runTrajUKF +from fsw.opnav.core.opnav import calculate_cam_measurements import unittest from parameterized import parameterized import logging diff --git a/telemetry/dummy_sensors.py b/telemetry/dummy_sensors.py index 93919a1f..8bc9cad8 100644 --- a/telemetry/dummy_sensors.py +++ b/telemetry/dummy_sensors.py @@ -1,5 +1,5 @@ -from utils.parameters import HIGH_CRACKING_PRESSURE -from telemetry.sensor import SynchronousSensor +from fsw.utils.parameters import HIGH_CRACKING_PRESSURE +from fsw.telemetry.sensor import SynchronousSensor class DummySynchronousSensor(SynchronousSensor): diff --git a/telemetry/telemetry.py b/telemetry/telemetry.py index 105fa3ea..06808043 100644 --- a/telemetry/telemetry.py +++ b/telemetry/telemetry.py @@ -8,13 +8,13 @@ from adafruit_blinka.agnostic import board_id from uptime import uptime -from drivers.power.power_structs import eps_hk_t -from telemetry.sensor import SynchronousSensor -from utils.constants import DB_FILE, MAX_GYRO_RATE, DownlinkKwargs as dk +from fsw.drivers.power.power_structs import eps_hk_t +from fsw.telemetry.sensor import SynchronousSensor +from fsw.utils.constants import DB_FILE, MAX_GYRO_RATE, DownlinkKwargs as dk # from utils.db import GyroModel -from utils.db import TelemetryModel, create_sensor_tables_from_path -from utils.exceptions import ( +from fsw.utils.db import TelemetryModel, create_sensor_tables_from_path +from fsw.utils.exceptions import ( PiSensorError, PressureError, GomSensorError, diff --git a/tests/bitflip_test.py b/tests/bitflip_test.py index b5137e93..116cbc4a 100644 --- a/tests/bitflip_test.py +++ b/tests/bitflip_test.py @@ -1,7 +1,7 @@ -from main import MainSatelliteThread -from utils.exceptions import DeserializationException +from fsw.main import MainSatelliteThread +from fsw.utils.exceptions import DeserializationException import unittest -from utils import constants +from fsw.utils import constants from typing import List import logging diff --git a/tests/codec_test.py b/tests/codec_test.py index 691a480f..5ea92eb1 100644 --- a/tests/codec_test.py +++ b/tests/codec_test.py @@ -1,5 +1,5 @@ import unittest -from communications.codec import Codec +from fsw.communications.codec import Codec from math import tan diff --git a/tests/command_test.py b/tests/command_test.py index 668db126..55f9f02f 100644 --- a/tests/command_test.py +++ b/tests/command_test.py @@ -28,10 +28,10 @@ import logging import unittest -from utils.constants import CommandEnum, FMEnum, CommandKwargs as ck -from main import MainSatelliteThread -from communications.command_handler import CommandHandler -import utils.parameters as params +from fsw.utils.constants import CommandEnum, FMEnum, CommandKwargs as ck +from fsw.main import MainSatelliteThread +from fsw.communications.command_handler import CommandHandler +import fsw.utils.parameters as params class CommandTest(unittest.TestCase): diff --git a/tests/commands_def_test.py b/tests/commands_def_test.py index 811a074f..5abb5e7c 100644 --- a/tests/commands_def_test.py +++ b/tests/commands_def_test.py @@ -1,5 +1,5 @@ -from utils.constants import CommandEnum -from communications.command_definitions import COMMAND_LIST +from fsw.utils.constants import CommandEnum +from fsw.communications.command_definitions import COMMAND_LIST import unittest diff --git a/tests/comms_test.py b/tests/comms_test.py index bd3f0dc7..23554d08 100644 --- a/tests/comms_test.py +++ b/tests/comms_test.py @@ -1,7 +1,7 @@ from time import sleep from queue import Queue -from communications.comms_driver import CommunicationsSystem +from fsw.communications.comms_driver import CommunicationsSystem class TestIPCommunicationsSystem: diff --git a/tests/db_test.py b/tests/db_test.py index 111c70b3..5b752fbd 100644 --- a/tests/db_test.py +++ b/tests/db_test.py @@ -1,7 +1,7 @@ from time import time -from utils.db import create_sensor_tables_from_path, TelemetryModel -from utils import db_functions +from fsw.utils.db import create_sensor_tables_from_path, TelemetryModel +from fsw.utils import db_functions MEMORY_DB_PATH = "sqlite://" diff --git a/tests/device_container_test.py b/tests/device_container_test.py index 1973e6dc..b69eed3d 100644 --- a/tests/device_container_test.py +++ b/tests/device_container_test.py @@ -1,5 +1,5 @@ import unittest -from drivers.devices import DeviceContainer +from fsw.drivers.devices import DeviceContainer class MainThreadInitTestCase(unittest.TestCase): diff --git a/tests/env_test.py b/tests/env_test.py index a8aadc25..bbea34a9 100644 --- a/tests/env_test.py +++ b/tests/env_test.py @@ -1,4 +1,4 @@ -import utils.constants as consts +import fsw.utils.constants as consts def test_env(): diff --git a/tests/gom_config_test.py b/tests/gom_config_test.py index 76dced18..018780eb 100644 --- a/tests/gom_config_test.py +++ b/tests/gom_config_test.py @@ -1,9 +1,9 @@ from random import randint -import drivers.power.power_structs as ps -from main import MainSatelliteThread -from utils.constants import CommandEnum -from communications.command_handler import CommandHandler -from utils.gom_util import ( +import fsw.drivers.power.power_structs as ps +from fsw.main import MainSatelliteThread +from fsw.utils.constants import CommandEnum +from fsw.communications.command_handler import CommandHandler +from fsw.utils.gom_util import ( dict_from_eps_config, eps_config_from_dict, dict_from_eps_config2, diff --git a/tests/main_test.py b/tests/main_test.py index ce78fac6..faaa729f 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -4,13 +4,13 @@ - To run a quick sanity check that the attributes of the thread object are what we expect them to be """ import unittest -from drivers.devices import DeviceContainer -from main import MainSatelliteThread +from fsw.drivers.devices import DeviceContainer +from fsw.main import MainSatelliteThread from queue import Queue -from communications.command_handler import CommandHandler -from telemetry.telemetry import Telemetry -from flight_modes.flight_mode import FlightMode +from fsw.communications.command_handler import CommandHandler +from fsw.telemetry.telemetry import Telemetry +from fsw.flight_modes.flight_mode import FlightMode EMPTY_LIST = [] diff --git a/tests/maneuver_test.py b/tests/maneuver_test.py index e85a2822..0538a6a9 100644 --- a/tests/maneuver_test.py +++ b/tests/maneuver_test.py @@ -2,12 +2,12 @@ from queue import PriorityQueue import pytest -import utils.constants as consts -import utils.parameters as params -from flight_modes.maneuver_flightmode import ManeuverMode -from main import MainSatelliteThread -from drivers.gom import Gomspace -from drivers.power.loadswitch import mockGPIOLoadSwitch, mockP31uLoadSwitch +import fsw.utils.constants as consts +import fsw.utils.parameters as params +from fsw.flight_modes.maneuver_flightmode import ManeuverMode +from fsw.main import MainSatelliteThread +from fsw.drivers.gom import Gomspace +from fsw.drivers.power.loadswitch import mockGPIOLoadSwitch, mockP31uLoadSwitch import logging # to speed testing diff --git a/tests/parameters_test.py b/tests/parameters_test.py index 8bab31d0..0a5041ad 100644 --- a/tests/parameters_test.py +++ b/tests/parameters_test.py @@ -1,5 +1,5 @@ import os -from utils import parameter_utils, parameters +from fsw.utils import parameter_utils, parameters import json import unittest diff --git a/utils/cqc.py b/utils/cqc.py index 73679a7d..8aa32252 100644 --- a/utils/cqc.py +++ b/utils/cqc.py @@ -1,4 +1,4 @@ -from constants import team_identifier, a, b, M, CommandKwargs as ck +from fsw.utils.constants import team_identifier, a, b, M, CommandKwargs as ck import time from typing import cast diff --git a/utils/db.py b/utils/db.py index 6c199205..573057b0 100644 --- a/utils/db.py +++ b/utils/db.py @@ -7,7 +7,7 @@ # from sqlalchemy.dialects import postgresql -from opnav.core.const import CameraMeasurementVector +from fsw.opnav.core.const import CameraMeasurementVector # from drivers.power.power_structs import eps_hk_t diff --git a/utils/db_functions.py b/utils/db_functions.py index 811a645e..fe484318 100644 --- a/utils/db_functions.py +++ b/utils/db_functions.py @@ -1,20 +1,20 @@ from typing import Dict -from utils.db import TelemetryModel, CommandModel, RebootsModel -from utils.db import ( +from fsw.utils.db import TelemetryModel, CommandModel, RebootsModel +from fsw.utils.db import ( OpNavTrajectoryStateModel, OpNavAttitudeStateModel, OpNavPropulsionModel, ) -from utils.db import ( +from fsw.utils.db import ( OpNavEphemerisModel, OpNavCameraMeasurementModel, OpNavGyroMeasurementModel, ) -from utils.db import SQLAlchemyTableBase +from fsw.utils.db import SQLAlchemyTableBase # from utils.db import create_sensor_tables_from_path -from utils.constants import DB_ENTRY_LIMIT +from fsw.utils.constants import DB_ENTRY_LIMIT import logging # TODO change MEMORY_DB_PATH back to DB_FILE diff --git a/utils/gom_util.py b/utils/gom_util.py index 71de2a13..5d1c3066 100644 --- a/utils/gom_util.py +++ b/utils/gom_util.py @@ -1,5 +1,5 @@ -import drivers.power.power_structs as ps -from utils.constants import GomConfKwargs +import fsw.drivers.power.power_structs as ps +from fsw.utils.constants import GomConfKwargs from typing import Dict, List, cast diff --git a/utils/parameter_utils.py b/utils/parameter_utils.py index 95912fb9..cd32f2d3 100644 --- a/utils/parameter_utils.py +++ b/utils/parameter_utils.py @@ -1,7 +1,7 @@ from json import load, dump -from utils.constants import PARAMETERS_JSON_PATH -from utils import parameters -from utils.exceptions import CislunarException +from fsw.utils.constants import PARAMETERS_JSON_PATH +from fsw.utils import parameters +from fsw.utils.exceptions import CislunarException from typing import Dict, Any, List, Union import os From 9854313d862ca827856512db54ef2fefb58c2b92 Mon Sep 17 00:00:00 2001 From: Thomas McFarland Date: Sat, 4 Mar 2023 15:20:32 -0500 Subject: [PATCH 2/2] Undo change to .env --- .env.example | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..fba3f580 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +CISLUNAR_BASE_DIR=cislunar_data +SURRENDER_LOCAL_DIR=outside_repo +FOR_FLIGHT=0 +LOG=1 +TEST=1