ideas:landing_spot_prediction
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ideas:landing_spot_prediction [2006/08/22 19:11] – rocketboy | ideas:landing_spot_prediction [2008/07/19 23:33] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
I wanted to write an algorithm that could continuously calculate the expected payload landing spot – to end the flight early if it looked like the payload might drift outside of pre-defined bounds. The algorithm would continuously compare the predicted spot this with an internal map of the UK outline and operate a cut-down device if it looked likely that it might drift out to sea. This would allow the balloon payload to run autonomously, | I wanted to write an algorithm that could continuously calculate the expected payload landing spot – to end the flight early if it looked like the payload might drift outside of pre-defined bounds. The algorithm would continuously compare the predicted spot this with an internal map of the UK outline and operate a cut-down device if it looked likely that it might drift out to sea. This would allow the balloon payload to run autonomously, | ||
- | I reasoned that the assent | + | I reasoned that the ascent |
- | I wanted an algorithm that would be easy to implement in a small micro (PIC) and would not use a lot of processor power, program or memory space. | + | I wanted an algorithm that would be easy to implement in a small micro (PIC) and would not use a lot of processor power, program or memory space. |
- | I tested the algorithm using data form the Pegasus III balloon flight. – I used the decent | + | I tested the algorithm using data form the Pegasus III balloon flight. – I used the descent |
{{: | {{: | ||
Line 21: | Line 21: | ||
* Compare the current time, latitude, longitude and height with the previous sample and calculate the differences of each. | * Compare the current time, latitude, longitude and height with the previous sample and calculate the differences of each. | ||
* Calculate the expected air density at the mid-point height between the current and previous sample | * Calculate the expected air density at the mid-point height between the current and previous sample | ||
- | * Calculate the decent | + | * Calculate the descent |
- | * Calculate how long it would take to fall from the current height to the previous height given that decent | + | * Calculate how long it would take to fall from the current height to the previous height given that descent |
* Scale the difference in latitude and longitude by the ratio of the time between the previous and current sample points and the calculated decent time. | * Scale the difference in latitude and longitude by the ratio of the time between the previous and current sample points and the calculated decent time. | ||
* Translate the difference in longitude using the midpoint of the current and previous sample latitude. | * Translate the difference in longitude using the midpoint of the current and previous sample latitude. | ||
Line 28: | Line 28: | ||
* Add the cumulative totals to the current position to get the predicted landing spot - re-translating the longitude given the predicted latitude. | * Add the cumulative totals to the current position to get the predicted landing spot - re-translating the longitude given the predicted latitude. | ||
- | The formula to calculate air density (kg/cu m) is | + | A very simple |
1.205 * EXP(-height / 7990.6) | 1.205 * EXP(-height / 7990.6) | ||
- | where height is in meters. | + | where height is in meters. The (better) NASA algorithem for calcualting air density is given in the pseudocode below. |
- | The formula to calculate | + | The formula to calculate |
| | ||
where cd is the drag co-efficient, | where cd is the drag co-efficient, | ||
- | Longitude adjustment is dome with the formulas: | + | Longitude adjustment is done with the formulas: |
| | ||
and | and | ||
Line 43: | Line 43: | ||
===== Co-Ordinate Maths ===== | ===== Co-Ordinate Maths ===== | ||
This algorithm assumes that the earth is a sphere (rather than the ovaloid that it actually is). | This algorithm assumes that the earth is a sphere (rather than the ovaloid that it actually is). | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
====== Pseudo Code ====== | ====== Pseudo Code ====== | ||
+ | <code c>double weight, cd, area; | ||
+ | |||
+ | // NASA air temperature/ | ||
+ | |||
+ | double air_density(double alt) | ||
+ | { | ||
+ | if (alt < 11000.0) | ||
+ | | ||
+ | temp = 15.04 - (0.00649 * alt); | ||
+ | pres = 101.29 * power((temp + 273.1) / 288.08, 5.256); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | if (alt < 25000.0) | ||
+ | { // between 11Km and 25Km - lower Stratosphere | ||
+ | temp = -56.46; | ||
+ | pres = 22.65 * exp(1.73 - ( 0.000157 * alt)); | ||
+ | } | ||
+ | else | ||
+ | { // above 25Km - upper Stratosphere | ||
+ | temp = -131.21 + (0.00299 * alt); | ||
+ | pres = 2.488 * power((temp + 273.1) / 216.6, -11.388); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | |||
- | + | void predict() | |
- | double this_time, this_lat, this_lon, | + | { |
- | double last_time, last_lat, last_lon, | + | double this_time, this_lat, this_lon, |
- | double delta_time, | + | double last_time, last_lat, last_lon, |
+ | double delta_time, | ||
double sum_lon, sum_lat; // Cumlative (scaled and translated) totals of lat/lon deltas | double sum_lon, sum_lat; // Cumlative (scaled and translated) totals of lat/lon deltas | ||
double density, descent_rate, | double density, descent_rate, | ||
double predict_lat, | double predict_lat, | ||
- | get_gps(& | + | get_gps(& |
while(1) | while(1) | ||
{ | { | ||
sleep(1); | sleep(1); | ||
- | get_gps(& | + | get_gps(& |
delta_time = this_time - last_time; | delta_time = this_time - last_time; | ||
delta_lon = this_lon - last_lon; | delta_lon = this_lon - last_lon; | ||
delta_lat = this_lat - last_lat; | delta_lat = this_lat - last_lat; | ||
- | delta_height = this_height | + | delta_alt = this_alt |
- | density = 1.205 * EXP(-((this_height | + | density = air_density((this_alt |
- | descent_rate = SQRT((weight * 9.81)/(0.5 * density * cd * area)); // calcualte descent rate given air density, weight, drag ... | + | descent_rate = sqrt((weight * 9.81)/(0.5 * density * cd * area)); // calcualte descent rate given air density, weight, drag ... |
- | descent_time = delta_height | + | descent_time = delta_alt |
scale = descent_time / delta_time; | scale = descent_time / delta_time; | ||
delta_lat *= scale; | delta_lat *= scale; | ||
delta_lon *= scale; | delta_lon *= scale; | ||
- | delta_lon *= COS((this_lat + last_Lat)/2); // Translate longtitude relative to equator | + | delta_lon *= cos(((this_lat + last_lat)/2) * DEG2RAD); // Translate longtitude relative to equator |
sum_lat += delta_lat; | sum_lat += delta_lat; | ||
sum_lon += delta_lon; | sum_lon += delta_lon; | ||
predict_lat = this_lat + sum_lat; | predict_lat = this_lat + sum_lat; | ||
- | predict_lon = this_lon + (sum_lon / COS(predict_lat)); | + | predict_lon = this_lon + (sum_lon / cos(predict_lat |
last_time = this_time; | last_time = this_time; | ||
last_lat = this_lat; | last_lat = this_lat; | ||
last_lon = this_lon; | last_lon = this_lon; | ||
- | last_height | + | last_alt |
} | } | ||
+ | }</ | ||
+ |
ideas/landing_spot_prediction.1156273917.txt.gz · Last modified: 2008/07/19 23:30 (external edit)