# Event-Based Path-Planning and Path-Following
## 3 Two-Level Control System
### Event-Based Path-Planning  
#### 3.3.1 Discrete-Event System  
A discrete-event system (DES) is designed in this section in order to identify situations when a new path needs to be built. Before describing the designed DES, we will introduce some definitions and notations. For each obstacle point \(Q_{i}\in\mathcal{Q}\), \(i=\overline{1,N_{b}}\), define the maximum turning radius \(R^{i}_{\max}\), which allows for the AUV to bypass the point \(Q_{i}\) at a safe distance \(D_{s}\) (see Figure 2(a)). It can be calculated (cf. [14]) as  
\[R^{i}_{\max}=\rho\frac{\cos\alpha_{i}}{\sin 2\beta_{i}}-D_{s},\quad\beta_{i}= \arctan\left(\frac{D_{s}}{\rho_{i}}\sec\alpha_{i}+\tan\alpha_{i}\right).\]  
Note that, when evaluating the proximity of the AUV to obstacles, the maximum radius \(R^{i}_{\max}\) is preferable to the distance \(\rho_{i}\), since using \(R^{i}_{\max}\) ensures safe bypassing of an obstacle point, when considering the turning radius constraint \(R_{\min}\). Define \(I_{d}(\Theta)=\{i\in I_{d}:\Theta\}\), \(d\in\{L,R,A\}\), \(\Theta\) is a logical condition that narrows the set \(I_{d}\). For example, set \(I_{A}(\rho_{i}<\rho_{a})=\{i\in I_{A}:\rho_{i}<\rho_{a}\}\) contains all \(i\in I_{A}\) for which \(\rho_{i}<\rho_{a}\). Define also  
\[i^{L}_{r}=\operatorname*{arg\,min}_{i\in I_{L}}R^{i}_{\max},\quad i^{R}_{r}= \operatorname*{arg\,min}_{i\in I_{R}}R^{i}_{\max},\quad i^{L}_{\rho}= \operatorname*{arg\,min}_{i\in I_{L}}\rho_{i},\quad i^{R}_{\rho}= \operatorname*{arg\,min}_{i\in I_{R}}\rho_{i}.\]  
Denote the current position of the AUV by \(P_{V}\), its orientation vector by \(e_{V}\), the angle measured from the AUV forward direction to the location of waypoint \(j\) (the waypoint bearing angle) by \(\gamma_{j}\), the angle between the forward direction and the direction of the reference path at waypoint \(j\) by \(\phi_{j}\), and the distance to the reference path in the travel direction by \(\rho^{RP}\). When leaving the reference path to avoid an obstacle, the AUV saves the leaving time \(t_{L}\) and its orientation vector \(e_{L}\), and then monitors the change in angle \(\xi\) measured from vector \(e_{V}\) to vector \(e_{L}\). Denote, by \(t_{mp}\) (\(t_{pm}\)), the time when angle \(\xi\) changes its sign from minus to plus (plus to minus). If no change occurs, then the corresponding time is assumed to be equal to \(t_{L}\). The last point processed by the path-planning algorithm described in Section 3.3.2, we will call the key point (KP). Denote, by \(\alpha_{K}\), the bearing angle to the KP. Let \(j_{r}\) be the active segment (or the active waypoint) of the reference path. The most relevant notations are explained in Figure 2(a),b.  
Figure 3: Introduced notations. We employ a class of discrete-event systems modeled by a finite automaton (FA) [38]. A FA is represented by the tuple  
\[G=<X,\Sigma,f,x_{0},X_{m}>,\]  
where \(X\) is the finite set of states, \(\Sigma\) is the finite set of events, \(f:X\times\Sigma\to X\) is the transition function, \(x_{0}\) is the initial state, and \(X_{m}\) is the set of marked states. For the designed DES, set X consists of states that are given in Table 1, \(x_{0}=\) mS, \(X_{m}=\{\)mMC\(\}\). For the sake of simplification, we assume that the events of the set \(\Sigma\) consist of atomic events that are presented in Table 2. In this table, in addition to the previously introduced entries, we use the following abbreviations: WP for the waypoint and RP for the reference path. A composite event \((E_{1},\ldots,E_{n_{e}})\in\Sigma\) is triggered when all of its atomic events \(E_{i}\), \(i=\overline{1,n_{e}}\) is triggered simultaneously. Table 3 summarizes the transition rules implementing the function \(f\).