# FlockAI: A Testing Suite for ML-Driven Drone Applications
## 4 Modeling and Implementation
### Drone Configuration  
One of the first difficulties presented to an ML practitioner, is how to configure a robot emulator (e.g., Webots) so that a simulated device resembles the actual drone(s) used in production. To illustrate the difficulty in apprehending this task, one must enable a vast number of motor and sensing devices, with the configuration potentially requiring the knowledge of drone specifics, such as how to enable a drone to move autonomously in a certain area (e.g., bounding box) and perform certain maneuvers (e.g., move in a straight line or perform a zig-zag formation). To actually achieve this functionality one must take positioning data from the camera, GPS, and gyroscope (e.g., roll, pitch, yaw) at the current time interval and compute the positioning for the next via a PID controller. This, and a number of other low-level configurations, even simple ones such as, e.g., setting the capacity of the drones' flash storage, or more advanced settings, such as which sensors must or cannot be used together, slow down the testing process and even derail practitioners from the actual testing scope. Towards this, FlockAI provides several abstractions easing the configuration of simulated drones. FlockAI provides blueprint classes for popular drones (e.g., DJI drones) that extend the FlockAIController so that encompassed motors, sensors and various parameters, such as the drone weight, motor efficiency, battery capacity, etc., are pre-filled to ease configuration and quickly enable users to test their algorithms. For example, Listing 1 depicts an exemplary Python script for extending the FlockAI controller to create a pre-configured DJI Mavic 2 drone ([[https://www.dji.com/mavic-2](https://www.dji.com/mavic-2)]([https://www.dji.com/mavic-2](https://www.dji.com/mavic-2))). Hence, users can quickly attach and detach to a drone both motorized components (e.g., propellers) and sensing devices (e.g., camera, GPS) so as to customize their drone according to their needs. Therefore, if a user is working on use-case that does not require a specific sensing device then it does not need to be included. Having created a new drone controller or selected one from the FlockAI repository, users are now able to create their own customized drone experiments. Listing 2 depicts such a custom experiment that uses the DJIMavic2 drone (line 12). From this, we immediately observe that a user adopting the mavic controller does not need to configure any motors, sensors, or drone-specific parameterization (e.g., weight). Still, a user can alter and even extend the selected controller. For example, suppose the user will use the selected drone but considers testing with a more powerful battery, thenthis can easily be changed (line 13). In turn, FlockAI provides a Sensor class which can be extended to create and attach custom sensors (Listing 2) that access data from either a file or create random data based on a given probability kernel (lines 15-16). Moreover, a drone upon configuration can include a Pilot that implements a flight plan that can be statically defined, keyboard-driven, or autonomous. In Listing 2, the depicted drone is configured with an _autopilot_ that will execute a flight within a user-desired _bounding box_ and will navigate through the vicinity of this area by applying a _zig-zag_ formation. Other autopilots that are currently available in the FlockAI repository include a pilot applying obstacle collision and another going through various user-given points of interest with the navigation from point X to Y computed via a simple euclidean distance.