# An In-Vehicle Smartphone RTK/DR Positioning Method Combined with OSM Road Network
## 2 Materials and Methods
### Corrected Heading Angle Method  
The heading angle correction strategy is aimed at obtaining the line segment of the road where the vehicle is located through map matching and using the road direction to correct the DR heading angle. After using the \"osm2 gmns\" library to process the raw OSM data, it is possible to produce a road network map that contains only line segments and  
Figure 1: Horizontal velocity comparison. (**a**) Smartphone Huawei P30; (**b**) Smartphone Huawei P40.  
points, as shown in Figure 2. It can be found that the straight road of the OSM network consists of short line segments, and most of the routes do not allow the lane information to be distinguished. In the curved part, the number of line segments of the OSM road network is higher, and the length is lower. When the vehicle is be driven along a curve, the heading angle of the OSM road drastically changes and cannot accurately represent the actual moving direction of the vehicle itself. Compared with curved roads, straight roads have longer line segments, while the direction changes of vehicles are fewer when driving. Therefore, the heading angle is corrected when driving along straight roads.  
The first step is to assess the motion state of the vehicle, which is divided into two cases: straight and turning. Figure 3 shows the change of heading angle per second. The DR heading angle is obtained by updating the IMU data of the smartphone, while the reference heading angle is obtained through the difference between the adjacent positioning results of the vehicle-mounted geodetic GNSS receiver. When the vehicle turns, the actual heading angle change has a peak. Figure 3 shows that the peak of the DR heading angle change is the same as that of the geodetic GNSS receiver, indicating that the DR heading angle change can be used to determine whether the vehicle is turning.  
Figure 3: Variation of heading angle. (**a**) Smartphone Huawei P30; (**b**) Smartphone Huawei P40.  
Figure 2: OSM road network.  
In this work, the latest 5 s change of the DR heading angle is obtained. Then the cumulative change \(sum(dy^{DR})\) of the heading angle within 5 s is calculated, as well as the times when the absolute value of the heading angle change is higher than 3 degrees. Thus, it is possible to determine whether the vehicle is located in a curve, according to the following formula:  
\[\left\{\begin{aligned} count=0,sum(d\psi^{DR})<4& curve\\ count>=2,sum(d\psi^{DR})>6& curve\\ \end{aligned}\right. \tag{16}\]  
The second step of heading angle correction is map matching. Map matching is usually performed using the traditional method point-to-point, point-to-line, or line-to-line. There are also probabilistic methods based on Hidden Markov. In order to ensure real time positioning, this work adopts the point-to-line matching method [24; 25]. The accuracy and time consumption of map matching is mainly focused so that the designed map matching method contains many constraints. The detailed steps are as follows: Firstly, according to the latest positioning results, the road segments with a distance higher than 400 m or a length of lower than 15 m were filtered out. Then, according to the latest DR heading angle, the line segments with a heading angle different by more than 20 degrees were filtered out. Then, according to the projection of the point to the line segment, all the line segments that cannot be vertically projected were removed. Finally, the line segment with the shortest vertical projection distance was selected so that the direction of the road segment was used to correct the heading angle.  
Due to the low position accuracy of the OSM road network, the map matching method may incorrectly match adjacent lanes. The heading angle correction needs only the direction information of the road, so matching it to the adjacent lane does not affect the final result.