On Saturday (April 5th) we flew the airplane for the first time with the autopilot since it got the new wing. But before we went out to the RC airfield we had to physically install the autopilot in the fuselage, which went well. We then performed all of the flights necessary to tune the autopilot in HIL (Hardware In the Loop) simulation mode.
Using HIL simulation allowed us to all to get a better of idea of what we had to do once we got out to the airfield. In the end performing the HIL simulation in the lab saved us a lot of time and allowed me to get more familiar with tuning the PID control loops for the autopilot. Previously we had not used the PID window in Virtual Cockpit, but after using it in the HIL simulation it proved to be invaluable for properly tuning the autopilot, it allows you to see the actual, desired, and effort of a certain control parameter (i.e. pitch, roll, yaw, altitude, etc.). Previously we had had issues seeing a change in the behavior from the ground after changing a certain PID gain.
On the first flight soon after takeoff the aircraft became unstable and began to become uncontrollable and began oscillating wildly, fortunately our pilot Kyle was able to get it back on the ground without any damage. It turns out that our CG was too far aft, but after adjusting the CG we were able to continue with testing. Using the PID window and the having performed the same process of tuning the autopilot in HIL mode, the first few flights went quickly and we were able to quickly tune the level 1 control loops within two 15-minute flights. A graph of the autopilot’s roll performance is shown below, ideally the two lines should match, and they are in fact very close.
We then moved on to the level 2 control loops (i.e. pitch from airspeed, pitch from altitude, airspeed from throttle, etc.). These were slightly more difficult, and took several passes over the airfield to complete, but we were able to get them tuned to a reasonable level. The ability of the autopilot to maintain a constant altitude is shown below, there are slight oscillations in the altitude (+/- 3 meters), these are reasonable, but might be improved at a later time with more tuning.
Just as my laptop battery was about to give out we moved on to the final flight of the day. The purpose of the final flight was to verify that the autopilot is able to navigate accurately and safely. The first test was simply placing a loiter waypoint above the center of the RC airfield; although there were some oscillations in altitude, the overall performance was quite good (note the 4 m/s wind speed).
The final test was to create an oval over the airfield that the UAV would have to navigate. The first time around the circuit the UAV did not adhere to the waypoints too strictly, but after adjusting some of the navigation parameters the performance was significantly improved (see image below). After completing these flights the telemetry was reviewed and we were better able to analyze the performance of the autopilot and its navigation.
Overall the testing went well and we were able to tune the autopilot control loops better than we had previously been able to with the old wing, this is most likely due to our use the PID window and the HIL simulation which allowed our time at the airfield to be spent much more efficiently.