# FlockAI: A Testing Suite for ML-Driven Drone Applications
## 4 Modeling and Implementation
### Drone Configuration
The above gives a brief, but elaborative, view on the complexity of energy modeling for drones. Implementing such a model requires the definition of a plethora of parameters and the measurement of the utilization of several resources. In order to provide a simple \"jump-start\" energy profiler so that novice users can quickly perform emulated measurements, but at the same time, provide a comprehensive modeling approach for more advanced analysis, FlockAI provides users with a compositional energy profiler and pre-filled drone energy templates based on an ensemble of the SOTA in energy modeling for drones. Specifically, users can simply \"attach\" to the instantiated energy model of a drone different components. For example, Listing 4 illustrates how a user can update the energy model of a drone with a customized \(E_{proc}\) component, so that the energy model for the processing overhead ignores the sensor and i/o sub-components, and, in turn, considers the power level for the flight controller to be 8.3 W.

```
1 fromflockai.models.energyimportEproc
2
3 cusEproc=Eproc(name=\"custom-eproc\")
4 cusEproc.removeComponents([\"sensors\",\"io\"])
5 efc=cusProc.getComponent(\"fc\")
6 efc.setdose(\"DJ1A3 flightcontroller\")
7 efc.setdose(B.3)
8 mydrone.energy.updComponent(\"proc\",custProc)
9...
```

Listing 4: Example of Customizing a Drone's Energy Model

In regards to the pre-filled templates, FlockAI provides for the drones uploaded in the project repository (e.g., DJI drones), pre-filled parameterization with all low-level energy parameters pre-configured (e.g., drone mass, power of flight controller, etc.) to ease the configuration overhead when starting to use FlockAI. ### Monitoring

To perform seamless and efficient monitoring FlockAI embraces the side-car architecture paradigm. In particular, the side-car paradigm enables FlockAI to add monitoring capabilities to a simulated drone with no additional configuration to the actual business logic of the ML solution. To achieve this, FlockAI deploys monitoring probes to the containerized environment encompassing the code that will run on the drone itself, with each probe operating as an independent long-running process for harvesting data. Monitoring Probes can logically group multiple metrics together, in order to reduce the monitoring overhead when accessing common and shared resources (e.g., requests to an API, file handler, etc.). Furthermore, by operating independently, different probes can be enabled/disabled without affecting the data collection process of the other probes, while both performance and app-level metrics, along with their periodicity, can be customized accordingly by the user. A number of pre-implemented probes already exist in the FlockAI codebase that enable a comprehensive overview of the impact ML algorithms have to the resource utilization of a flying drone. The metrics encompassing these probes, depicted in Table 1, are also used to continuously populate the energy modeling which, in turn, feeds updates to a drones energy probe. Moreover, users can expose application-level metrics for their ML services by creating custom monitoring probes based on the probe interface exposed by FlockAI. The probe interface adopts the open specification spawned from the jetascopia monitoring system [28], that we have ported to the Python language and provide as open-source ([[https://github.com/dtrihinas/PyCatascopia](https://github.com/dtrihinas/PyCatascopia)]([https://github.com/dtrihinas/PyCatascopia](https://github.com/dtrihinas/PyCatascopia))) even for projects not related to drones. An example of an app-level probe was created for the use-case presented in the evaluation (objection detection), which is developed so that a ML practitioner can view in one consolidated environment both drone resource utilization and algorithm performance. To create custom probes, FlockAI exposes a high-level interface with users only needing to provide definitions (e.g., timer, ratio, etc.)