Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huntsville changes #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helper_objects/barometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion helper_objects/cylloggerCSV.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
os.close(self.logfile)
8 changes: 5 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@ 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:
return 1.0
elif altSpeed <= 0:
return 2.0
else:
return altSpeed

def predicted_alt(alt,velocity):
m=26.75 #lbs
m=29.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
Expand Down
26 changes: 17 additions & 9 deletions sensor_speed_test.py
Original file line number Diff line number Diff line change
@@ -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")
# stime.sleep(.2)
print(str(current_speed()) + "\r")