# Object Semantic Grid Mapping with 2D LiDAR and RGB-D Camera for Domestic Robot Navigation
## 4 Back-End
### Room Dominant Direction Detection  
Although the filtered and instantiated point cloud can better approximate the object positions, due to the influence of the robot trajectory or the installation position of the camera, the robot may not be able to completely observe an object. In other words, the robot can only observe part of the object. To better represent the objects, the minimum bounding box (MBB) is used to determine the approximate shape of the objects. MBB mainly includes axis-aligned, arbitrarily oriented, and object-oriented forms. The object-oriented means that the box orientation is the same as the local coordinate system of the object. As it can better  
Figure 5: The generated object semantic point cloud. Figure 6: The refinement result of the object point cloud. represent the object and the grid map as a two-dimensional map, we use OOMBR to describe all instances. The domestic floor plan is usually a rectangular layout, as it has the advantages of simple structure, a high indoor effective area utilization rate, and easy construction. Defining the two directions, which are parallel to the two edges of the rectangle, are the dominant directions of the room. Furthermore, considering that most objects are placed parallel to the dominant directions, we define the object local coordinate axes parallel to them. Aiming at the rectangular layout, the dominant directions can be extracted by means of line length and direction statistics. While the line detection algorithm needs a binary image, the occupied grid map has three states. To convert the grid map to a binary image, the free grids are regarded as the image foreground, and the unknown and occupied grids are used as the image background. Based on the binary image, we can detect the line segments. In the Cartesian coordinate system, the general equation of a straight line is:  
\[ax+by+c=0. \tag{6}\]  
The traditional Hough transform turns a point in the Cartesian coordinate system into a curve in the Hough space:  
\[\rho=x\cos\theta+y\sin\theta, \tag{7}\]  
where \(\rho\) is the distance from the origin to the line, and \(\theta\) is the angle between the perpendicular line and the x-axis. The parameters can be determined by voting. However, this method cannot obtain the coordinates of the endpoints of the line segments. Cumulative probability Hough line detection can help to obtain them. While reducing the accumulation space, the coordinates of the endpoints of the line segments can also be obtained. Therefore, we use a four-tuple \(\left(\mathbf{P}_{\mathrm{s}},\ \mathbf{P}_{\mathrm{e}},\mathbf{L},l\right)\) to describe the line segment parameters. Assuming the points of a line segment are \(\mathbf{P}_{\mathrm{s}}=\left[x_{\mathrm{s}},\ y_{\mathrm{s}}\right]^{\mathrm{T}}\) and \(\mathbf{P}_{\mathrm{e}}=\left[x_{\mathrm{e}},\ y_{\mathrm{e}}\right]^{\mathrm{T}}\), the straight line parameters \(\mathbf{L}\) and line segment length \(l\) are:  
\[\mathbf{L}=\left[\mathrm{a},\ \mathrm{b},\ \mathrm{c}\right]^{\mathrm{T}}= \left[\mathbf{P}_{\mathrm{s}}^{\mathrm{T}},1\right]^{\mathrm{T}}\times\left[ \mathbf{P}_{\mathrm{e}}^{\mathrm{T}},1\right]^{\mathrm{T}}. \tag{8}\]  
\[l=\|\mathbf{P}_{\mathrm{s}}-\mathbf{P}_{\mathrm{e}}\|_{2}. \tag{9}\]  
When determining the dominant direction of the room, we take the cumulative line length in the same direction as the number of votes. However, some of the obtained line segments belong to the same straight line but are extracted as two line segments with overlapping parts, as shown in Figure 7.  
Figure 7: Line segments to be merged: (**a**) schematic diagram and (**b**) to be merged segments in the gird map. The points of line segment are \(\mathbf{P}_{\mathrm{s}}\) and \(\mathbf{P}_{\mathrm{e}}\). The line parameters are [a, b, c]\({}^{\mathrm{T}}\). The line segment length is \(l\). Although, by adjusting the algorithm thresholds, we can reduce this situation.