Tyler Jordan, Matthew Berk, Michael Vegh
The confine strategy seen in Problem Set 3 was utilized for the official missions but the search path was changed. During testing, the aircraft tended to lose altitude as it approached waypoints during climb. As a result, the team decided on a strategy that allowed the plane to follow long straight lines so that it could reach the mission altitude quicker and remain there. Furthermore, the high-control-low included a turn-rate-limiter to ensure that the aircraft did not lose altitude during steep turns. Additionally, the old zig-zag pattern was replaced with a lawnmower pattern which swept cross-wind across the map from upwind to downwind. After a few official flights it was determined that the aircraft was detecting fires too late to be able to effectively contain and extinguish them; as a result, several heuristic paths were developed that the team determined covered the most dangerous areas quickest. A "heat map" analysis was performed to see which cells could spread fire the farthest.
Figure 1: Wind blows from left to right. (Left) Potential burn caused by upwind fire. Results are averaged over 1000 simulations. (Right) Potential damage mapped to every cell. Upwind fires are most dangerous. the fires on the sides and downwind are least dangerous.
The first new search path was dubbed ‘Linkin Park’ because of its resemblance to the band’s logo. This search path ensured that the plane looks upwind first, but then quickly searches the middle of the map, leaving the downwind and sides for last. We then modified the lawnmower path, intricately re-thinking on each time-step where the potential fires would spread to. It ended up looking like an S so it was christened ‘Superman’. However, in simulations Linkin Park outperformed Superman and the Lawnmower so it was retained for the competition.
Figure 2: (Left)Linkin Park search pattern ensures that downwind is searched quickly followed rapidly by the middle.
(Right) Superman search path attempts to anticipate where fires will spread to at different point in the path.
(Top) Lawnmower search path attempts to ensure coverage of the most dangerous cells first.
Upon reviewing the flight playbacks the team noticed that the aircraft was not completely containing the fire like it was in the MATLAB simulations. After inspecting the code, a typo was found that only allowed the algorithm to check two out of the three potential spread cells, causing the fire to be able to break out diagonally as mentioned in Mission Flights and Analysis. However, when simulations were run with the typo corrected, a decrease in average score was observed; this is likely due to another bug that was found after the official flights were flown; in this case, the aircraft contained at an angle perpendicular to the wind, which reduced spread somewhat, but ended up using additional water drops. This is again, expanded upon in Mission Flights and Analysis.
Speeding up the code
One unforeseen problem was the limited memory and processing power of the Pixhawk. The decision-making algorithm was designed to run on a laptop computer which performed adequately. However, the computing capabilities of the embedded system were severely overestimated. To adapt the algorithm to the Pixhawk several memory and processing efficiency improvements were made.
Firstly, 8-bit unsigned integers were used instead of 32-bit floating point numbers in many of the arrays to save memory. The same arrays were then used for different, non-overlapping tasks so that different tasks, such as containment and fighting, could use the same memory rather than reserving memory for themselves. In this way many variables were eliminated and reduced memory usage from 7.7 kilobytes to 1.1 kilobytes.
To improve processing efficiency the "powf()" function to take powers of floating point numbers was avoided; instead multiplication and square root functions were used. When comparing distances, the square of the distance was used to avoid superfluous operations. Additionally, instead of using arctangent to rotate points on the map, linear transformations with pre-calculated, hard-programmed cosine and sine tables were used. Finally, instead of calling the algorithm on every single low control law execution, it was only prompted to run when a picture was taken, a waypoint was reached, or a fire was put out. This allowed the navigation to only act when given new information rather than possibly changing its strategy every timestep. This drastically reduced the processing time and allowed the computer to keep up with the plane. Before these modifications the Pixhawk took up to 9.5 seconds to execute the algorithm, but after the code was made more efficient the longest wait was about .5 seconds with an average of much less.
Previous: 03_Controls