# Trajectory Planning for a Mobile Robot in a Dynamic Environment Using an LSTM Neural Network
## 4 Results  
The first experiments were implemented with one trajectory example for the mobile robot \(tb3\_0\). Figure 9 describes the velocity commands given by the user to the LSTM model. The linear velocity in \(x\) in \(m/s\) of the mobile robot is represented by the green line, while the angular velocity in \(z\) in \(rad/s\) is represented by the red line. The results showed that training for only one trajectory was not enough for the model to learn to reach different target locations while evading a dynamic obstacle. Further experimentation included several trajectories to train the network. Figure 10 describes many trajectories and navigation examples provided by the user through the velocity commands to the LSTM model. The linear velocity in \(x\) in \(m/s\) of the mobile robot is represented by the green line, while the angular velocity in \(z\) in \(rad/s\) is represented by the red line. Figure 9: Velocity commands for one trajectory given by the user for training. To train the network it was necessary to provide trajectory examples. Figure 9 shows only one trajectory example provided by the user to the network. The results show that one trajectory alone is not enough for the model to learn to reach different target locations while evading a dynamic obstacle. Therefore, more trajectories were needed, as shown in Figure 10, where 70 trajectories with different starting and target points were provided to the network. Each trajectory was completed within a given timestep number. The trajectory in Figure 9 was completed with 400 timesteps. Each trajectory in Figure 10 has a different timestep length given the proximity of the target points, which is why Figure 10 has near to 16,000 timesteps. After training the model with several trajectories, 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\), and an accuracy of 99.24% were obtained Figure 11. The loss curve in Figure 12 shows that the proposed LSTM model reached a consistent minimum MSE over the training runs/epochs. Figure 10: Velocity commands for several trajectories given by the user for training. The following images in Figures 13-15 show the simulation results in Gazebo, where the goal location is indicated by a green circle, and the path followed by the dynamic obstacle is marked manually by a red straight arrow. Figure 11: LSTM multi-output prediction for different trajectories at variable speeds. Figure 12: Model train loss vs. validation loss for many velocity commands for different trajectories. In Rviz, the obstacles marked by green are the ones that the sensor sees at that time, considering they are within the range of the sensor, including the dynamic obstacle. Although all obstacles and objects always appear as visual elements in the simulation environment in Gazebo, in Rviz, the dynamic or static obstacles will not be seen if they are out of the sensor's field of view. Figure 14: (a) Gazebo simulation for dynamic environment scenario 2 with goal point of \((3.0,4.0)\) for \(tb3\_0\), (b) Gazebo simulation for dynamic environment scenario 2 with goal point of \((3.0,3.0)\) for \(tb3\_0\). Figure 13: (a) Gazebo simulation for dynamic environment scenario 1 with goal point of \((1.0,4.0)\) for \(tb3\_0\), (b) Gazebo simulation for dynamic environment scenario 1 with goal point of \((1.0,3.0)\) for \(tb3\_0\). Figures 16-18 show, in Rviz, the mobile robot model \(tb3\_0\); the dynamic obstacle model \(tb3\_1\); the map of the \(5\times 5\) m simulated world for the experimentation; the path followed by \(tb3\_0\) in green; the path followed by \(tb3\_1\) in red; and the information captured in green from the \(tb3\_0\) LiDAR sensor, which has an operating range from 12 cm to 350 cm, a sampling rate of 1.8 kHz and an angular resolution of \(1^{\circ}\)[36]. The mobile robot \(tb3\_0\) arrives at the desired goal point evading the dynamic obstacle \(tb3\_1\) in each case scenario.