# Design of a Chaotic Trajectory Generator Algorithm for Mobile Robots
## 4 Proposed Chaotic Trajectory Generator Algorithm for a Differential Drive Mobile Robot  
The following algorithm is used for numerical simulations and generation of chaotic trajectories in a differential drive mobile robot. The equations corresponding to every stage are shown in Algorithm 1. The block diagram of the proposed algorithm is shown in Figure 4.  
In step 1, the initial positions \((x_{0},y_{0})\) of the differential drive robot are taken as initial conditions for the Henon map (Equation (1)). In step 2, the current values of Henon's chaotic map are calculated \((x_{h}(n+1),y_{h}(n+1))\) and then assigned to the linear and angular speeds \((v(n)\) and \(\omega(n))\) in step 3. Next, in step 4, right and left wheel speeds \((v_{l}\) and \(v_{r})\) are calculated, obtaining the histograms shown in Figure 5. Then, a homogeneous dispersion is applied to these values in step 5, allowing us to re-scale the maximum and minimum speed values \((v_{dl},v_{dr})\) to the ones used by an actual differential drive mobile robot. Lastly, \(v_{dl}\) and \(v_{dr}\) values are sent to the mobile robot, which will be used for movement for 2 s (step 6). This execution time was chosen to allow the mobile robot to move in the work area.  
```
0:\((x_{0},y_{0})=\) Initial position \((x,y)\) of the robot in the work area, \(steps=\) iterations
0:\(v_{dl},v_{dr}=\) Left and right speeds for the mobile robot wheels
1:\(x_{h}(0)=x_{0}/1000\), \(y_{h}(0)=y_{0}/1000\), n = 0; While\(1\leq n\leq steps\)do
2:\(x_{h}(n+1)=1-ax_{h}^{2}(n)+y_{h}(n)\) \(y_{h}(n+1)=bx_{h}(n)\);
3:\(v(n)=x_{h}(n+1)\) \(\omega(n)=y_{h}(n+1))\);
4:\(v_{l}=v(n)-l\omega(n)\) \(v_{r}=v(n)+l\omega(n)\);
5:\(v_{dl}=floor(((100v_{l})-floor(100v_{l}))*180)+20\) \(v_{dr}=floor(((100v_{r})-floor(100v_{r}))*180)+20\);
6:\(t=2\) s;
7:\(n=n+1\). endreturn\(v_{dl},v_{dr}\)
```  
**Algorithm 1** Proposed AlgorithmThe number of iterations is determined by the application, each with an execution time of two seconds. For example, if the robot is required to operate for 2 min (that is, 120 s), the desired number of iterations would be 60. The number of iterations could be related to another kind of application; for example, the algorithm could stop when an object is found or a certain coverage percentage is achieved.  
Isolating left and right wheel speeds from Equation (5), we obtain the histograms shown in Figure 5. We can observe that \(v_{l}\) and \(v_{r}\) values are mostly negative and positive, respectively, indicating that the resulting trajectory will be primarily based on left turns. Very similar behavior can be observed with different numbers of iterations. Because of this, dispersion and uniformity measures need to be taken for \(v_{l}\) and \(v_{r}\) values, as shown in Figure 6. The dispersion allows performing a re-escalation of the values to a range of velocities usable by the robot, limiting the minimum and maximum values so that the robot can use them without any problem.  
Figure 4: Block diagram of the proposed chaotic trajectory generator Algorithm 1.  
Figure 5: Wheel speed histograms: (a) left speed \(v_{l}\); (b) right speed \(v_{r}\).  
This speed range does not include negative values, preventing the robot from moving in reverse, so that the generated trajectory encompasses a larger area of coverage in a shorter time. The two-second run time in step 6 in Algorithm 1 is used to allow the robot to have the opportunity to move properly and to have greater coverage of the work area. This run time can be adjusted according to the individual capacities of the mobile robot type to implement (maximum and minimum speed, movement type, etc.). To perform the numerical simulations, an HP laptop with an A10 processor of 1.9 GHz, 12 GB of RAM, Windows 10 (64 bit), and MATLAB R2019a were used.