Vehicle GPS track completion method and device
By combining extended Kalman filtering and the Transformer model, the problems of uneven sampling, point errors, and missing data in vehicle GPS trajectory acquisition systems are solved, achieving high-precision trajectory completion, which is applicable to fields such as intelligent transportation and autonomous driving.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-04-07
AI Technical Summary
Existing vehicle GPS trajectory acquisition systems suffer from uneven sampling time intervals, large GPS point errors, and severe trajectory loss, resulting in insufficient trajectory continuity and accuracy. Traditional methods cannot effectively remove noise points and have insufficient ability to fit complex trajectory patterns.
By combining extended Kalman filtering with the Transformer model, and through data preprocessing, trajectory correction, sequence modeling and completion, result fusion and visualization, the method utilizes physical motion models and sequence prediction capabilities to achieve smooth and accurate trajectory completion.
It improves the robustness and accuracy of trajectory completion, adapts to various missing modes, saves data storage and transmission resources, and is suitable for online and embedded scenarios.
Smart Images

Figure CN121807984A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent transportation and space-time data processing, and specifically provides a vehicle GPS trajectory completion method and device. BACKGROUND
[0002] With the rapid development of Internet of Vehicles and Intelligent Transportation Systems (ITS), GPS-based trajectory data collection and analysis technology is widely used in urban traffic management, fleet dispatching, intelligent navigation, autonomous driving and other fields.
[0003] However, the existing vehicle GPS trajectory collection system has the following technical problems:
[0004] Uneven or too large sampling time interval: due to device performance, network delay or energy saving strategy, the vehicle terminal often has a fixed, too large sampling time interval during trajectory collection, which affects the continuity and authenticity of the trajectory.
[0005] Obvious GPS point error: due to environmental factors such as shielding, urban canyon effect, multipath propagation, weather, etc., the GPS trajectory points have a certain degree of jitter and drift, affecting the subsequent trajectory analysis and positioning accuracy.
[0006] There are a large number of missing points: in the environment without GPS signal such as tunnel, basement, etc., the vehicle trajectory will be interrupted for a long time, forming a data missing band, which seriously affects the accuracy of trajectory reconstruction, trajectory mining and behavior prediction.
[0007] Traditional methods have limitations: the commonly used trajectory completion methods such as linear interpolation, spline interpolation, acceleration model, etc. can solve the problem of trajectory missing to some extent, but have the following shortcomings:
[0008] 1. Unable to effectively remove noise points;
[0009] 2. Insufficient fitting ability for complex trajectory patterns (such as turning and stopping);
[0010] 3. The prediction effect of long-time missing segment is not ideal.
[0011] Deep learning method does not fully integrate physical motion model: some studies try to use recurrent neural network (RNN), graph neural network (GNN) and other methods for trajectory completion, but due to the lack of modeling of vehicle dynamics and motion rules, there are problems such as large prediction deviation and strong training dependence, and a high-precision, strong-robustness general trajectory completion method has not yet been formed.
[0012] In summary, the prior art cannot balance the smoothness, accuracy and robustness of the trajectory, especially under complex conditions such as sparse GPS sampling, large point deviation and long missing time, still facing great technical bottlenecks. SUMMARY
[0013] The present application is aimed at the deficiencies of the prior art, and provides a practical vehicle GPS trajectory completion method.
[0014] The further technical task of the present application is to provide a vehicle GPS trajectory completion device with reasonable design and safety.
[0015] The technical solution adopted by the present application to solve its technical problems is:
[0016] A vehicle GPS trajectory completion method based on extended Kalman filtering and Transformer model, having the following steps:
[0017] S1, data preprocessing;
[0018] S2, extended Kalman filtering trajectory correction;
[0019] S3, Transformer trajectory sequence modeling and completion;
[0020] S4, result fusion and trajectory restoration;
[0021] S5, trajectory output and visualization.
[0022] Further, in step S1, the vehicle trajectory data is collected, the trajectory data includes timestamp, longitude, latitude, speed and heading angle, the data is sorted in ascending order of timestamp, the time interval Δt of adjacent points is calculated, the GPS longitude and latitude coordinates are converted into two-dimensional plane coordinate system for subsequent modeling processing, and the time period with missing data in the data is identified and marked.
[0023] Further, in step S2, according to the motion characteristics of the vehicle, the state vector of the vehicle in the two-dimensional plane is defined as follows:
[0024]
[0025] Wherein:
[0026] x k ,y k : the plane coordinates of the current position of the vehicle;
[0027] v k : the current speed of the vehicle;
[0028] θ k : the current heading angle of the vehicle;
[0029] Based on the vehicle uniform straight or approximate turning model, in the time interval Δt=t k -t k-1 If the vehicle moves at a constant speed, the state transition function is constructed, and the state transition function is constructed:
[0030]
[0031] The collected GPS points are used as observation input to iteratively update the state estimation value, realize the denoising and smoothing of the trajectory points, and the specific observation model is as follows:
[0032]
[0033] The observation function is:
[0034] z k =H·x k +W k
[0035] w k is the observation noise, and wherein:
[0036]
[0037] And since the state transition function is nonlinear, the Jacobian matrix F k about the state needs to be calculated.
[0038]
[0039] The initial state estimation is given by the first GPS point, and for each non-missing point, the next position is predicted according to the vehicle motion model, and the EKF update is performed using the current GPS observation value. If a point has no GPS data but the interval between the previous and next points is less than a certain time, the predicted value is used to complete it.
[0040] Further, the specific EKF algorithm steps are as follows:
[0041] (1) Prediction stage;
[0042] X k|k-1 =f(x k-1 )
[0043]
[0044] Wherein, P k is the state covariance matrix;
[0045] (2) Update stage;
[0046] Kalman gain:
[0047]
[0048] It is the transpose of the observation matrix H;
[0049] Status Update:
[0050] x k =x k|k-1 +K k (z k -Hx k|k-1 )
[0051] Covariance update:
[0052] P k =(IK k H)P k|k-1
[0053] in:
[0054] I: is the identity matrix;
[0055] Q: Process noise covariance matrix;
[0056] R: Observation noise covariance matrix;
[0057] P k : State covariance matrix.
[0058] Furthermore, in step S3, the processed trajectory data is vector-encoded to construct the input sequence, with each trajectory point encoded as a vector:
[0059] e k =[x k ,y k ,v k ,θ k ,Δt k ]
[0060] Where, Δt k This indicates the time interval between the current point and the previous point;
[0061] The trajectory sequence is input into a Transformer model based on an Encoder-Decoder structure. An attention mechanism is used to predict the coordinates of missing points using global modeling capabilities. For missing segments with time intervals exceeding a threshold, the Transformer model is used for long-term trajectory prediction and completion.
[0062] Input Embedding Layer: For each e k Mapped to a high-dimensional vector E k ;
[0063] Positional encoding: introduces sequence information into a sequence;
[0064] Transformer encoder: Multi-layer self-attention and feedforward network construct global context representation;
[0065] E k ′=E k +PE k
[0066] PE k For position encoding;
[0067] The attention mechanism is defined as follows, with query Q, key K, and value V defined as:
[0068]
[0069] Let K be the transpose of the key vector matrix. This is the scaling factor for attention;
[0070] The decoder predicts the coordinates of missing points, and compares the predicted output coordinates with the original trajectory for evaluation or fusion into the final trajectory.
[0071]
[0072] The error between predicted and actual points can be evaluated using the Haversine distance formula:
[0073]
[0074] in:
[0075] R: Earth's radius;
[0076] φ, λ: Latitude and longitude in radians.
[0077] Furthermore, in step S4, the extended Kalman filter and the Transformer prediction results are fused, with EKF preferentially selected for short-time interpolation and Transformer for long-time missing prediction.
[0078] Convert the completed planar coordinates back to latitude and longitude coordinates and output the complete trajectory data;
[0079] The source of each trajectory point's completion is marked for subsequent analysis and credibility assessment.
[0080] Furthermore, in step S5, the completed trajectory data file is output, and the original trajectory, filtered trajectory and completed trajectory are visualized. The trajectory point error can be calculated to evaluate the completion effect.
[0081] A vehicle GPS trajectory completion device includes: at least one memory and at least one processor;
[0082] The at least one memory is used to store a machine-readable program;
[0083] The at least one processor is used to call the machine-readable program to execute a vehicle GPS trajectory completion method.
[0084] Compared with the prior art, the vehicle GPS trajectory completion method and apparatus of the present invention have the following outstanding advantages:
[0085] This method combines physical motion modeling and sequence prediction capabilities, making it adaptable to various missing trajectory patterns and exhibiting strong robustness. The extended Kalman filter provides real-time smoothing for continuous trajectory segments, making it suitable for embedded or online scenarios. The Transformer model can handle complex trajectory patterns and long-term missing segments, improving overall trajectory completion accuracy.
[0086] This method does not require high-frequency GPS sampling, saving data storage and transmission resources, and has good engineering applicability. Attached Figure Description
[0087] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0088] Figure 1 This is a flowchart illustrating a vehicle GPS trajectory completion method;
[0089] Figure 2 This is a flowchart illustrating the extended Kalman filter trajectory correction process in a vehicle GPS trajectory completion method.
[0090] Figure 3 This is a flowchart illustrating the Transformer trajectory sequence modeling and completion process in a vehicle GPS trajectory completion method. Detailed Implementation
[0091] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to specific embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0092] The following is a preferred embodiment:
[0093] Example 1:
[0094] like Figure 1 As shown, a vehicle GPS trajectory completion method in this embodiment includes the following steps:
[0095] S1, Data Preprocessing;
[0096] Vehicle trajectory data is collected, including: timestamp, longitude, latitude, speed, and heading angle, as shown in the sample data in the table below, which represents missing data:
[0097]
[0098] Sort the data in ascending order by timestamp, calculate the time interval Δt between adjacent points, convert the GPS latitude and longitude coordinates into a two-dimensional plane coordinate system (such as UTM or Mercator projection coordinates) for subsequent modeling and processing, and identify and mark the missing time periods in the data.
[0099] S2, Extended Kalman Filter Trajectory Correction;
[0100] like Figure 2 As shown, based on the vehicle's motion characteristics, the vehicle's state vector in the two-dimensional plane is defined as follows:
[0101]
[0102] in:
[0103] x k ,y k The planar coordinates of the vehicle's current position;
[0104] v k : Current speed of the vehicle (m / s);
[0105] θ k : Vehicle's current heading angle (in radians).
[0106] Based on a vehicle's uniform linear or approximate turning model, at a time interval Δt = t k -t k-1 If the vehicle moves at a constant speed, then construct a state transition function:
[0107]
[0108] Using the collected GPS points as observation input, the state estimate is iteratively updated to achieve denoising and smoothing of the trajectory points. The specific observation model is as follows:
[0109]
[0110] The observation function is:
[0111] z k =H·x k +w k
[0112] H is the observation matrix under the state model;
[0113] w k The observed noise is (Gaussian white noise), and where:
[0114]
[0115] Furthermore, since the state transition function is nonlinear, it is necessary to calculate its Jacobian matrix F with respect to the state. k ;
[0116]
[0117] The initial state estimate is given by the first GPS point. For each non-missing point, the next position is predicted based on the vehicle motion model. The EKF is updated using the current GPS observation. If a point has no GPS data but the interval between it and the points before and after it is less than 20 seconds, the predicted value is used to complete the data.
[0118] The specific steps of the EKF algorithm are as follows:
[0119] (a) Forecasting phase;
[0120] x k|k-1 =f(x) k-1 )
[0121]
[0122] (II) Update Phase
[0123] Kalman gain:
[0124]
[0125] It is the transpose of the observation matrix H;
[0126] Status Update:
[0127] x k =x k|k-1 +K k (z k -Hx k|k-1 )
[0128] Covariance update:
[0129] P k =(IK k H)P k|k-1
[0130] Where I is the identity matrix; Q: process noise covariance matrix; R: observation noise covariance matrix; P k : State covariance matrix.
[0131] S3, Transformer trajectory sequence modeling and completion;
[0132] like Figure 3 As shown, the processed trajectory data is vector-encoded to construct an input sequence, including features such as coordinates, velocity, heading angle, and time interval. Each trajectory point is encoded as a vector.
[0133] e k =[x k ,y k ,v k ,θ k ,Δt k ]
[0134] Where Δt k This indicates the time interval between the current point and the previous point.
[0135] The trajectory sequence is input into a Transformer model based on an Encoder-Decoder structure. An attention mechanism is used to predict the coordinates of missing points by leveraging its global modeling capabilities. For missing segments with time intervals exceeding a threshold, the Transformer model is used for long-term trajectory prediction and completion.
[0136] Input embedding layer: For each e k Mapped to a high-dimensional vector E k ;
[0137] Positional encoding: introduces sequence information into a sequence;
[0138] Transformer encoder: Multi-layer self-attention and feedforward network construct global context representation;
[0139] E′ k =E k +PE k
[0140] PE k For position encoding;
[0141] The attention mechanism is defined as follows, with query Q, key K, and value V defined as:
[0142]
[0143] Let K be the transpose of the key vector matrix. This is the scaling factor for attention.
[0144] The decoder predicts the coordinates of missing points, and the predicted output coordinates can be compared with the original trajectory for evaluation or fused into the final trajectory.
[0145]
[0146] The error between predicted and actual points can be evaluated using the Haversine distance formula:
[0147]
[0148] Where: R: Earth's radius (approximately 6371 km);
[0149] φ, λ: Latitude and longitude in radians.
[0150] S4. Result fusion and trajectory reconstruction;
[0151] The results of extended Kalman filtering and Transformer predictions are fused, with EKF preferred for short-time interpolation and Transformer preferred for long-term missing data prediction.
[0152] Convert the completed planar coordinates back to latitude and longitude coordinates and output the complete trajectory data.
[0153] Mark the source of each trajectory point's completion (original / EKF / Transformer) to facilitate subsequent analysis and credibility assessment.
[0154] S5. Trajectory output and visualization;
[0155] Output the completed trajectory data file, visualize the original trajectory, filtered trajectory and completed trajectory, and calculate trajectory point errors (such as Haversine distance) to evaluate the completion effect.
[0156] Example 2:
[0157] Example of vehicle GPS trajectory point completion process:
[0158] This embodiment, based on actual trajectory data collected from intelligent connected vehicles in a certain city, uses the method of this application to repair and complete GPS trajectory points that are missing or noisy. The main steps include:
[0159] Step 1: Data preprocessing;
[0160] Collect vehicle trajectory data, including timestamps, longitude, latitude, speed, and heading angle, as shown in the sample data in the table below. The table represents missing data. Calculate the time interval between each pair of adjacent trajectory points, convert the latitude and longitude to metric plane coordinates (e.g., UTM), and mark time periods with no sampling exceeding 30 seconds as "missing segments."
[0161]
[0162]
[0163] Step 2: Extended Kalman filter trajectory repair;
[0164] State definition: x = [x coordinate, y coordinate, velocity v, heading angle θ]. The initial state estimate is given by the first GPS point. For each non-missing point, the next position is predicted according to the vehicle motion model, and the EKF is updated using the current GPS observations.
[0165] If a point has no GPS data but the interval between it and the points before and after it is less than 20 seconds, then the predicted value is used to complete the data.
[0166] After EKF processing, most of the drifts and jumps in the original trajectory are corrected, and the overall trajectory is smoother.
[0167] Step 3: Transformer trajectory completion;
[0168] The processed trajectory is used to construct a feature sequence, which includes: planar coordinates, velocity, direction, and time interval. After position encoding, it is input into the Transformer Encoder. For long-term missing segments (such as intervals missing 3 to 5 points): the context window is input (the first 5 points + the last 3 points), the planar coordinate prediction results of the missing points are output, and the completed planar coordinates are converted back to latitude and longitude.
[0169] This model uses offline reasoning and is suitable for intelligent completion of historical trajectory data.
[0170] Step 4: Result fusion and trajectory output;
[0171] For points with a missing time of less than 20 seconds, the EKF prediction value is used first. For long missing segments, the Transformer outputs the completion result, and outputs a trajectory table in a uniform format with the following fields:
[0172] timestamp, latitude, longitude, source, where source identifies the data source (original, EKF, Transformer).
[0173] Step 5: Trajectory Visualization and Effect Verification;
[0174] Visualize the trajectory before and after, use hidden points in the complete trajectory to simulate missing points, and calculate error metrics (such as Haversine distance).
[0175] Example 3:
[0176] A vehicle GPS trajectory completion device in this embodiment includes: at least one memory and at least one processor;
[0177] At least one memory for storing machine-readable programs;
[0178] At least one processor is configured to invoke the machine-readable program to execute a vehicle GPS trajectory completion method.
[0179] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can be a microprocessor or any conventional processor.
[0180] Memory is used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, memory can also include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart memory cards (SMC), secure digital cards (SD cards), flash memory cards, at least one disk storage device, flash memory devices, or other volatile solid-state storage devices.
[0181] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for completing a vehicle's GPS trajectory, characterized in that, Based on the extended Kalman filter and the Transformer model, the following steps are involved: S1, Data Preprocessing; S2, Extended Kalman Filter Trajectory Correction; S3, Transformer trajectory sequence modeling and completion; S4. Result fusion and trajectory reconstruction; S5, Trajectory Output and Visualization.
2. The vehicle GPS trajectory completion method according to claim 1, characterized in that, In step S1, vehicle trajectory data is collected, including timestamps, longitude, latitude, speed, and heading angle. The data is sorted in ascending order by timestamps, the time interval Δt between adjacent points is calculated, the GPS latitude and longitude coordinates are converted into a two-dimensional plane coordinate system for subsequent modeling processing, and missing time periods in the data are identified and marked.
3. The vehicle GPS trajectory completion method according to claim 2, characterized in that, In step S2, based on the vehicle's motion characteristics, the vehicle's state vector in the two-dimensional plane is defined as follows: in: x k ,y k The planar coordinates of the vehicle's current position; v k : Current speed of the vehicle; θ k : The vehicle's current heading angle; Based on a vehicle's uniform linear or approximate turning model, at a time interval Δt = t k -t k-1 If the vehicle moves at a constant speed, then construct a state transition function: Using the collected GPS points as observation input, the state estimate is iteratively updated to achieve denoising and smoothing of the trajectory points. The specific observation model is as follows: The observation function is: z k =H·x k +w k H is the observation matrix under the state model; w k For observing noise, and where: Furthermore, since the state transition function is nonlinear, it is necessary to calculate its Jacobian matrix F with respect to the state. k ; The initial state estimate is given by the first GPS point. For each non-missing point, the next position is predicted based on the vehicle motion model. The EKF is updated using the current GPS observations. If a point has no GPS data but the interval between it and the points before and after it is less than a certain time, the predicted value is used to fill in the missing data.
4. The vehicle GPS trajectory completion method according to claim 3, characterized in that, The specific steps of the EKF algorithm are as follows: (1) Prediction phase; x k|k-1 =f(x k-1 ) Among them, P k Here is the state covariance matrix; (2) Update phase; Kalman gain: It is the transpose of the observation matrix H; Status Update: x k =x k|k-1 +K k (z k -Hx k|k-1 ) Covariance update: P k =(I-K k H)P k|k-1 in: I: is the identity matrix; Q: Process noise covariance matrix; R: Observation noise covariance matrix; P k : State covariance matrix.
5. A vehicle GPS trajectory completion method according to claim 4, characterized in that, In step S3, the processed trajectory data is vector-encoded to construct the input sequence, with each trajectory point encoded as a vector: e k =[x k ,y k ,v k ,i k ,Δt k ] Where, Δt k This indicates the time interval between the current point and the previous point; The trajectory sequence is input into a Transformer model based on an Encoder-Decoder structure. An attention mechanism is used to predict the coordinates of missing points using global modeling capabilities. For missing segments with time intervals exceeding a threshold, the Transformer model is used for long-term trajectory prediction and completion. Input Embedding Layer: For each e k Mapped to a high-dimensional vector E k ; Positional encoding: introduces sequence information into a sequence; Transformer encoder: Multi-layer self-attention and feedforward network construct global context representation; It is k ′=E k +PE k PE k For position encoding; The attention mechanism is defined as follows, with query Q, key K, and value V defined as: Let K be the transpose of the key vector matrix. This is the scaling factor for attention; The decoder predicts the coordinates of missing points, and compares the predicted output coordinates with the original trajectory for evaluation or fusion into the final trajectory. The error between predicted and actual points can be evaluated using the Haversine distance formula: in: R: Earth's radius; φ, λ: latitude and longitude in radians.
6. A vehicle GPS trajectory completion method according to claim 5, characterized in that, In step S4, the extended Kalman filter and Transformer prediction results are fused, with EKF preferred for short-time interpolation and Transformer preferred for long-time missing prediction. Convert the completed planar coordinates back to latitude and longitude coordinates and output the complete trajectory data; The source of each trajectory point's completion is marked for subsequent analysis and credibility assessment.
7. A vehicle GPS trajectory completion method according to claim 5, characterized in that, In step S5, the completed trajectory data file is output, and the original trajectory, filtered trajectory and completed trajectory are visualized. The trajectory point error can be calculated to evaluate the completion effect.
8. A vehicle GPS trajectory completion device, characterized in that, include: At least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to invoke the machine-readable program to perform the method according to any one of claims 1 to 7.