# Real-Time Hybrid Navigation System-Based Path Planning and Obstacle Avoidance for Mobile Robots
## 7 Obstacle-Avoidance  
### Detect Collision by Using Gradient Descent and Context Analysis Based Obstacle-Avoidance Scheme  
For convenience, we assume that the robot sensors have already detected moving obstacles when it moves over the scanning area. The information from sensors can obtain which includes a radius of the circular boundary of obstacle body, position of center of boundary and constant linear velocity. It has two distinct cases when the robot detects the object:  
* Obstacle passes over the scanning zone, but not dead zone. These zones of sensors were introduced in Figure 10.  
Each case has different behaviors to avoid the obstacle based on context analysis and is illustrated in Figure 11. In the first case, when an obstacle suddenly passes over the dead zone (unpredictable case), the robot will try to stop and turn to the left until the obstacle does not present in the dead zone anymore. In the second case, when an obstacle passes over the scanning zone, the robot will check  
Figure 10: Illustrating dead zone and scanning zone of the robot. Figure 9: (**a**) Robot moves to the position where curvature is large enough, and deviates from desired trajectory; (**b**) After robot deviates from the trajectory, robot will create a subtrajectory to the back point, (**c**) The robot continues to fail to meet the acceleration condition caused by large curvature of the first created subtrajectory, the robot repeatedly create subtrajectory until it returns to original path. whether a collision is occurring. If the current trajectory were free-obstacle, the robot would continue to track on it. Otherwise, the robot must change the velocity and plans a new path. In this work, we assume the robot is on the emergency situation and needs to move as fast as possible. Therefore, in the second case, to an avoid obstacle, the robot must change the velocity direction instead of slowing down. The robot will generate a new path that will help the robot dodge the moving object and lead the robot back to the initial path at some point further. The new path has optimized arc length. Let \(\{O\}=(\mathbf{P}_{O}(t),\psi_{O})\) be the obstacle frame respect to reference frame, obstacle moving with constant velocity \(\mathbf{V}_{O}\) and \(R_{O}\) be a radius of the circular boundary. If the distance between obstacle and the robot is equal or less than sum of radius of them then collision between the obstacle and the robot will occur. Let \(\mathbf{P}_{O}^{R}(t)\) is the relative position of object respect to the robot position determined by Equation (29). \[\mathbf{P}_{O}^{R}(t)=\mathbf{P}_{O}(t)-\mathbf{P}_{R}(t) \tag{29}\]  
The path is safe if the minimum distance between the robot and moving obstacle is greater than sum of radius of them. This condition is held by the inequation below. \[\min_{t\in[t_{0},\infty)}\|\mathbf{P}_{O}^{R}(t)\|>R_{R}+R_{O} \tag{30}\]  
However, the derivative of Equation (29) is very complicated. Solution of inequation (30) can be obtained by using the univariate gradient descent algorithms with initial solution candidate \(t_{0}\) is assigned by the time when the robot detects obstacle and initial learning rate is \(\gamma_{0}\). By Equations (31) and (32), the robot can find out candidate solution very fast. \[t_{n+1}=t_{n}-\gamma_{n}\|\mathbf{P}_{O}^{R}(t_{n})\| \tag{31}\]  
\[\gamma_{n}=\frac{t_{n}-t_{n-1}}{\|\mathbf{P}_{O}^{R}(t_{n})\|-\|\mathbf{P}_{O }^{R}(t_{n-1})\|} \tag{32}\]  
According to the Equation (29) and established candidate solution of (31), the shortest distance between obstacle and the robot is obtained. By the condition (30), the robot can decide to continue following the initial path or getting a new path.