## 3 Methodology  
### Network Congestion Control for ROS Images  
Figure 2 shows a control diagram, where the user parameters are read by the ROS node controller and, depending on the mode, the controller node requests an image with 3 different parameters (scale, quality, and whether it is an RGB or grayscale image). These three image quality parameters are considered because of their simplicity for the operator. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Image Type** & **Resolution** & \
\begin{tabular}{c} **Size** \\ **(MB)** \\ \end{tabular} &
\begin{tabular}{c} **Time per** \\ **Frame** \\ \end{tabular} & **FPS** \\ \hline RGB Raw Image & 1280 \(\times\) 1024 & 3.75 & 5 s & 0.20 \\ \hline Grayscale Raw Image & 1280 \(\times\) 1024 & 1.25 & 1.66 s & 0.60 \\ \hline Low-compression RGB Image & 1280 \(\times\) 1024 & 1.125 & 1.5 s & 0.66 \\ \hline High-compression RGB Image & 1280 \(\times\) 1024 & 0.375 & 0.5 s & 2 \\ \hline Low-compression Grayscale Image & 1280 \(\times\) 1024 & 0.375 & 0.5 s & 2 \\ \hline High-compression Grayscale Image & 1280 \(\times\) 1024 & 0.075 & 0.166 s & 6 \\ \hline RGB Raw Image & 640 \(\times\) 360 & 0.66 & 0.92 s & 1.08 \\ \hline Grayscale Raw Image & 640 \(\times\) 360 & 0.22 & 0.31 s & 3.22 \\ High-compression RGB Image & 640 \(\times\) 360 & 0.06 & 0.092 s & 10.8 \\ \hline High-compression Grayscale Image & 640 \(\times\) 360 & 0.02 & 0.031 s & 32.2 \\ \hline \hline \end{tabular} Values correspond to an ideal 6 Mbit bandwidth and approximate JPEG compression rates of 10% for high compression and 30% for low compression.  
\end{table} 
Table 2: Compression, resolution, size, TBF, and FPS of images at 6 Mbits/s. In complex, long-duration robotic interventions, the operator has to manage multiple tasks simultaneously (supervising autonomous behaviors, launching tasks, canceling tasks, etc.). This is why controlling simple variables such as size, quality, and RGB vs. grayscale results in better usability of the HRI. Additionally, the decision of the operator to allow for changes between RGB and grayscale images and vice versa increases the robustness of the system. There are four different modes: manual, adaptive, scale priority, and quality priority modes. The manual mode is used for situations where the operator decides the quality, scale, and number of channels of an image (RGB or grayscale) without taking into account or controlling the Request Frame Latency (RFL). This mode can be used in intervention task when the operator is not constantly looking at the image or the image is minimized. The second control mode is adaptive; this method considers the error between the desired Time Between Frames (TBF) requested by the operator in the HRI and the real RFL measured by the ROS node (the time between when the service was called and when the response was received). Based on this error, the controller adjusts the scale and quality and, if necessary, changes the image type from RGB to grayscale or vice versa. A Proportional-Integral-Derivative (PID) controller was used to control the RFL. This controlled variable was controlled by increasing or decreasing the % of scale and quality. Equations (1) and (2) define the error and the control law of the algorithm, respectively. \[e_{RFL}[k]=desired_{TBF}[k]-real_{RFL}[k] \tag{1}\]  
where the error represents the difference between the reference value (time between frames) set by the operator and the actual time it takes for an image to arrive (request frame latency). \[\tau[k]=k_{p}*e_{RFL}[k]+K_{d}*(e_{RFL}[k]-e_{RFL}[k-1])+k_{i}*\sum_{i}e_{RFL_{ i}}*real_{RFL_{i}} \tag{2}\]  
where \(K_{p}\), \(K_{d}\), and \(K_{i}\) represent the proportional, derivative, and integral gain, respectively. \(e_{RFL}\) is the RFL error, \(real_{RFL}\) is the real RFL, \(\tau\) represents the control action, and \(k\) is the discrete time step. To calculate the requested % of scale and quality, Equations (3) and (4) are used.