# Trajectory Planning for a Mobile Robot in a Dynamic Environment Using an LSTM Neural Network
## 4 Results
Figure 16: (**a**) Rviz simulation for dynamic environment scenario 1 after testing the LSTM model with goal point of \((1.0,4.0)\) for \(tb3\_0\), (**b**) Rviz simulation for dynamic environment scenario 1 after testing the LSTM model with goal point of \((1.0,3.0)\) for \(tb3\_0\). Figure 15: (**a**) Gazebo simulation for dynamic environment scenario 3 with goal point of \((4.0,3.0)\) Figure 3. (**b**) Gazebo simulation for dynamic environment scenario 3 with goal point of \((4.0,2.0)\) for \(tb3\_0\). speed of 0.2 \(m/s\) until it reached the point \((0.5,2.0)\). Finally, for the simulated environment scenario 3 (Figure 18), the dynamic obstacle \(tb3\_1\) was placed initially at \((4.5,2.5)\) and was moving diagonally towards the mobile robot \(tb3\_0\) with a constant speed of 0.2 \(m/s\) until it reached the point \((2.5,0.5)\). Figures 17 and 18 show an intersection of the green and red path lines of the mobile robot and the dynamic obstacle, but there was no collision, since \(tb3\_0\) waited for \(tb3\_1\) to pass. Following the training of the LSTM model (with several examples of trajectories with six different target points, three distinct dynamic obstacles behaviors, and three unalike initial conditions for the mobile robot), an MSE of 0.0002 \(m/s\) for the linear velocity in \(x\), an MSE of 0.0004 \(rad/s\) for the angular velocity in \(z\) of \(tb3\_0\), rms errors of 0.0141 \(m/s\) for the linear velocity in \(x\), 0.02 \(rad/s\) for the angular velocity in \(z\), and an accuracy of 99.24 % were obtained. This means that the more training examples the neural network learns, the greater the precision and the easier it is for the model to be able to navigate to different target points while evading the dynamic obstacle. The proposed LSTM algorithm was compared in terms of distance (m) and time (s) with the [PERSON]'s algorithm, which is the default global planner in the ROS turtlebot3 packages. This type of algorithm is mainly used for determining the shortest paths between nodes in a graph that rely purely on local path cost [42]. [PERSON] et al. [43] state that the collision avoidance approaches for a mobile robot can be divided into two categories: global and local. The local planner in the ROS packages is the Dynamic Window Approach (DWA), which is one of the most used methods for local obstacle avoidance in mobile robots. This method was executed with a fixed frequency, meaning that only a set of velocities could be commanded to the robot due to its acceleration and velocity limits, then a reward function was proposed to select the best velocities to execute [44]. Table 2 shows the comparison made between the two approaches (LSTM proposed model, Dijkstra/DWA model) in the environment scenarios 1, 2, and 3. Figures 5-7 with the same tested goal points of Figures 13-15 for each scenario. In Tests 1 and 3, the LSTM solution had a better performance than the default solution for both time and distance wise. Meanwhile, in Test 2 the opposite occurs, where the training method slowed the robot with the LSTM. This happened because the mobile robot was trained to wait for the dynamic obstacle to pass. Test 4 was very similar in both solutions. Finally in the last two tests, the state-of-the-art solution crashed in narrow spaces while the proposed model showed its robustness and did not crash into the obstacles.