From 9f2cc077e548c928840d9f03c11780366eb66adb Mon Sep 17 00:00:00 2001 From: bdpope Date: Mon, 8 Apr 2024 14:48:42 -0500 Subject: [PATCH 1/4] Changed speed to not return negative values --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 0335036..b647bdf 100644 --- a/main.py +++ b/main.py @@ -83,7 +83,7 @@ def current_speed(): altSpeed = (alt_s2-alt_s1)/time_delta_s - if altSpeed > ALT_MAX_SPEED_FT_S: #This can change so it makes sense just if its outside of bounds + if altSpeed > ALT_MAX_SPEED_FT_S or altSpeed <= 0 : #This can change so it makes sense just if its outside of bounds return 1.0 else: return altSpeed From 257fce4d76b9d219827b023d411d99e4995466a6 Mon Sep 17 00:00:00 2001 From: Softchair Date: Mon, 8 Apr 2024 16:50:52 -0500 Subject: [PATCH 2/4] Changed oversample rate on temp, made everything better? --- helper_objects/barometer.py | 2 +- helper_objects/cylloggerCSV.py | 2 +- sensor_speed_test.py | 26 +++++++++++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/helper_objects/barometer.py b/helper_objects/barometer.py index 6150f4c..ca525a9 100644 --- a/helper_objects/barometer.py +++ b/helper_objects/barometer.py @@ -14,7 +14,7 @@ def __init__(self): i2c = board.I2C() self.bmp = adafruit_bmp3xx.BMP3XX_I2C(i2c) self.bmp.pressure_oversampling = 8 - self.bmp.temperature_oversampling = 2 + self.bmp.temperature_oversampling = 32 # Returns the altitude in feet def get_altitude(self): diff --git a/helper_objects/cylloggerCSV.py b/helper_objects/cylloggerCSV.py index cfd9274..7228279 100644 --- a/helper_objects/cylloggerCSV.py +++ b/helper_objects/cylloggerCSV.py @@ -25,4 +25,4 @@ def writeToCSV(self, message): os.write(self.logfile, str.encode("[" + current_time + "]" + ", " + str(message) + "\n")) def __del__(self): - self.logfile.close() \ No newline at end of file + os.close(self.logfile) \ No newline at end of file diff --git a/sensor_speed_test.py b/sensor_speed_test.py index 0e5914b..9568f33 100644 --- a/sensor_speed_test.py +++ b/sensor_speed_test.py @@ -1,21 +1,29 @@ import time from airbrake import airbrake +NS_TO_S = 0.000000001 +ALT_MAX_SPEED_FT_S = 700.0 + ab = airbrake() -def speed(): - alt_s1a = ab.get_altitude() - alt_s1b = ab.get_altitude() - alt_s1 = (alt_s1a + alt_s1b)/2 +def current_speed(): + alt_s1 = ab.get_altitude() before_time_ns = time.time_ns() - alt_s2a = ab.get_altitude() - alt_s2b = ab.get_altitude() - alt_s2 = (alt_s2a + alt_s2b)/2 + alt_s2 = ab.get_altitude() after_time_ns = time.time_ns() time_delta_s = (after_time_ns - before_time_ns) * NS_TO_S + altSpeed = (alt_s2-alt_s1)/time_delta_s - return altSpeed + + if altSpeed > ALT_MAX_SPEED_FT_S: #This can change so it makes sense just if its outside of bounds + return 1.0 + + elif altSpeed <= 0: + return 2.0 + else: + return altSpeed while True: - print(str(speed()) + "\r") \ No newline at end of file + # stime.sleep(.2) + print(str(current_speed()) + "\r") \ No newline at end of file From 1f095a0c73db7ac1644fe3be5810aa618c36e8ea Mon Sep 17 00:00:00 2001 From: bdpope Date: Tue, 9 Apr 2024 10:59:19 -0500 Subject: [PATCH 3/4] Updated mass and air density params. --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index b647bdf..73744dc 100644 --- a/main.py +++ b/main.py @@ -83,16 +83,18 @@ def current_speed(): altSpeed = (alt_s2-alt_s1)/time_delta_s - if altSpeed > ALT_MAX_SPEED_FT_S or altSpeed <= 0 : #This can change so it makes sense just if its outside of bounds + if altSpeed > ALT_MAX_SPEED_FT_S: return 1.0 + elif altSpeed <= 0: + return 2.0 else: return altSpeed def predicted_alt(alt,velocity): - m=26.75 #lbs + m=33.25 #lbs Cd=0.53 #CHANGE for each rocket!! A= 0.2413 # ft^2 - rho=0.062 #lbs/ft^3 at 2000ft + rho=0.065 #lbs/ft^3 at 2000ft g=32.16789 #ft/s^2 Xc=(m/(rho*Cd*A)*math.log((m*g+0.5*rho*Cd*A*velocity**2)/(m*g)))+alt return Xc From 8154e0ffb9bfd3fa4a5177661afff1ee44e3136f Mon Sep 17 00:00:00 2001 From: Softchair Date: Fri, 12 Apr 2024 21:10:42 -0500 Subject: [PATCH 4/4] Updated mass --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 73744dc..d9b3865 100644 --- a/main.py +++ b/main.py @@ -91,7 +91,7 @@ def current_speed(): return altSpeed def predicted_alt(alt,velocity): - m=33.25 #lbs + m=29.25 #lbs Cd=0.53 #CHANGE for each rocket!! A= 0.2413 # ft^2 rho=0.065 #lbs/ft^3 at 2000ft