# Research on Visual Positioning of a Roadheader and Construction of an Environment Map
## 4 Map Construction and Test
### Construction of Grid Map and Test  
4.2.1. Principle of Laser Mapping  
To construct an occupancy grid map based on laser SLAM, the key is to use the prior information to calculate the posterior probability of the map, and then identify the grid state, i.e., unknown, idle, or occupied [41; 42]. The grid state schemas formed after two-dimensional (2D) LiDAR scanning are shown in Figure 8; \(\text{O}_{\text{g}}\text{X}_{\text{g}}\text{Y}_{\text{g}}\) and \(\text{O}_{\text{b}}\text{X}_{\text{b}}\text{Y}_{\text{b}}\) are the grid coordinate system and body coordinate system, respectively. The white area in the grid is idle, the black area in the grid is occupied, and the gray area in the grid is unknown, which is the target area for further exploration using SLAM technology.  
Figure 8: Construction principle of occupied grid map.  
Figure 7: Long corridor used for test.  
The measured data after the laser beam is emitted by the 2D LiDAR is denoted as \(z^{L}\), and is as shown in Equation (24). According to probability theory, if \(s=1\) that means that the grid is occupied, and if \(s=0\) that means that the grid is idle; then, the updated rule of state \(S\) for any grid is shown in Equation (25).  
\[z^{L}=\left[\begin{array}{cc}d&\theta\end{array}\right]^{T} \tag{24}\]  
where \(d\) represents the distance of the measuring point, and \(\theta\) represents the included angle between the laser beam and the body orientation.  
\[S_{i}=S_{i-1}+\log\frac{\mathrm{p}(z|s=1)}{\mathrm{p}(z|s=0)} \tag{25}\]  
where \(\mathrm{p}(0)\) is the probability calculation expression.  
The map constructed using laser SLAM can provide a priori information for navigation and obstacle avoidance of the roadheader, but it is not safe to move in the occupancy grid map using only Boolean values [42]. To realize global navigation of the roadheader and to avoid dynamic obstacles in real time, an obstacle map layer and expansion layer should be added, based on the static map layer constructed using SLAM; that is, a cost map for navigation should be constructed. The value principle of a cost map is shown in Figure 9, where each grid state is represented by a gray value from 0 to 255. The dashed line frame in the figure represents the contours of the roadheader, and the grid value of 254 indicates that the obstacles coincide with the center of the body, which will inevitably lead to a collision. The single dotted circle represents the inner tangent circle of the body contour line, the grid value in the inner tangent circle is 253, and collision is also inevitable in this area. The double-dot dotted circle represents the outer tangential circle of the body contour line, the grid value range in the outer tangential circle is 128-252, and collisions may occur in this area; the three-point scribbled circle represents the buffer area, and the grid value range is 1-128, which should be avoided. The grid value in the three-point double-dashed circle is 0, and the area is allowed free passage. The gray block with a grid value of 255 represents an unknown area, which needs to be updated according to the sensor information [43].  
Figure 9: Value principle of cost map.