diff --git a/flight/pygnc/configuration/pygnc.py b/flight/pygnc/configuration/pygnc.py index 2611801..ca1656a 100644 --- a/flight/pygnc/configuration/pygnc.py +++ b/flight/pygnc/configuration/pygnc.py @@ -2,3 +2,4 @@ import warnings batch_sensor_gps_filepath = os.path.expanduser("~/sense.bin") +batch_range_filepath = os.path.expanduser("~/range.bin") diff --git a/flight/pygnc/tasks/range_history_saver.py b/flight/pygnc/tasks/range_history_saver.py new file mode 100644 index 0000000..ce4aa66 --- /dev/null +++ b/flight/pygnc/tasks/range_history_saver.py @@ -0,0 +1,25 @@ +# from ..configuration.pygnc import batch_range_filepath + + # print(f"Open {batch_range_filepath}") + # read files from range filepath then read D bytes every S time steps +def read_and_save(input_file, output_file, D, S): + with open(input_file, 'rb') as infile, open(output_file, 'wb') as outfile: + print(f"Reading {input_file} and saving every {S}th measurement to {output_file}") + count = 0 + while True: + data = infile.read(D) + if not data: + break # End of file + count += 1 + if count % S == 0: + outfile.write(data) + +if __name__ == "__main__": + # Replace 'input_file.bin' and 'output_file.bin' with your actual file names + input_file = 'range.txt' + output_file = 'sparse_measurements.bin' + + # Replace 100 and 5 with your desired values for D and S + D = 120 # Number of bytes to read and save + S = 30 # Save every S instances + read_and_save(input_file, output_file, D, S) \ No newline at end of file diff --git a/scenarios/example_scenario/batch_range_sensor_data.bin b/scenarios/example_scenario/batch_range_sensor_data.bin new file mode 100644 index 0000000..9b11956 Binary files /dev/null and b/scenarios/example_scenario/batch_range_sensor_data.bin differ