Software Documentation

From AD7ZJ Wiki
Revision as of 20:22, 26 October 2012 by Elijah (talk | contribs)
Jump to navigation Jump to 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 {
       uint32_t timeStamp;
       uint16_t timeInterval;
       COURSE course;
       COORD coord;
   } NAV_WINDDATA;

A COURSE structure looks like this:

   typedef struct {
       float dist, head, trackError;
   } COURSE;

And a COORD structure looks like this:

   typedef struct {
       /// lat and long in degrees
       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.

GPS File Layout

The following structure is used to write the GPS data into a binary file on the SD card. This allows for easy access by the prediction routines later on. The thought is to have a separate (human-readable) file to log the plain NMEA strings to.

Size (bits) Description
8 Hours, GMT
8 Minutes
8 Seconds
32 Latitude in degrees * 10^7 where + is North and - is South
32 Longitude in degrees * 10^7 where + is East and - is West
32 Altitude above MSL in cm
16 Groundspeed in cm/s
16 Heading CW from north in units of 0.01 degrees
16 Number of tracked Satellites