Skip to content

Commit

Permalink
Merge pull request #40 from TeamSunride/Sub-Zero-Altitude
Browse files Browse the repository at this point in the history
Sub zero altitude
  • Loading branch information
danverstom authored Jun 4, 2023
2 parents 7dca8d8 + c9f20d7 commit 3059390
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/shared/Atmosphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Atmosphere::Atmosphere(float pressure)
{

// initializing the layer constant matrix
layers << -5.00e3, 360.65, -6.50e-3, 1.77687e5,
layers << -5.00e3, 320.65, -6.50e-3, 1.77687e5,
0.00e3, 288.15, -6.50e-3, 1.01325e5,
11.00e3, 216.65, 0.00e-3, 2.26320e4,
20.00e3, 216.65, 1.00e-3, 5.47487e3,
Expand All @@ -23,10 +23,10 @@ Atmosphere::Atmosphere(float pressure)
layer_const << 80.00e3, 196.65, -2.00e-3, 8.86272e-1;
return;
}
if (pressure > 1.01325e5)
if (pressure > 1.77687e5)
{
geometric_alt = 0.00;
layer_const << 0.00e3, 288.15, -6.50e-3, 1.01325e5;
geometric_alt = -5.00e3;
layer_const << -5.00e3, 360.65, -6.50e-3, 1.77687e5;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/native/test_altitude_conversion/altitude_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
plt.rcParams["figure.autolayout"] = True

headers = ["pressure", "altitude"]
df = pd.read_csv('altPressure.csv', names=headers)
df = pd.read_csv('test/native/test_altitude_conversion/altPressure.csv', names=headers)

df.set_index("pressure").plot()
plt.grid()
Expand Down
18 changes: 15 additions & 3 deletions test/native/test_altitude_conversion/test_altitude_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ void tearDown() {}

float error = 0.025; // 2.5%

// layer 1 is attenuated
void test_altitude_conversion_layer1(void) {

Atmosphere Rocket(1.77687e5);

float delta = (float) (Rocket.get_altitude() - -4996.07027357);


TEST_ASSERT_TRUE(abs(delta/-4996.07027357) < error); //not tested for error as div by zero



return;
}
void test_altitude_conversion_layer2(void) {

Atmosphere Rocket(101325);
Expand Down Expand Up @@ -124,7 +136,7 @@ void CSVwrite(void) {
std::ofstream altitudeFile;
altitudeFile.open("test/native/test_altitude_conversion/altPressure.csv");

for (int i = 110000; i > 1; i = i - 1) {
for (int i = 170000; i > 1; i = i - 1) {
Atmosphere Rocket(i);
altitudeFile << i << "," << Rocket.get_altitude() << "\n";
}
Expand All @@ -140,7 +152,7 @@ int main() {
CSVwrite();
#endif
UNITY_BEGIN();

RUN_TEST(test_altitude_conversion_layer1);
RUN_TEST(test_altitude_conversion_layer2);
RUN_TEST(test_altitude_conversion_layer3);
RUN_TEST(test_altitude_conversion_layer4);
Expand Down

0 comments on commit 3059390

Please sign in to comment.