# FlockAI: A Testing Suite for ML-Driven Drone Applications
## 4 Modeling and Implementation
### Drone Configuration
In regards to the inference algorithm, this is user-defined and requires from the user to extend the abstract method inference(). Moreover, as ML is a constantly evolving landscape with a large and diverse corpus of techniques and algorithms, no ML framework can cover everything. Towards this, despite the fact that FlockAI provides ML templates for regression, clustering, and classification, there are no templates, in the current version, for evolutionary techniques, such as swarm learning. To support swarm learning, a user must create a new ML al gorithm type from the abstract FlockAIMLBaseClass just like the other ML algorithms currently supported. In contrast to classification, the swarm learning algorithm type (i.e., PSO) will not include the loading of a pre-trained (static) model but rather, will include the periodic communication with a central coordination service (i.e., basestation) to receive updates so that the local model is updated after each communication round with inference embracing the updated model parameterization. Furthermore, FlockAI is designed to support the on-boarding (and testing) of multiple ML algorithms, while inference needs not be applied in the same time intervals. Finally, we note that both the input and the response of the inference task can be structured in different formats including raw form, csv, or to accommodate the most popular data science libraries in Python, as numpy's ndarrays and/or pandas' dataframes. ```
1 fromflockai.drones.mlimportFlockAIClassifier
2...
3
4 classCrowDetectionClassifier(FlockAIClassifier)
5
6 def_init__(self,inf_period=10):
7 super()..init__()
8 self.inf_period=inf_period
9...
10
11 defload_model(self,model_path,params,...)
12...
13
14 definference(self,testdata)
15...
16 returnprediction
17
18...
```

Listing 3: Custom Classifier from FlockAI Base Class

### Energy Profiling

The following provides a comprehensive overview of the vast configurations and parameters one must consider when attempting to obtain energy consumption analytics. Through this brief overview of the state-of-the-art in drone energy modeling we want to show that there are a plethora of modeling approaches and a vast set of parameters that must be understood and obtained, while most models will need to be coded for a desired simulator. All these must be apprehended prior to the emulation process, a task requiring knowledge from multiple domains, which at the very least, slows experimentation and yields innovation [24]. Equation (1) depicts the energy model integrated in Webots for calculating the energy consumption at the \(t\)th time interval of a drone and robots in general. In this equation, \(tq\) is defined as the output torque of a rotational motor and \(C\) is a constant _user-defined_ consumption factor between \([0,\text{inf})\). \[E_{t}=tq*C \tag{1}\]

Despite its simplicity, one can easily argue that such a model ignores significant aspects of what beholds as energy consumption for drone technology. A more general model for a multi-copter drone can be defined as follows. Specifically, the total energy consumption of a multi-copter drone at the \(t\)th time interval is denoted as \(E_{t}\) and can be modeled by the following equation:

\[E_{t}=E_{mators}+E_{comm}+E_{proc} \tag{2}\]

In this equation, \(E_{mators}\) denotes the energy consumption attributed to the mechanical parts tasked with \"flying\" the drone, including the electrical motors and rotating propellers. Naturally, this is the prominent energy draining factor, with the literature referencing that \(E_{motors}\) may even attribute to 95% of \(E_{t}\) for a drone entrusted with a simple flying task, and, therefore, some consider that \(E_{t}\simeq E_{motors}\)[25]. However, this does not suffice when a drone is entrusted with an AI-driven task and an open link is established for real-time data dissemination.