Skip to content

Added atmospheric tables for high altitude flight #17984

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

Closed
wants to merge 11 commits into from

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Jul 10, 2021

This adds a set of atmospheric tables for accurate pressure altitude and EAS2TAS for high flight up to 150k feet. This was tested on a glider at 75k feet and worked well.
The PR also fixes the EAS2TAS calculation to be consistent within SITL, which fixes problems with wind speed estimates at high altitudes.
The new tables are only used on boards also using the double precision EKF
This is part of a broader "Extreme ArduPilot" project to allow ArduPilot to work correctly at very long distances, high altitudes and high speeds.

@davidbuzz
Copy link
Contributor

davidbuzz commented Jul 27, 2021

Id like to suggest that you find a way to reduce the flash cost of the table for the average user. i understand its currently 'around' 1k. Perhaps gating this feature behind some #defines and/or gating some or all of the table behind a #define (say, perhaps leaving out the upper 50% of it that's not really used by "normal users" ?) makes sense to me. if you do this, then i think its good-to-merge.

@davidbuzz
Copy link
Contributor

Out of curiosity, i decided to graph the atmospheric table data you included here, and here's a graph. THe 4 columns are simply called A,b,c,d and I simply scaled the C and D columns by a fixed amount each to make them easy to visualise in the graph.
Screenshot at 2021-07-28 09-13-15


#if HAL_BARO_ATMOSPHERIC_TABLE || CONFIG_HAL_BOARD == HAL_BOARD_SITL
/*
MIL-STD 3013 (1962 U.S. Standard Atmosphere) in Tabular Form.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the International Standard Atmosphere as adopted by ICAO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've used the one recommended for the high altitude testing as recommended by a aerodynamics specialist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A stated goal was to give the same reading as calibrated sensors in manned aircraft give. I believe they're calibrated against that ICAO standard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ICAO according to wiki (famous last words) says it uses the USA 1976 model up to 85km which is what I used for my model of this.

Unfortunately, I cant find a copy of the ICAO that doesnt cost $$ to compare constants and such.

@davidbuzz
Copy link
Contributor

Do we need a collection of 'extreme' autotests, eg high alt, long dist from home, etc?

@hendjoshsr71
Copy link
Member

One other note is that you don't need all three of these in the table [pressure, temperature, density].
These models (1962 or 1976) assume an ideal gas and thus P = rho * R_specific * T can be used. It looks like an R_specifc of 287.053 J⋅kg−1⋅K−1 is used in the 1962 model.

If flash space is an issue, I'd really suggest using the linear discretized equations for temperature & pressure by layers.

@tridge
Copy link
Contributor Author

tridge commented Aug 2, 2021

If flash space is an issue, I'd really suggest using the linear discretized equations for temperature & pressure by layers.

have you got a reference for those? If they are a good match and not too complex then we would like to use them

@hendjoshsr71
Copy link
Member

hendjoshsr71 commented Aug 2, 2021

If flash space is an issue, I'd really suggest using the linear discretized equations for temperature & pressure by layers.

have you got a reference for those? If they are a good match and not too complex then we would like to use them

So I can't find my aerodynamics textbooks they are in boxes :(

Here is the link to the USA 1976 model. It is the same as the 1962 up until 51 km except for natural constants used. I reference this one as it is more widely used by my knowledge (for simple modeling used in aircraft design and flight sims)

See page 6 Eq 4: https://ntrs.nasa.gov/citations/19770009539

That differential is then solved depending of whether the temperature layer is gradient or isothermal.
Unfortunately, the US government is lazy and leaves that as an exercise for the reader.

Here are some lecture slides that go through the derivation (not University of Michigan but Virginia Tech is cool too :) ):
Page 12&13 for solutions: http://www.dept.aoe.vt.edu/~cdhall/courses/aoe2104/Standard%20Atmosphere.pdf

@hendjoshsr71
Copy link
Member

Here solves the differentials with all the work shown (pg 5): http://www.dept.aoe.vt.edu/~lutze/AOE2104/3atmosphere.pdf

I'm working on simplifying the c++.

@tridge
Copy link
Contributor Author

tridge commented Aug 2, 2021

@hendjoshsr71 this seems like a reasonable base:
https://github.com/maxmclau/standard-atmosphere/blob/master/index.js
we can then test how close it is to the table

@hendjoshsr71
Copy link
Member

@hendjoshsr71 this seems like a reasonable base:
https://github.com/maxmclau/standard-atmosphere/blob/master/index.js
we can then test how close it is to the table

@tridge I already have them in matlab done. I am just translating and then needs a simplification.

Pressure Error: (< 80 Pa): probably linearization errors, significant digit differences, and slight differences in constants

pressure_error

Temperature Error:
temperature_error

@tridge tridge force-pushed the pr-baro-tables branch 2 times, most recently from d0014d7 to 6fba281 Compare September 3, 2021 03:44
@tridge
Copy link
Contributor Author

tridge commented Sep 18, 2021

@hendjoshsr71 I've redone the table to use half the space, by removing pressure_Pa and making height and temperature int16_t

@hendjoshsr71
Copy link
Member

@hendjoshsr71 I've redone the table to use half the space, by removing pressure_Pa and making height and temperature int16_t

@tridge

I'd really still advocate using the functions that these tables got generated from originally. I pinged you on this branch, but perhaps you didn't see it. I implemented these functions for the US1976 model. Total space for this PR then is around 500-700 bytes. hendjoshsr71#5

I tested and compared it to the table and vs. a few online tools. Any difference to your tables is linear interpolation error.

Traveling till Monday. but I can post the graphs of the error between the two then.

@tridge
Copy link
Contributor Author

tridge commented Sep 18, 2021

I pinged you on this branch, but perhaps you didn't see it

I didn't see it, sorry. I'll have a look

@magicrub
Copy link
Contributor

@tridge Would you mind rebasing this? We'd like to do some high-altitude flight tests as a ride-along to compare against the existing implementation

@hendjoshsr71
Copy link
Member

A couple notes that really depend on the altitudes you are flying to.

This PR is missing 30,000ft as a table element.
It has linearization errors of around 10-15Pa depending upon altitude. (not taking into geopotential vs geometric errors))
Uses a table based off of geopotential altitude but doesn't deal with converting between geometric vs geopotential (negligible difference at low altitude but grows to be a bigger source of error)

The below are from MATLAB using the model, values, and methods in my branch referenced above. (It has been rebased on master. Though the part around the AHRS_Backend needs help as it is tricky to see where the refactoring there is headed.)

Graph Below using the Mathematical Functions Instead
The curves are linearization errors. Note this is comparing the two methods while not taking into account errors from using Geopotential vs Geometric Altitude. Uses 10K linearly spaced Geopotential altitudes.
image

Here is a graph with only the Geopotential Altitudes in the Table Plotted So you can see that the model and table match
image

@tridge
Copy link
Contributor Author

tridge commented Apr 29, 2024

replaced by #26915

@tridge tridge closed this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants