## 3 Contact Angle Measurement and Emergency Control Based on Laser Scanning Sensor
### Emergency Controller to Prevent Robot Falls  
In previous research, the Jacobian matrices of each wheel and its inverse were obtained [13]. The measurement of the contact angle between the wheel-ground using 2D laser sensors allows obtaining the geometric information of the terrain and detection of the wheel-contact loss. This information has an important role in preventing the robot from falling during climbing up or down. Figure 10 shows the schematic control of the wheeled robot, including the emergency control when a wheel loses contact with the ground. We set the desired robot velocity according to the contact angle measurement from the LiDAR. We calculated the Jacobian and its inverse to obtain the angular velocity of each wheel \(\dot{q}=[w_{1}w_{2}w_{3}]^{T}\), where \(w_{1}\), \(w_{2}\), and \(w_{3}\) mean the angular velocity of the front, middle, and rear wheels, respectively. Therefore, the robot can follow the desired robot velocity.  
The block \"wheel-contact loss detection Equation (10)\" defined an emergency case during climbing up or down stairs, the analysis focuses on the front wheel when it loses contact with the ground, which compromises the stability of the robot. When this case occurs, the switch changes the wheel's velocity from the \"inverse kinematic\" block to the wheel's velocity from the \"Emergency Control Equation (12) \" block, \(q_{e}c=[w_{1e}w_{2e}w_{3e}]^{T}\), where \(w_{1e}\), \(w_{2e}\), and \(w_{3e}\) denote the front, middle, and rear wheel from the emergency control block. Thus, the controller stabilizes the robot until the wheel touches the ground and the switch changes again to the \"inverse kinematic\" block.  
The emergency control kicks in when the first wheel detects the lost contact with the ground, the second wheel can lose contact, and the robot's stability will not be compromised as long as the front and rear wheels are touching the floor. The parameter \(\alpha_{2}\), Figure 3a,b is controlled, which is the angle between \(l_{2}\) and the global horizontal axis Equation (11), \(l_{2}\) is the distance between the center of the bogie and the middle wheel, \(\theta_{b}\) is the rotation of the bogie, and \(\alpha_{20}\) is the initial angle of \(\alpha_{2}\) when the robot is on a flat surface. Suppose the front wheel loses contact with the ground, then, we want \(\alpha_{2}\) to return its initial position \(\alpha_{20}\) to prevent the robot falling. Therefore, \(\alpha_{20}\) is a threshold in the controller, where \(e\) is the error control between \(\alpha_{2}\) and \(\alpha_{20}\), which it is the same as the bogie rotations \(\theta_{b}\).  
\[\alpha_{2}=\alpha_{20}+\theta_{b} \tag{11}\]  
Based on the instantaneous center of rotation, Equation (12) includes the PD controller to adjust the velocity of the middle wheel. Thus, \(\alpha_{2}\) reach the threshold \(\alpha_{20}\); \(w_{b}\), is the desired bogie velocity to achieve its ideal pose, then, the wheels' velocities continue to use the Jacobian and its inverse matrix to follow the robot's trajectory. The rear wheel during the emergency controller can inverse its velocity to maintain fixed the robot's position until \(\alpha_{2}\) reaches the initial position.  
\[\dot{q}_{cc}=\begin{bmatrix}w_{1}\\ w_{b}l_{2}\sin(\alpha_{2}+k_{p}e+k_{d}e)\\ -w_{3}\end{bmatrix} \tag{12}\]