Software Documentation

From AD7ZJ Wiki
Jump to: navigation, search

Most of the software is documented using specially formatted comments that can be parsed by doxygen. This mostly details what each function does and what kind of parameters to give it. Anything else that isn't detailed there will be put below

Landing Predictions

The landing prediction method works by figuring out the wind speed and direction at various altitudes on ascent and then extrapolating that during the descent.

Every NAV_INTERVAL ft of altitude, another entry is made in the windData[] array. This is an array of NAV_WINDDATA which has the following form:

   typedef struct {
       /// time of day in seconds
       uint32_t timeStamp;
       /// time difference in seconds from the previous entry
       uint16_t timeInterval;
       COURSE course;
       COORD coord;
   } NAV_WINDDATA;

A COURSE structure looks like this:

   typedef struct {
       /// distance in radians
       float dist;
       /// heading in radians referenced to true north
       float head;
       /// currently not used
       float trackError;
   } COURSE;

And a COORD structure looks like this:

   typedef struct {
       /// lat and long in radians
       float lat, lon;
       /// altitude in ft
       int32_t alt;
   } COORD;

So during the ascent, every 500ft the computer figures out the vector between the current lat/long and the previous entry in the table and saves the magnitude of that as 'dist' and the direction as 'head' in the COURSE structure. The current altitude is also stored in 'alt' in the COORD structure.

Then after descent is detected, the computer first iterates through the windData[] array and places the current index such that only the entries for altitudes less than the current altitude will be handled. It then iterates through the remaining entries, each time using dist = rate * time to create a vector starting at the current location whose direction is the same as was determined on ascent but whose magnitude is determined by scaling the ascent rate vector's magnitude by a fraction of how much of that original time will now be spent in the segment (descent goes much faster than ascent so this number will be < 1).

The only real trick here is figuring out the 'time' part of the equation as the descent rate is not linear and really depends on the size of the parachute and weight of the payload train. Currently this is done using a 4th order polynomial best-fit to a descent curve of a previous flight. But this is where most the inaccuracy in the prediction comes from as this curve will change depending on the previously mentioned parameters.

Once the vector for a particular segment is determined, the coordinate for it's head is determined and then set as the starting coordinate for the next entry in the table. This is continued for the remainder of the wind table and the head of the final vector is the landing estimate.