# Design of Autonomous Mobile Robot for Cleaning in the Environment with Obstacles
## 3 Control Algorithm  
The control algorithm for the mobile platform was taken from the research paper [8]. The control algorithm was tested in the numerical simulation in the same research paper. To move one step further, the authors decided to test the algorithm with the proposed cleaning robot. With this control algorithm, the cleaning robot tried to follow a virtual robot path while avoiding the obstacles with artificial potential functions (APF). A repulsive field was generated to repel the robot from the obstacles. The kinematics of the robot is given by the following formula:  
\[\dot{q}=\left[ \begin{array}{cc}\cos\theta&0\\ \sin\theta&0\\ 0&1\end{array} \right]u \tag{1}\]  
where vector \(u= \begin{bmatrix}v&\omega\end{bmatrix} ^{\top}\) is the control vector with \(v\) denoting linear velocity control, and \(\omega\) denotes the angular velocity control of the follower robot. Vector \(q=[x\;\;y\;\;\theta]^{\top}\) denotes the pose, and \(x\), \(y\), \(\theta\) are the position coordinates and orientation of the robot with respect to a global, fixed coordinate frame. The robot has to follow the virtual robot, which moves with the desired linear velocity and angular velocity \([v_{d}\;\;\omega_{d}]^{T}\) along the planned trajectory. The robot should achieve the same velocities as that of the virtual robot; \([x_{d}\;\;y_{d}]^{T}\) are the position coordinates of the virtual leader, which acts as a reference position of the real robot, and its orientation \(\theta\) converges to the orientation of the virtual leader \(\theta_{d}\). The APF repels the robot from the obstacles as it rises to infinity near the obstacle's borders, \(r_{j}\) (\(j\)--number of the obstacles) and decreases to zero at some distance \(R_{j}\), \(R_{j}>r_{j}\) \begin{table}
\begin{tabular}{c c c c} \hline \hline
**S.No** & **Component Name** & **Quantity** & **Specification** \\ \hline
1 & Motor Driver, L298N & 2 & Maximum current 2A \\
2 & Arduino Mega & 1 & 54 digital input/output pins \\
3 & Arduino Uno & 1 & 14 digital input/output pins \\
4 & Raspberry Pi 4 & 1 & 2 GB RAM \\
5 & Battery & 1 & 6 V, 12 Ah \\
6 & DC motor- Pololu 99:1 Metal & 4 & Integrated 48 CPR quadrature encoder \\  & gearmotor 25D\(\times\)66L & & 4741.44 CPR, Torque-15 kg/cm \\  & & & 14 digital input/output pins \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Details of electronics part of mobile platform. Equations for APF are written as follows:  
\[B_{aj}(l_{j})=\left\{ \begin{array}{ccc}0&\text{for}&l_{j}<r_{j}\\ \frac{l_{j}-r_{j}}{r_{j}-R_{j}}&\text{for}&r_{j}\leq l_{j}<R_{j}\\ 0&\text{for}&l_{j}\geq R_{j}\end{array} \right., \tag{2}\]  
which gives output \(B_{aj}(l_{j})\in\langle 0,1\rangle\), the distance between the robot and the \(j\)-th obstacle, which is defined as the Euclidean length \(l_{j}=\left\|[x_{j}\,y_{j}]^{\top}-[x\ y]^{\top}\right\|\). Scaling the function given by Equation (2) within the range \(\langle 0,\infty\rangle\) can be given as follows:  
\[V_{aj}(l_{j})=\frac{B_{aj}(l_{j})}{1-B_{aj}(l_{j})}, \tag{3}\]  
which is used later to avoid collisions. In further description terms, the 'collision area' is used for location fulfilling conditions \(l_{j}<r_{j}\). The range \(r_{j}<l_{j}<R_{j}\) is called the 'collision avoidance area'. The goal of the controller is to drive the robot along the desired trajectory along with avoiding obstacles, which result brings the following quantities to zero:  
\[p_{x} =x_{d}-x\] \[p_{y} =y_{d}-y\] \[p_{\theta} =\theta_{d}-\theta. \tag{4}\]  
**Assumption 1**. : \(\forall\{i,j\},i\
eq j,\ ||[x_{d}\ \ y_{d}]^{T}-[x_{j}\ \ y_{j}]^{T}||>R_{j}\) _where \([x_{j}\ \ y_{j}]^{T}\) is location of the center of the \(j\)-th obstacle._  
**Assumption 2**. : _If the robot gets into the avoidance region, its desired trajectory is temporarily frozen (\(\hat{x}_{d}=0,\,\hat{y}_{d}=0\)). If the robot leaves the collision avoidance area, then its desired coordinates are immediately updated.